dbus-pending-call.c
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* dbus-pending-call.c Object representing a call in progress.
*
* Copyright (C) 2002, 2003 Red Hat Inc.
*
* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
*
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <config.h>
#include "dbus-internals.h"
#include "dbus-connection-internal.h"
#include "dbus-message-internal.h"
#include "dbus-pending-call-internal.h"
#include "dbus-pending-call.h"
#include "dbus-list.h"
#include "dbus-threads.h"
#include "dbus-test.h"
#define CONNECTION_LOCK(connection) _dbus_connection_lock(connection)
#define CONNECTION_UNLOCK(connection) _dbus_connection_unlock(connection)
struct DBusPendingCall
{
DBusAtomic refcount;
DBusDataSlotList slot_list;
DBusPendingCallNotifyFunction function;
DBusConnection *connection;
DBusMessage *reply;
DBusTimeout *timeout;
DBusList *timeout_link;
dbus_uint32_t reply_serial;
unsigned int completed : 1;
unsigned int timeout_added : 1;
};
static void
_dbus_pending_call_trace_ref (DBusPendingCall *pending_call,
int old_refcount,
int new_refcount,
const char *why)
{
#ifdef DBUS_ENABLE_VERBOSE_MODE
static int enabled = -1;
_dbus_trace_ref ("DBusPendingCall", pending_call, old_refcount,
new_refcount, why, "DBUS_PENDING_CALL_TRACE", &enabled);
#endif
}
/* protected by _DBUS_LOCK_pending_call_slots */
static dbus_int32_t notify_user_data_slot = -1;
DBusPendingCall*
_dbus_pending_call_new_unlocked (DBusConnection *connection,
int timeout_milliseconds,
DBusTimeoutHandler timeout_handler)
{
DBusPendingCall *pending;
DBusTimeout *timeout;
_dbus_assert (timeout_milliseconds >= 0 || timeout_milliseconds == -1);
if (timeout_milliseconds == -1)
timeout_milliseconds = _DBUS_DEFAULT_TIMEOUT_VALUE;
if (!dbus_pending_call_allocate_data_slot (&notify_user_data_slot))
return NULL;
pending = dbus_new0 (DBusPendingCall, 1);
if (pending == NULL)
{
dbus_pending_call_free_data_slot (&notify_user_data_slot);
return NULL;
}
if (timeout_milliseconds != DBUS_TIMEOUT_INFINITE)
{
timeout = _dbus_timeout_new (timeout_milliseconds,
timeout_handler,
pending, NULL);
if (timeout == NULL)
{
dbus_pending_call_free_data_slot (&notify_user_data_slot);
dbus_free (pending);
return NULL;
}
pending->timeout = timeout;
}
else
{
pending->timeout = NULL;
}
_dbus_atomic_inc (&pending->refcount);
pending->connection = connection;
_dbus_connection_ref_unlocked (pending->connection);
_dbus_data_slot_list_init (&pending->slot_list);
_dbus_pending_call_trace_ref (pending, 0, 1, "new_unlocked");
return pending;
}
void
_dbus_pending_call_set_reply_unlocked (DBusPendingCall *pending,
DBusMessage *message)
{
if (message == NULL)
{
message = pending->timeout_link->data;
_dbus_list_clear (&pending->timeout_link);
}
else
dbus_message_ref (message);
_dbus_verbose (" handing message %p (%s) to pending call serial %u\n",
message,
dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN ?
"method return" :
dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR ?
"error" : "other type",
pending->reply_serial);
_dbus_assert (pending->reply == NULL);
_dbus_assert (pending->reply_serial == dbus_message_get_reply_serial (message));
pending->reply = message;
}
void
_dbus_pending_call_start_completion_unlocked (DBusPendingCall *pending)
{
_dbus_assert (!pending->completed);
pending->completed = TRUE;
}
void
_dbus_pending_call_finish_completion (DBusPendingCall *pending)
{
_dbus_assert (pending->completed);
if (pending->function)
{
void *user_data;
user_data = dbus_pending_call_get_data (pending,
notify_user_data_slot);
(* pending->function) (pending, user_data);
}
}
void
_dbus_pending_call_queue_timeout_error_unlocked (DBusPendingCall *pending,
DBusConnection *connection)
{
_dbus_assert (connection == pending->connection);
if (pending->timeout_link)
{
_dbus_connection_queue_synthesized_message_link (connection,
pending->timeout_link);
pending->timeout_link = NULL;
}
}
dbus_bool_t
_dbus_pending_call_is_timeout_added_unlocked (DBusPendingCall *pending)
{
_dbus_assert (pending != NULL);
return pending->timeout_added;
}
void
_dbus_pending_call_set_timeout_added_unlocked (DBusPendingCall *pending,
dbus_bool_t is_added)
{
_dbus_assert (pending != NULL);
pending->timeout_added = is_added;
}
DBusTimeout *
_dbus_pending_call_get_timeout_unlocked (DBusPendingCall *pending)
{
_dbus_assert (pending != NULL);
return pending->timeout;
}
dbus_uint32_t
_dbus_pending_call_get_reply_serial_unlocked (DBusPendingCall *pending)
{
_dbus_assert (pending != NULL);
return pending->reply_serial;
}
void
_dbus_pending_call_set_reply_serial_unlocked (DBusPendingCall *pending,
dbus_uint32_t serial)
{
_dbus_assert (pending != NULL);
_dbus_assert (pending->reply_serial == 0);
pending->reply_serial = serial;
}
DBusConnection *
_dbus_pending_call_get_connection_and_lock (DBusPendingCall *pending)
{
_dbus_assert (pending != NULL);
CONNECTION_LOCK (pending->connection);
return pending->connection;
}
DBusConnection *
_dbus_pending_call_get_connection_unlocked (DBusPendingCall *pending)
{
_dbus_assert (pending != NULL);
return pending->connection;
}
dbus_bool_t
_dbus_pending_call_set_timeout_error_unlocked (DBusPendingCall *pending,
DBusMessage *message,
dbus_uint32_t serial)
{
DBusList *reply_link;
DBusMessage *reply;
reply = dbus_message_new_error (message, DBUS_ERROR_NO_REPLY,
"Did not receive a reply. Possible causes include: "
"the remote application did not send a reply, "
"the message bus security policy blocked the reply, "
"the reply timeout expired, or "
"the network connection was broken.");
if (reply == NULL)
return FALSE;
reply_link = _dbus_list_alloc_link (reply);
if (reply_link == NULL)
{
/* it's OK to unref this, nothing that could have attached a callback
* has ever seen it */
dbus_message_unref (reply);
return FALSE;
}
pending->timeout_link = reply_link;
_dbus_pending_call_set_reply_serial_unlocked (pending, serial);
return TRUE;
}
DBusPendingCall *
_dbus_pending_call_ref_unlocked (DBusPendingCall *pending)
{
dbus_int32_t old_refcount;
old_refcount = _dbus_atomic_inc (&pending->refcount);
_dbus_pending_call_trace_ref (pending, old_refcount, old_refcount + 1,
"ref_unlocked");
return pending;
}
static void
_dbus_pending_call_last_unref (DBusPendingCall *pending)
{
DBusConnection *connection;
/* If we get here, we should be already detached
* from the connection, or never attached.
*/
_dbus_assert (!pending->timeout_added);
connection = pending->connection;
/* this assumes we aren't holding connection lock... */
_dbus_data_slot_list_free (&pending->slot_list);
if (pending->timeout != NULL)
_dbus_timeout_unref (pending->timeout);
if (pending->timeout_link)
{
dbus_message_unref ((DBusMessage *)pending->timeout_link->data);
_dbus_list_free_link (pending->timeout_link);
pending->timeout_link = NULL;
}
if (pending->reply)
{
dbus_message_unref (pending->reply);
pending->reply = NULL;
}
dbus_free (pending);
dbus_pending_call_free_data_slot (&notify_user_data_slot);
/* connection lock should not be held. */
/* Free the connection last to avoid a weird state while
* calling out to application code where the pending exists
* but not the connection.
*/
dbus_connection_unref (connection);
}
void
_dbus_pending_call_unref_and_unlock (DBusPendingCall *pending)
{
dbus_int32_t old_refcount;
old_refcount = _dbus_atomic_dec (&pending->refcount);
_dbus_assert (old_refcount > 0);
_dbus_pending_call_trace_ref (pending, old_refcount,
old_refcount - 1, "unref_and_unlock");
CONNECTION_UNLOCK (pending->connection);
if (old_refcount == 1)
_dbus_pending_call_last_unref (pending);
}
dbus_bool_t
_dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending)
{
return pending->completed;
}
static DBusDataSlotAllocator slot_allocator =
_DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (pending_call_slots));
dbus_bool_t
_dbus_pending_call_set_data_unlocked (DBusPendingCall *pending,
dbus_int32_t slot,
void *data,
DBusFreeFunction free_data_func)
{
DBusFreeFunction old_free_func;
void *old_data;
dbus_bool_t retval;
retval = _dbus_data_slot_list_set (&slot_allocator,
&pending->slot_list,
slot, data, free_data_func,
&old_free_func, &old_data);
/* Drop locks to call out to app code */
CONNECTION_UNLOCK (pending->connection);
if (retval)
{
if (old_free_func)
(* old_free_func) (old_data);
}
CONNECTION_LOCK (pending->connection);
return retval;
}
DBusPendingCall *
dbus_pending_call_ref (DBusPendingCall *pending)
{
dbus_int32_t old_refcount;
_dbus_return_val_if_fail (pending != NULL, NULL);
old_refcount = _dbus_atomic_inc (&pending->refcount);
_dbus_pending_call_trace_ref (pending, old_refcount, old_refcount + 1,
"ref");
return pending;
}
void
dbus_pending_call_unref (DBusPendingCall *pending)
{
dbus_int32_t old_refcount;
_dbus_return_if_fail (pending != NULL);
old_refcount = _dbus_atomic_dec (&pending->refcount);
_dbus_pending_call_trace_ref (pending, old_refcount, old_refcount - 1,
"unref");
if (old_refcount == 1)
_dbus_pending_call_last_unref(pending);
}
dbus_bool_t
dbus_pending_call_set_notify (DBusPendingCall *pending,
DBusPendingCallNotifyFunction function,
void *user_data,
DBusFreeFunction free_user_data)
{
dbus_bool_t ret = FALSE;
_dbus_return_val_if_fail (pending != NULL, FALSE);
CONNECTION_LOCK (pending->connection);
/* could invoke application code! */
if (!_dbus_pending_call_set_data_unlocked (pending, notify_user_data_slot,
user_data, free_user_data))
goto out;
pending->function = function;
ret = TRUE;
out:
CONNECTION_UNLOCK (pending->connection);
return ret;
}
void
dbus_pending_call_cancel (DBusPendingCall *pending)
{
_dbus_return_if_fail (pending != NULL);
_dbus_connection_remove_pending_call (pending->connection,
pending);
}
dbus_bool_t
dbus_pending_call_get_completed (DBusPendingCall *pending)
{
dbus_bool_t completed;
_dbus_return_val_if_fail (pending != NULL, FALSE);
CONNECTION_LOCK (pending->connection);
completed = pending->completed;
CONNECTION_UNLOCK (pending->connection);
return completed;
}
DBusMessage*
dbus_pending_call_steal_reply (DBusPendingCall *pending)
{
DBusMessage *message;
_dbus_return_val_if_fail (pending != NULL, NULL);
_dbus_return_val_if_fail (pending->completed, NULL);
_dbus_return_val_if_fail (pending->reply != NULL, NULL);
CONNECTION_LOCK (pending->connection);
message = pending->reply;
pending->reply = NULL;
CONNECTION_UNLOCK (pending->connection);
_dbus_message_trace_ref (message, -1, -1, "dbus_pending_call_steal_reply");
return message;
}
void
dbus_pending_call_block (DBusPendingCall *pending)
{
_dbus_return_if_fail (pending != NULL);
_dbus_connection_block_pending_call (pending);
}
dbus_bool_t
dbus_pending_call_allocate_data_slot (dbus_int32_t *slot_p)
{
_dbus_return_val_if_fail (slot_p != NULL, FALSE);
return _dbus_data_slot_allocator_alloc (&slot_allocator,
slot_p);
}
void
dbus_pending_call_free_data_slot (dbus_int32_t *slot_p)
{
_dbus_return_if_fail (slot_p != NULL);
_dbus_return_if_fail (*slot_p >= 0);
_dbus_data_slot_allocator_free (&slot_allocator, slot_p);
}
dbus_bool_t
dbus_pending_call_set_data (DBusPendingCall *pending,
dbus_int32_t slot,
void *data,
DBusFreeFunction free_data_func)
{
dbus_bool_t retval;
_dbus_return_val_if_fail (pending != NULL, FALSE);
_dbus_return_val_if_fail (slot >= 0, FALSE);
CONNECTION_LOCK (pending->connection);
retval = _dbus_pending_call_set_data_unlocked (pending, slot, data, free_data_func);
CONNECTION_UNLOCK (pending->connection);
return retval;
}
void*
dbus_pending_call_get_data (DBusPendingCall *pending,
dbus_int32_t slot)
{
void *res;
_dbus_return_val_if_fail (pending != NULL, NULL);
CONNECTION_LOCK (pending->connection);
res = _dbus_data_slot_list_get (&slot_allocator,
&pending->slot_list,
slot);
CONNECTION_UNLOCK (pending->connection);
return res;
}
_dbus_connection_remove_pending_call
void _dbus_connection_remove_pending_call(DBusConnection *connection, DBusPendingCall *pending)
Removes a pending call from the connection, such that the pending reply will be ignored.
Definition dbus-connection.c:1048
_dbus_connection_block_pending_call
void _dbus_connection_block_pending_call(DBusPendingCall *pending)
Blocks until a pending call times out or gets a reply.
Definition dbus-connection.c:2394
_dbus_connection_queue_synthesized_message_link
void _dbus_connection_queue_synthesized_message_link(DBusConnection *connection, DBusList *link)
Adds a link + message to the incoming message queue.
Definition dbus-connection.c:549
_dbus_connection_ref_unlocked
DBUS_PRIVATE_EXPORT DBusConnection * _dbus_connection_ref_unlocked(DBusConnection *connection)
Increments the reference count of a DBusConnection.
Definition dbus-connection.c:1424
dbus_connection_unref
void dbus_connection_unref(DBusConnection *connection)
Decrements the reference count of a DBusConnection, and finalizes it if the count reaches zero.
Definition dbus-connection.c:2832
DBusPendingCallNotifyFunction
void(* DBusPendingCallNotifyFunction)(DBusPendingCall *pending, void *user_data)
Called when a pending call now has a reply available.
Definition dbus-connection.h:165
_dbus_data_slot_allocator_free
void _dbus_data_slot_allocator_free(DBusDataSlotAllocator *allocator, dbus_int32_t *slot_id_p)
Deallocates an ID previously allocated with _dbus_data_slot_allocator_alloc().
Definition dbus-dataslot.c:157
_dbus_data_slot_list_init
void _dbus_data_slot_list_init(DBusDataSlotList *list)
Initializes a slot list.
Definition dbus-dataslot.c:200
_dbus_data_slot_list_free
void _dbus_data_slot_list_free(DBusDataSlotList *list)
Frees the data slot list and all data slots contained in it, calling application-provided free functi...
Definition dbus-dataslot.c:343
_dbus_data_slot_list_get
void * _dbus_data_slot_list_get(DBusDataSlotAllocator *allocator, DBusDataSlotList *list, int slot)
Retrieves data previously set with _dbus_data_slot_list_set_data().
Definition dbus-dataslot.c:288
_dbus_data_slot_list_set
dbus_bool_t _dbus_data_slot_list_set(DBusDataSlotAllocator *allocator, DBusDataSlotList *list, int slot, void *data, DBusFreeFunction free_data_func, DBusFreeFunction *old_free_func, void **old_data)
Stores a pointer in the data slot list, along with an optional function to be used for freeing the da...
Definition dbus-dataslot.c:224
_dbus_data_slot_allocator_alloc
dbus_bool_t _dbus_data_slot_allocator_alloc(DBusDataSlotAllocator *allocator, dbus_int32_t *slot_id_p)
Allocates an integer ID to be used for storing data in a DBusDataSlotList.
Definition dbus-dataslot.c:72
_dbus_assert
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
Definition dbus-internals.h:153
_DBUS_LOCK_NAME
#define _DBUS_LOCK_NAME(name)
Expands to name of a global lock variable.
Definition dbus-internals.h:436
_dbus_list_free_link
void _dbus_list_free_link(DBusList *link)
Frees a linked list node allocated with _dbus_list_alloc_link.
Definition dbus-list.c:257
_dbus_list_clear
void _dbus_list_clear(DBusList **list)
Frees all links in the list and sets the list head to NULL.
Definition dbus-list.c:545
_dbus_list_alloc_link
DBusList * _dbus_list_alloc_link(void *data)
Allocates a linked list node.
Definition dbus-list.c:245
NULL
#define NULL
A null pointer, defined appropriately for C or C++.
Definition dbus-macros.h:51
TRUE
#define TRUE
Expands to "1".
Definition dbus-macros.h:41
FALSE
#define FALSE
Expands to "0".
Definition dbus-macros.h:44
dbus_free
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition dbus-memory.c:710
DBusFreeFunction
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
Definition dbus-memory.h:65
dbus_new0
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
Definition dbus-memory.h:60
dbus_message_new_error
DBusMessage * dbus_message_new_error(DBusMessage *reply_to, const char *error_name, const char *error_message)
Creates a new message that is an error reply to another message.
Definition dbus-message.c:1515
dbus_message_get_type
int dbus_message_get_type(DBusMessage *message)
Gets the type of a message.
Definition dbus-message.c:1767
dbus_message_ref
DBusMessage * dbus_message_ref(DBusMessage *message)
Increments the reference count of a DBusMessage.
Definition dbus-message.c:1712
dbus_message_get_reply_serial
dbus_uint32_t dbus_message_get_reply_serial(DBusMessage *message)
Returns the serial that the message is a reply to or 0 if none.
Definition dbus-message.c:1208
dbus_message_unref
void dbus_message_unref(DBusMessage *message)
Decrements the reference count of a DBusMessage, freeing the message if the count reaches 0.
Definition dbus-message.c:1735
_dbus_pending_call_finish_completion
void _dbus_pending_call_finish_completion(DBusPendingCall *pending)
Call the notifier function for the pending call.
Definition dbus-pending-call.c:235
_dbus_pending_call_get_connection_and_lock
DBusConnection * _dbus_pending_call_get_connection_and_lock(DBusPendingCall *pending)
Gets the connection associated with this pending call.
Definition dbus-pending-call.c:352
_dbus_pending_call_ref_unlocked
DBusPendingCall * _dbus_pending_call_ref_unlocked(DBusPendingCall *pending)
Increments the reference count on a pending call, while the lock on its connection is already held.
Definition dbus-pending-call.c:423
_dbus_pending_call_queue_timeout_error_unlocked
void _dbus_pending_call_queue_timeout_error_unlocked(DBusPendingCall *pending, DBusConnection *connection)
If the pending call hasn't been timed out, add its timeout error reply to the connection's incoming m...
Definition dbus-pending-call.c:257
_dbus_pending_call_unref_and_unlock
void _dbus_pending_call_unref_and_unlock(DBusPendingCall *pending)
Decrements the reference count on a pending call, freeing it if the count reaches 0.
Definition dbus-pending-call.c:486
_dbus_pending_call_get_completed_unlocked
dbus_bool_t _dbus_pending_call_get_completed_unlocked(DBusPendingCall *pending)
Checks whether the pending call has received a reply yet, or not.
Definition dbus-pending-call.c:509
_dbus_pending_call_set_reply_unlocked
void _dbus_pending_call_set_reply_unlocked(DBusPendingCall *pending, DBusMessage *message)
Sets the reply of a pending call with the given message, or if the message is NULL,...
Definition dbus-pending-call.c:183
_dbus_pending_call_set_reply_serial_unlocked
void _dbus_pending_call_set_reply_serial_unlocked(DBusPendingCall *pending, dbus_uint32_t serial)
Sets the reply's serial number.
Definition dbus-pending-call.c:336
_dbus_pending_call_set_data_unlocked
dbus_bool_t _dbus_pending_call_set_data_unlocked(DBusPendingCall *pending, dbus_int32_t slot, void *data, DBusFreeFunction free_data_func)
Stores a pointer on a DBusPendingCall, along with an optional function to be used for freeing the dat...
Definition dbus-pending-call.c:531
_dbus_pending_call_new_unlocked
DBusPendingCall * _dbus_pending_call_new_unlocked(DBusConnection *connection, int timeout_milliseconds, DBusTimeoutHandler timeout_handler)
Creates a new pending reply object.
Definition dbus-pending-call.c:120
_dbus_pending_call_set_timeout_error_unlocked
dbus_bool_t _dbus_pending_call_set_timeout_error_unlocked(DBusPendingCall *pending, DBusMessage *message, dbus_uint32_t serial)
Sets the reply message associated with the pending call to a timeout error.
Definition dbus-pending-call.c:383
CONNECTION_LOCK
#define CONNECTION_LOCK(connection)
Internals of DBusPendingCall.
Definition dbus-pending-call.c:55
CONNECTION_UNLOCK
#define CONNECTION_UNLOCK(connection)
shorter and more visible way to write _dbus_connection_unlock()
Definition dbus-pending-call.c:59
_dbus_pending_call_start_completion_unlocked
void _dbus_pending_call_start_completion_unlocked(DBusPendingCall *pending)
Sets the pending call to completed.
Definition dbus-pending-call.c:218
_dbus_pending_call_is_timeout_added_unlocked
dbus_bool_t _dbus_pending_call_is_timeout_added_unlocked(DBusPendingCall *pending)
Checks to see if a timeout has been added.
Definition dbus-pending-call.c:277
_dbus_pending_call_get_reply_serial_unlocked
dbus_uint32_t _dbus_pending_call_get_reply_serial_unlocked(DBusPendingCall *pending)
Gets the reply's serial number.
Definition dbus-pending-call.c:322
_dbus_pending_call_get_connection_unlocked
DBusConnection * _dbus_pending_call_get_connection_unlocked(DBusPendingCall *pending)
Gets the connection associated with this pending call.
Definition dbus-pending-call.c:367
_dbus_pending_call_get_timeout_unlocked
DBusTimeout * _dbus_pending_call_get_timeout_unlocked(DBusPendingCall *pending)
Retrives the timeout.
Definition dbus-pending-call.c:308
_dbus_pending_call_set_timeout_added_unlocked
void _dbus_pending_call_set_timeout_added_unlocked(DBusPendingCall *pending, dbus_bool_t is_added)
Sets wether the timeout has been added.
Definition dbus-pending-call.c:292
dbus_pending_call_set_notify
dbus_bool_t dbus_pending_call_set_notify(DBusPendingCall *pending, DBusPendingCallNotifyFunction function, void *user_data, DBusFreeFunction free_user_data)
Sets a notification function to be called when the reply is received or the pending call times out.
Definition dbus-pending-call.c:651
dbus_pending_call_free_data_slot
void dbus_pending_call_free_data_slot(dbus_int32_t *slot_p)
Deallocates a global ID for DBusPendingCall data slots.
Definition dbus-pending-call.c:808
DBUS_TIMEOUT_INFINITE
#define DBUS_TIMEOUT_INFINITE
An integer constant representing an infinite timeout.
Definition dbus-pending-call.h:43
dbus_pending_call_ref
DBusPendingCall * dbus_pending_call_ref(DBusPendingCall *pending)
Increments the reference count on a pending call.
Definition dbus-pending-call.c:606
dbus_pending_call_get_data
void * dbus_pending_call_get_data(DBusPendingCall *pending, dbus_int32_t slot)
Retrieves data previously set with dbus_pending_call_set_data().
Definition dbus-pending-call.c:856
dbus_pending_call_steal_reply
DBusMessage * dbus_pending_call_steal_reply(DBusPendingCall *pending)
Gets the reply, or returns NULL if none has been received yet.
Definition dbus-pending-call.c:731
dbus_pending_call_cancel
void dbus_pending_call_cancel(DBusPendingCall *pending)
Cancels the pending call, such that any reply or error received will just be ignored.
Definition dbus-pending-call.c:692
dbus_pending_call_block
void dbus_pending_call_block(DBusPendingCall *pending)
Block until the pending call is completed.
Definition dbus-pending-call.c:766
dbus_pending_call_set_data
dbus_bool_t dbus_pending_call_set_data(DBusPendingCall *pending, dbus_int32_t slot, void *data, DBusFreeFunction free_data_func)
Stores a pointer on a DBusPendingCall, along with an optional function to be used for freeing the dat...
Definition dbus-pending-call.c:830
dbus_pending_call_allocate_data_slot
dbus_bool_t dbus_pending_call_allocate_data_slot(dbus_int32_t *slot_p)
Allocates an integer ID to be used for storing application-specific data on any DBusPendingCall.
Definition dbus-pending-call.c:788
dbus_pending_call_get_completed
dbus_bool_t dbus_pending_call_get_completed(DBusPendingCall *pending)
Checks whether the pending call has received a reply yet, or not.
Definition dbus-pending-call.c:708
dbus_pending_call_unref
void dbus_pending_call_unref(DBusPendingCall *pending)
Decrements the reference count on a pending call, freeing it if the count reaches 0.
Definition dbus-pending-call.c:626
DBUS_MESSAGE_TYPE_ERROR
#define DBUS_MESSAGE_TYPE_ERROR
Message type of an error reply message, see dbus_message_get_type().
Definition dbus-protocol.h:240
DBUS_MESSAGE_TYPE_METHOD_RETURN
#define DBUS_MESSAGE_TYPE_METHOD_RETURN
Message type of a method return message, see dbus_message_get_type().
Definition dbus-protocol.h:238
DBUS_ERROR_NO_REPLY
#define DBUS_ERROR_NO_REPLY
No reply to a message expecting one, usually means a timeout occurred.
Definition dbus-protocol.h:369
_dbus_atomic_dec
dbus_int32_t _dbus_atomic_dec(DBusAtomic *atomic)
Atomically decrement an integer.
Definition dbus-sysdeps-unix.c:3205
_dbus_atomic_inc
dbus_int32_t _dbus_atomic_inc(DBusAtomic *atomic)
Atomically increments an integer.
Definition dbus-sysdeps-unix.c:3178
_dbus_timeout_unref
void _dbus_timeout_unref(DBusTimeout *timeout)
Decrements the reference count of a DBusTimeout object and finalizes the object if the count reaches ...
Definition dbus-timeout.c:111
_dbus_timeout_new
DBusTimeout * _dbus_timeout_new(int interval, DBusTimeoutHandler handler, void *data, DBusFreeFunction free_data_function)
Creates a new DBusTimeout, enabled by default.
Definition dbus-timeout.c:66
DBusTimeoutHandler
dbus_bool_t(* DBusTimeoutHandler)(void *data)
function to run when the timeout is handled
Definition dbus-timeout.h:43
dbus_uint32_t
unsigned int dbus_uint32_t
A 32-bit unsigned integer on all platforms.
Definition dbus-arch-deps.h:45
dbus_int32_t
int dbus_int32_t
A 32-bit signed integer on all platforms.
Definition dbus-arch-deps.h:44
dbus_bool_t
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition dbus-types.h:37
DBusAtomic
An atomic integer safe to increment or decrement from multiple threads.
Definition dbus-sysdeps.h:340
DBusConnection
Implementation details of DBusConnection.
Definition dbus-connection.c:259
DBusDataSlotAllocator
An allocator that tracks a set of slot IDs.
Definition dbus-dataslot.h:58
DBusDataSlotList
Data structure that stores the actual user data set at a given slot.
Definition dbus-dataslot.h:72
DBusList
A node in a linked list.
Definition dbus-list.h:37
DBusList::data
void * data
Data stored at this element.
Definition dbus-list.h:40
DBusMessage
Internals of DBusMessage.
Definition dbus-message-private.h:102
DBusPendingCall
Implementation details of DBusPendingCall - all fields are private.
Definition dbus-pending-call.c:65
DBusPendingCall::function
DBusPendingCallNotifyFunction function
Notifier when reply arrives.
Definition dbus-pending-call.c:70
DBusPendingCall::reply
DBusMessage * reply
Reply (after we've received it).
Definition dbus-pending-call.c:73
DBusPendingCall::timeout_link
DBusList * timeout_link
Preallocated timeout response.
Definition dbus-pending-call.c:76
DBusPendingCall::refcount
DBusAtomic refcount
reference count
Definition dbus-pending-call.c:66
DBusPendingCall::timeout_added
unsigned int timeout_added
TRUE if we have added the timeout.
Definition dbus-pending-call.c:89
DBusPendingCall::reply_serial
dbus_uint32_t reply_serial
Expected serial of reply.
Definition dbus-pending-call.c:78
DBusPendingCall::completed
unsigned int completed
TRUE if some thread has taken responsibility for completing this pending call: either the pending cal...
Definition dbus-pending-call.c:85
DBusPendingCall::slot_list
DBusDataSlotList slot_list
Data stored by allocated integer ID.
Definition dbus-pending-call.c:68
DBusPendingCall::connection
DBusConnection * connection
Connections we're associated with.
Definition dbus-pending-call.c:72
DBusPendingCall::timeout
DBusTimeout * timeout
Timeout.
Definition dbus-pending-call.c:74
DBusTimeout
Internals of DBusTimeout.
Definition dbus-timeout.c:43