D-Bus 1.14.10

dbus-pending-call.c
1/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2/* dbus-pending-call.c Object representing a call in progress.
3 *
4 * Copyright (C) 2002, 2003 Red Hat Inc.
5 *
6 * Licensed under the Academic Free License version 2.1
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 */
23
24#include <config.h>
25#include "dbus-internals.h"
26#include "dbus-connection-internal.h"
27#include "dbus-message-internal.h"
28#include "dbus-pending-call-internal.h"
29#include "dbus-pending-call.h"
30#include "dbus-list.h"
31#include "dbus-threads.h"
32#include "dbus-test.h"
33
53#define CONNECTION_LOCK(connection) _dbus_connection_lock(connection)
57#define CONNECTION_UNLOCK(connection) _dbus_connection_unlock(connection)
58
62 struct DBusPendingCall
63{
64 DBusAtomic refcount;
66 DBusDataSlotList slot_list;
68 DBusPendingCallNotifyFunction function;
70 DBusConnection *connection;
71 DBusMessage *reply;
72 DBusTimeout *timeout;
74 DBusList *timeout_link;
76 dbus_uint32_t reply_serial;
83 unsigned int completed : 1;
87 unsigned int timeout_added : 1;
88};
89
90 static void
91_dbus_pending_call_trace_ref (DBusPendingCall *pending_call,
92 int old_refcount,
93 int new_refcount,
94 const char *why)
95{
96#ifdef DBUS_ENABLE_VERBOSE_MODE
97 static int enabled = -1;
98
99 _dbus_trace_ref ("DBusPendingCall", pending_call, old_refcount,
100 new_refcount, why, "DBUS_PENDING_CALL_TRACE", &enabled);
101#endif
102}
103
104/* protected by _DBUS_LOCK_pending_call_slots */
105 static dbus_int32_t notify_user_data_slot = -1;
106
117 DBusPendingCall*
118_dbus_pending_call_new_unlocked (DBusConnection *connection,
119 int timeout_milliseconds,
120 DBusTimeoutHandler timeout_handler)
121{
122 DBusPendingCall *pending;
123 DBusTimeout *timeout;
124
125 _dbus_assert (timeout_milliseconds >= 0 || timeout_milliseconds == -1);
126
127 if (timeout_milliseconds == -1)
128 timeout_milliseconds = _DBUS_DEFAULT_TIMEOUT_VALUE;
129
130 if (!dbus_pending_call_allocate_data_slot (&notify_user_data_slot))
131 return NULL;
132
133 pending = dbus_new0 (DBusPendingCall, 1);
134
135 if (pending == NULL)
136 {
137 dbus_pending_call_free_data_slot (&notify_user_data_slot);
138 return NULL;
139 }
140
141 if (timeout_milliseconds != DBUS_TIMEOUT_INFINITE)
142 {
143 timeout = _dbus_timeout_new (timeout_milliseconds,
144 timeout_handler,
145 pending, NULL);
146
147 if (timeout == NULL)
148 {
149 dbus_pending_call_free_data_slot (&notify_user_data_slot);
150 dbus_free (pending);
151 return NULL;
152 }
153
154 pending->timeout = timeout;
155 }
156 else
157 {
158 pending->timeout = NULL;
159 }
160
161 _dbus_atomic_inc (&pending->refcount);
162 pending->connection = connection;
163 _dbus_connection_ref_unlocked (pending->connection);
164
165 _dbus_data_slot_list_init (&pending->slot_list);
166
167 _dbus_pending_call_trace_ref (pending, 0, 1, "new_unlocked");
168
169 return pending;
170}
171
180 void
181_dbus_pending_call_set_reply_unlocked (DBusPendingCall *pending,
182 DBusMessage *message)
183{
184 if (message == NULL)
185 {
186 message = pending->timeout_link->data;
187 _dbus_list_clear (&pending->timeout_link);
188 }
189 else
190 dbus_message_ref (message);
191
192 _dbus_verbose (" handing message %p (%s) to pending call serial %u\n",
193 message,
194 dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN ?
195 "method return" :
196 dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR ?
197 "error" : "other type",
198 pending->reply_serial);
199
200 _dbus_assert (pending->reply == NULL);
201 _dbus_assert (pending->reply_serial == dbus_message_get_reply_serial (message));
202 pending->reply = message;
203}
204
215 void
216_dbus_pending_call_start_completion_unlocked (DBusPendingCall *pending)
217{
218 _dbus_assert (!pending->completed);
219
220 pending->completed = TRUE;
221}
222
232 void
233_dbus_pending_call_finish_completion (DBusPendingCall *pending)
234{
235 _dbus_assert (pending->completed);
236
237 if (pending->function)
238 {
239 void *user_data;
240 user_data = dbus_pending_call_get_data (pending,
241 notify_user_data_slot);
242
243 (* pending->function) (pending, user_data);
244 }
245}
246
254 void
255_dbus_pending_call_queue_timeout_error_unlocked (DBusPendingCall *pending,
256 DBusConnection *connection)
257{
258 _dbus_assert (connection == pending->connection);
259
260 if (pending->timeout_link)
261 {
262 _dbus_connection_queue_synthesized_message_link (connection,
263 pending->timeout_link);
264 pending->timeout_link = NULL;
265 }
266}
267
274dbus_bool_t
275_dbus_pending_call_is_timeout_added_unlocked (DBusPendingCall *pending)
276{
277 _dbus_assert (pending != NULL);
278
279 return pending->timeout_added;
280}
281
282
289 void
290_dbus_pending_call_set_timeout_added_unlocked (DBusPendingCall *pending,
291 dbus_bool_t is_added)
292{
293 _dbus_assert (pending != NULL);
294
295 pending->timeout_added = is_added;
296}
297
298
305 DBusTimeout *
306_dbus_pending_call_get_timeout_unlocked (DBusPendingCall *pending)
307{
308 _dbus_assert (pending != NULL);
309
310 return pending->timeout;
311}
312
319dbus_uint32_t
320_dbus_pending_call_get_reply_serial_unlocked (DBusPendingCall *pending)
321{
322 _dbus_assert (pending != NULL);
323
324 return pending->reply_serial;
325}
326
333 void
334_dbus_pending_call_set_reply_serial_unlocked (DBusPendingCall *pending,
335 dbus_uint32_t serial)
336{
337 _dbus_assert (pending != NULL);
338 _dbus_assert (pending->reply_serial == 0);
339
340 pending->reply_serial = serial;
341}
342
349 DBusConnection *
350_dbus_pending_call_get_connection_and_lock (DBusPendingCall *pending)
351{
352 _dbus_assert (pending != NULL);
353
354 CONNECTION_LOCK (pending->connection);
355 return pending->connection;
356}
357
364 DBusConnection *
365_dbus_pending_call_get_connection_unlocked (DBusPendingCall *pending)
366{
367 _dbus_assert (pending != NULL);
368
369 return pending->connection;
370}
371
380dbus_bool_t
381_dbus_pending_call_set_timeout_error_unlocked (DBusPendingCall *pending,
382 DBusMessage *message,
383 dbus_uint32_t serial)
384{
385 DBusList *reply_link;
386 DBusMessage *reply;
387
388 reply = dbus_message_new_error (message, DBUS_ERROR_NO_REPLY,
389 "Did not receive a reply. Possible causes include: "
390 "the remote application did not send a reply, "
391 "the message bus security policy blocked the reply, "
392 "the reply timeout expired, or "
393 "the network connection was broken.");
394 if (reply == NULL)
395 return FALSE;
396
397 reply_link = _dbus_list_alloc_link (reply);
398 if (reply_link == NULL)
399 {
400 /* it's OK to unref this, nothing that could have attached a callback
401 * has ever seen it */
402 dbus_message_unref (reply);
403 return FALSE;
404 }
405
406 pending->timeout_link = reply_link;
407
408 _dbus_pending_call_set_reply_serial_unlocked (pending, serial);
409
410 return TRUE;
411}
412
420 DBusPendingCall *
421_dbus_pending_call_ref_unlocked (DBusPendingCall *pending)
422{
423 dbus_int32_t old_refcount;
424
425 old_refcount = _dbus_atomic_inc (&pending->refcount);
426 _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount + 1,
427 "ref_unlocked");
428
429 return pending;
430}
431
432
433 static void
434_dbus_pending_call_last_unref (DBusPendingCall *pending)
435{
436 DBusConnection *connection;
437
438 /* If we get here, we should be already detached
439 * from the connection, or never attached.
440 */
441 _dbus_assert (!pending->timeout_added);
442
443 connection = pending->connection;
444
445 /* this assumes we aren't holding connection lock... */
446 _dbus_data_slot_list_free (&pending->slot_list);
447
448 if (pending->timeout != NULL)
449 _dbus_timeout_unref (pending->timeout);
450
451 if (pending->timeout_link)
452 {
453 dbus_message_unref ((DBusMessage *)pending->timeout_link->data);
454 _dbus_list_free_link (pending->timeout_link);
455 pending->timeout_link = NULL;
456 }
457
458 if (pending->reply)
459 {
460 dbus_message_unref (pending->reply);
461 pending->reply = NULL;
462 }
463
464 dbus_free (pending);
465
466 dbus_pending_call_free_data_slot (&notify_user_data_slot);
467
468 /* connection lock should not be held. */
469 /* Free the connection last to avoid a weird state while
470 * calling out to application code where the pending exists
471 * but not the connection.
472 */
473 dbus_connection_unref (connection);
474}
475
483 void
484_dbus_pending_call_unref_and_unlock (DBusPendingCall *pending)
485{
486 dbus_int32_t old_refcount;
487
488 old_refcount = _dbus_atomic_dec (&pending->refcount);
489 _dbus_assert (old_refcount > 0);
490 _dbus_pending_call_trace_ref (pending, old_refcount,
491 old_refcount - 1, "unref_and_unlock");
492
493 CONNECTION_UNLOCK (pending->connection);
494
495 if (old_refcount == 1)
496 _dbus_pending_call_last_unref (pending);
497}
498
506dbus_bool_t
507_dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending)
508{
509 return pending->completed;
510}
511
512 static DBusDataSlotAllocator slot_allocator =
513 _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (pending_call_slots));
514
528dbus_bool_t
529_dbus_pending_call_set_data_unlocked (DBusPendingCall *pending,
530 dbus_int32_t slot,
531 void *data,
532 DBusFreeFunction free_data_func)
533{
534 DBusFreeFunction old_free_func;
535 void *old_data;
536 dbus_bool_t retval;
537
538 retval = _dbus_data_slot_list_set (&slot_allocator,
539 &pending->slot_list,
540 slot, data, free_data_func,
541 &old_free_func, &old_data);
542
543 /* Drop locks to call out to app code */
544 CONNECTION_UNLOCK (pending->connection);
545
546 if (retval)
547 {
548 if (old_free_func)
549 (* old_free_func) (old_data);
550 }
551
552 CONNECTION_LOCK (pending->connection);
553
554 return retval;
555}
556
603 DBusPendingCall *
604 dbus_pending_call_ref (DBusPendingCall *pending)
605{
606 dbus_int32_t old_refcount;
607
608 _dbus_return_val_if_fail (pending != NULL, NULL);
609
610 old_refcount = _dbus_atomic_inc (&pending->refcount);
611 _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount + 1,
612 "ref");
613
614 return pending;
615}
616
623 void
624 dbus_pending_call_unref (DBusPendingCall *pending)
625{
626 dbus_int32_t old_refcount;
627
628 _dbus_return_if_fail (pending != NULL);
629
630 old_refcount = _dbus_atomic_dec (&pending->refcount);
631 _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount - 1,
632 "unref");
633
634 if (old_refcount == 1)
635 _dbus_pending_call_last_unref(pending);
636}
637
648dbus_bool_t
649 dbus_pending_call_set_notify (DBusPendingCall *pending,
650 DBusPendingCallNotifyFunction function,
651 void *user_data,
652 DBusFreeFunction free_user_data)
653{
654 dbus_bool_t ret = FALSE;
655
656 _dbus_return_val_if_fail (pending != NULL, FALSE);
657
658 CONNECTION_LOCK (pending->connection);
659
660 /* could invoke application code! */
661 if (!_dbus_pending_call_set_data_unlocked (pending, notify_user_data_slot,
662 user_data, free_user_data))
663 goto out;
664
665 pending->function = function;
666 ret = TRUE;
667
668out:
669 CONNECTION_UNLOCK (pending->connection);
670
671 return ret;
672}
673
689 void
690 dbus_pending_call_cancel (DBusPendingCall *pending)
691{
692 _dbus_return_if_fail (pending != NULL);
693
694 _dbus_connection_remove_pending_call (pending->connection,
695 pending);
696}
697
705dbus_bool_t
706 dbus_pending_call_get_completed (DBusPendingCall *pending)
707{
708 dbus_bool_t completed;
709
710 _dbus_return_val_if_fail (pending != NULL, FALSE);
711
712 CONNECTION_LOCK (pending->connection);
713 completed = pending->completed;
714 CONNECTION_UNLOCK (pending->connection);
715
716 return completed;
717}
718
728 DBusMessage*
729 dbus_pending_call_steal_reply (DBusPendingCall *pending)
730{
731 DBusMessage *message;
732
733 _dbus_return_val_if_fail (pending != NULL, NULL);
734 _dbus_return_val_if_fail (pending->completed, NULL);
735 _dbus_return_val_if_fail (pending->reply != NULL, NULL);
736
737 CONNECTION_LOCK (pending->connection);
738
739 message = pending->reply;
740 pending->reply = NULL;
741
742 CONNECTION_UNLOCK (pending->connection);
743
744 _dbus_message_trace_ref (message, -1, -1, "dbus_pending_call_steal_reply");
745 return message;
746}
747
763 void
764 dbus_pending_call_block (DBusPendingCall *pending)
765{
766 _dbus_return_if_fail (pending != NULL);
767
768 _dbus_connection_block_pending_call (pending);
769}
770
785dbus_bool_t
786 dbus_pending_call_allocate_data_slot (dbus_int32_t *slot_p)
787{
788 _dbus_return_val_if_fail (slot_p != NULL, FALSE);
789
790 return _dbus_data_slot_allocator_alloc (&slot_allocator,
791 slot_p);
792}
793
805 void
806 dbus_pending_call_free_data_slot (dbus_int32_t *slot_p)
807{
808 _dbus_return_if_fail (slot_p != NULL);
809 _dbus_return_if_fail (*slot_p >= 0);
810
811 _dbus_data_slot_allocator_free (&slot_allocator, slot_p);
812}
813
827dbus_bool_t
828 dbus_pending_call_set_data (DBusPendingCall *pending,
829 dbus_int32_t slot,
830 void *data,
831 DBusFreeFunction free_data_func)
832{
833 dbus_bool_t retval;
834
835 _dbus_return_val_if_fail (pending != NULL, FALSE);
836 _dbus_return_val_if_fail (slot >= 0, FALSE);
837
838
839 CONNECTION_LOCK (pending->connection);
840 retval = _dbus_pending_call_set_data_unlocked (pending, slot, data, free_data_func);
841 CONNECTION_UNLOCK (pending->connection);
842 return retval;
843}
844
853 void*
854 dbus_pending_call_get_data (DBusPendingCall *pending,
855 dbus_int32_t slot)
856{
857 void *res;
858
859 _dbus_return_val_if_fail (pending != NULL, NULL);
860
861 CONNECTION_LOCK (pending->connection);
862 res = _dbus_data_slot_list_get (&slot_allocator,
863 &pending->slot_list,
864 slot);
865 CONNECTION_UNLOCK (pending->connection);
866
867 return res;
868}
869
_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:1046
_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:2392
_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:547
_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:1422
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:2828
DBusPendingCallNotifyFunction
void(* DBusPendingCallNotifyFunction)(DBusPendingCall *pending, void *user_data)
Called when a pending call now has a reply available.
Definition dbus-connection.h:163
_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:155
_dbus_data_slot_list_init
void _dbus_data_slot_list_init(DBusDataSlotList *list)
Initializes a slot list.
Definition dbus-dataslot.c:198
_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:341
_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:286
_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:222
_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:70
_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:420
_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:255
_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:543
_dbus_list_alloc_link
DBusList * _dbus_list_alloc_link(void *data)
Allocates a linked list node.
Definition dbus-list.c:243
NULL
#define NULL
A null pointer, defined appropriately for C or C++.
Definition dbus-macros.h:49
TRUE
#define TRUE
Expands to "1".
Definition dbus-macros.h:39
FALSE
#define FALSE
Expands to "0".
Definition dbus-macros.h:42
DBusFreeFunction
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
Definition dbus-memory.h:63
dbus_free
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition dbus-memory.c:692
dbus_new0
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
Definition dbus-memory.h:58
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:1503
dbus_message_get_type
int dbus_message_get_type(DBusMessage *message)
Gets the type of a message.
Definition dbus-message.c:1755
dbus_message_ref
DBusMessage * dbus_message_ref(DBusMessage *message)
Increments the reference count of a DBusMessage.
Definition dbus-message.c:1700
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:1196
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:1723
_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:233
_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:350
_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:421
_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:255
_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:484
_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:507
_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:181
_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:334
_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:529
_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:118
_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:381
CONNECTION_LOCK
#define CONNECTION_LOCK(connection)
Internals of DBusPendingCall.
Definition dbus-pending-call.c:53
CONNECTION_UNLOCK
#define CONNECTION_UNLOCK(connection)
shorter and more visible way to write _dbus_connection_unlock()
Definition dbus-pending-call.c:57
_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:216
_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:275
_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:320
_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:365
_dbus_pending_call_get_timeout_unlocked
DBusTimeout * _dbus_pending_call_get_timeout_unlocked(DBusPendingCall *pending)
Retrives the timeout.
Definition dbus-pending-call.c:306
_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:290
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:649
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:806
DBUS_TIMEOUT_INFINITE
#define DBUS_TIMEOUT_INFINITE
An integer constant representing an infinite timeout.
Definition dbus-pending-call.h:41
dbus_pending_call_ref
DBusPendingCall * dbus_pending_call_ref(DBusPendingCall *pending)
Increments the reference count on a pending call.
Definition dbus-pending-call.c:604
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:854
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:729
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:690
dbus_pending_call_block
void dbus_pending_call_block(DBusPendingCall *pending)
Block until the pending call is completed.
Definition dbus-pending-call.c:764
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:828
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:786
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:706
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:624
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:238
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:236
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:367
_dbus_atomic_dec
dbus_int32_t _dbus_atomic_dec(DBusAtomic *atomic)
Atomically decrement an integer.
Definition dbus-sysdeps-unix.c:3052
_dbus_atomic_inc
dbus_int32_t _dbus_atomic_inc(DBusAtomic *atomic)
Atomically increments an integer.
Definition dbus-sysdeps-unix.c:3029
_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:109
_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:64
DBusTimeoutHandler
dbus_bool_t(* DBusTimeoutHandler)(void *data)
function to run when the timeout is handled
Definition dbus-timeout.h:41
DBusAtomic
An atomic integer safe to increment or decrement from multiple threads.
Definition dbus-sysdeps.h:324
DBusConnection
Implementation details of DBusConnection.
Definition dbus-connection.c:257
DBusDataSlotAllocator
An allocator that tracks a set of slot IDs.
Definition dbus-dataslot.h:56
DBusDataSlotList
Data structure that stores the actual user data set at a given slot.
Definition dbus-dataslot.h:70
DBusList
A node in a linked list.
Definition dbus-list.h:35
DBusList::data
void * data
Data stored at this element.
Definition dbus-list.h:38
DBusMessage
Internals of DBusMessage.
Definition dbus-message-private.h:100
DBusPendingCall
Implementation details of DBusPendingCall - all fields are private.
Definition dbus-pending-call.c:63
DBusPendingCall::function
DBusPendingCallNotifyFunction function
Notifier when reply arrives.
Definition dbus-pending-call.c:68
DBusPendingCall::reply
DBusMessage * reply
Reply (after we've received it)
Definition dbus-pending-call.c:71
DBusPendingCall::timeout_link
DBusList * timeout_link
Preallocated timeout response.
Definition dbus-pending-call.c:74
DBusPendingCall::refcount
DBusAtomic refcount
reference count
Definition dbus-pending-call.c:64
DBusPendingCall::timeout_added
unsigned int timeout_added
TRUE if we have added the timeout.
Definition dbus-pending-call.c:87
DBusPendingCall::reply_serial
dbus_uint32_t reply_serial
Expected serial of reply.
Definition dbus-pending-call.c:76
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:83
DBusPendingCall::slot_list
DBusDataSlotList slot_list
Data stored by allocated integer ID.
Definition dbus-pending-call.c:66
DBusPendingCall::connection
DBusConnection * connection
Connections we're associated with.
Definition dbus-pending-call.c:70
DBusPendingCall::timeout
DBusTimeout * timeout
Timeout.
Definition dbus-pending-call.c:72
DBusTimeout
Internals of DBusTimeout.
Definition dbus-timeout.c:41