D-Bus: dbus-pending-call.c Source File

D-Bus 1.12.20

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)
54
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 static dbus_int32_t notify_user_data_slot = -1;
105
116 DBusPendingCall*
117 _dbus_pending_call_new_unlocked (DBusConnection *connection,
118 int timeout_milliseconds,
119 DBusTimeoutHandler timeout_handler)
120 {
121 DBusPendingCall *pending;
122 DBusTimeout *timeout;
123
124 _dbus_assert (timeout_milliseconds >= 0 || timeout_milliseconds == -1);
125
126 if (timeout_milliseconds == -1)
127 timeout_milliseconds = _DBUS_DEFAULT_TIMEOUT_VALUE;
128
129 if (!dbus_pending_call_allocate_data_slot (&notify_user_data_slot))
130 return NULL;
131
132 pending = dbus_new0 (DBusPendingCall, 1);
133
134 if (pending == NULL)
135 {
136 dbus_pending_call_free_data_slot (&notify_user_data_slot);
137 return NULL;
138 }
139
140 if (timeout_milliseconds != DBUS_TIMEOUT_INFINITE)
141 {
142 timeout = _dbus_timeout_new (timeout_milliseconds,
143 timeout_handler,
144 pending, NULL);
145
146 if (timeout == NULL)
147 {
148 dbus_pending_call_free_data_slot (&notify_user_data_slot);
149 dbus_free (pending);
150 return NULL;
151 }
152
153 pending->timeout = timeout;
154 }
155 else
156 {
157 pending->timeout = NULL;
158 }
159
160 _dbus_atomic_inc (&pending->refcount);
161 pending->connection = connection;
162 _dbus_connection_ref_unlocked (pending->connection);
163
164 _dbus_data_slot_list_init (&pending->slot_list);
165
166 _dbus_pending_call_trace_ref (pending, 0, 1, "new_unlocked");
167
168 return pending;
169 }
170
179 void
180 _dbus_pending_call_set_reply_unlocked (DBusPendingCall *pending,
181 DBusMessage *message)
182 {
183 if (message == NULL)
184 {
185 message = pending->timeout_link->data;
186 _dbus_list_clear (&pending->timeout_link);
187 }
188 else
189 dbus_message_ref (message);
190
191 _dbus_verbose (" handing message %p (%s) to pending call serial %u\n",
192 message,
193 dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN ?
194 "method return" :
195 dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR ?
196 "error" : "other type",
197 pending->reply_serial);
198
199 _dbus_assert (pending->reply == NULL);
200 _dbus_assert (pending->reply_serial == dbus_message_get_reply_serial (message));
201 pending->reply = message;
202 }
203
214 void
215 _dbus_pending_call_start_completion_unlocked (DBusPendingCall *pending)
216 {
217 _dbus_assert (!pending->completed);
218
219 pending->completed = TRUE;
220 }
221
231 void
232 _dbus_pending_call_finish_completion (DBusPendingCall *pending)
233 {
234 _dbus_assert (pending->completed);
235
236 if (pending->function)
237 {
238 void *user_data;
239 user_data = dbus_pending_call_get_data (pending,
240 notify_user_data_slot);
241
242 (* pending->function) (pending, user_data);
243 }
244 }
245
253 void
254 _dbus_pending_call_queue_timeout_error_unlocked (DBusPendingCall *pending,
255 DBusConnection *connection)
256 {
257 _dbus_assert (connection == pending->connection);
258
259 if (pending->timeout_link)
260 {
261 _dbus_connection_queue_synthesized_message_link (connection,
262 pending->timeout_link);
263 pending->timeout_link = NULL;
264 }
265 }
266
273 dbus_bool_t
274 _dbus_pending_call_is_timeout_added_unlocked (DBusPendingCall *pending)
275 {
276 _dbus_assert (pending != NULL);
277
278 return pending->timeout_added;
279 }
280
281
288 void
289 _dbus_pending_call_set_timeout_added_unlocked (DBusPendingCall *pending,
290 dbus_bool_t is_added)
291 {
292 _dbus_assert (pending != NULL);
293
294 pending->timeout_added = is_added;
295 }
296
297
304 DBusTimeout *
305 _dbus_pending_call_get_timeout_unlocked (DBusPendingCall *pending)
306 {
307 _dbus_assert (pending != NULL);
308
309 return pending->timeout;
310 }
311
318 dbus_uint32_t
319 _dbus_pending_call_get_reply_serial_unlocked (DBusPendingCall *pending)
320 {
321 _dbus_assert (pending != NULL);
322
323 return pending->reply_serial;
324 }
325
332 void
333 _dbus_pending_call_set_reply_serial_unlocked (DBusPendingCall *pending,
334 dbus_uint32_t serial)
335 {
336 _dbus_assert (pending != NULL);
337 _dbus_assert (pending->reply_serial == 0);
338
339 pending->reply_serial = serial;
340 }
341
348 DBusConnection *
349 _dbus_pending_call_get_connection_and_lock (DBusPendingCall *pending)
350 {
351 _dbus_assert (pending != NULL);
352
353 CONNECTION_LOCK (pending->connection);
354 return pending->connection;
355 }
356
363 DBusConnection *
364 _dbus_pending_call_get_connection_unlocked (DBusPendingCall *pending)
365 {
366 _dbus_assert (pending != NULL);
367
368 return pending->connection;
369 }
370
379 dbus_bool_t
380 _dbus_pending_call_set_timeout_error_unlocked (DBusPendingCall *pending,
381 DBusMessage *message,
382 dbus_uint32_t serial)
383 {
384 DBusList *reply_link;
385 DBusMessage *reply;
386
387 reply = dbus_message_new_error (message, DBUS_ERROR_NO_REPLY,
388 "Did not receive a reply. Possible causes include: "
389 "the remote application did not send a reply, "
390 "the message bus security policy blocked the reply, "
391 "the reply timeout expired, or "
392 "the network connection was broken.");
393 if (reply == NULL)
394 return FALSE;
395
396 reply_link = _dbus_list_alloc_link (reply);
397 if (reply_link == NULL)
398 {
399 /* it's OK to unref this, nothing that could have attached a callback
400 * has ever seen it */
401 dbus_message_unref (reply);
402 return FALSE;
403 }
404
405 pending->timeout_link = reply_link;
406
407 _dbus_pending_call_set_reply_serial_unlocked (pending, serial);
408
409 return TRUE;
410 }
411
419 DBusPendingCall *
420 _dbus_pending_call_ref_unlocked (DBusPendingCall *pending)
421 {
422 dbus_int32_t old_refcount;
423
424 old_refcount = _dbus_atomic_inc (&pending->refcount);
425 _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount + 1,
426 "ref_unlocked");
427
428 return pending;
429 }
430
431
432 static void
433 _dbus_pending_call_last_unref (DBusPendingCall *pending)
434 {
435 DBusConnection *connection;
436
437 /* If we get here, we should be already detached
438 * from the connection, or never attached.
439 */
440 _dbus_assert (!pending->timeout_added);
441
442 connection = pending->connection;
443
444 /* this assumes we aren't holding connection lock... */
445 _dbus_data_slot_list_free (&pending->slot_list);
446
447 if (pending->timeout != NULL)
448 _dbus_timeout_unref (pending->timeout);
449
450 if (pending->timeout_link)
451 {
452 dbus_message_unref ((DBusMessage *)pending->timeout_link->data);
453 _dbus_list_free_link (pending->timeout_link);
454 pending->timeout_link = NULL;
455 }
456
457 if (pending->reply)
458 {
459 dbus_message_unref (pending->reply);
460 pending->reply = NULL;
461 }
462
463 dbus_free (pending);
464
465 dbus_pending_call_free_data_slot (&notify_user_data_slot);
466
467 /* connection lock should not be held. */
468 /* Free the connection last to avoid a weird state while
469 * calling out to application code where the pending exists
470 * but not the connection.
471 */
472 dbus_connection_unref (connection);
473 }
474
482 void
483 _dbus_pending_call_unref_and_unlock (DBusPendingCall *pending)
484 {
485 dbus_int32_t old_refcount;
486
487 old_refcount = _dbus_atomic_dec (&pending->refcount);
488 _dbus_assert (old_refcount > 0);
489 _dbus_pending_call_trace_ref (pending, old_refcount,
490 old_refcount - 1, "unref_and_unlock");
491
492 CONNECTION_UNLOCK (pending->connection);
493
494 if (old_refcount == 1)
495 _dbus_pending_call_last_unref (pending);
496 }
497
505 dbus_bool_t
506 _dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending)
507 {
508 return pending->completed;
509 }
510
511 static DBusDataSlotAllocator slot_allocator =
512 _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (pending_call_slots));
513
527 dbus_bool_t
528 _dbus_pending_call_set_data_unlocked (DBusPendingCall *pending,
529 dbus_int32_t slot,
530 void *data,
531 DBusFreeFunction free_data_func)
532 {
533 DBusFreeFunction old_free_func;
534 void *old_data;
535 dbus_bool_t retval;
536
537 retval = _dbus_data_slot_list_set (&slot_allocator,
538 &pending->slot_list,
539 slot, data, free_data_func,
540 &old_free_func, &old_data);
541
542 /* Drop locks to call out to app code */
543 CONNECTION_UNLOCK (pending->connection);
544
545 if (retval)
546 {
547 if (old_free_func)
548 (* old_free_func) (old_data);
549 }
550
551 CONNECTION_LOCK (pending->connection);
552
553 return retval;
554 }
555
602 DBusPendingCall *
603 dbus_pending_call_ref (DBusPendingCall *pending)
604 {
605 dbus_int32_t old_refcount;
606
607 _dbus_return_val_if_fail (pending != NULL, NULL);
608
609 old_refcount = _dbus_atomic_inc (&pending->refcount);
610 _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount + 1,
611 "ref");
612
613 return pending;
614 }
615
622 void
623 dbus_pending_call_unref (DBusPendingCall *pending)
624 {
625 dbus_int32_t old_refcount;
626
627 _dbus_return_if_fail (pending != NULL);
628
629 old_refcount = _dbus_atomic_dec (&pending->refcount);
630 _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount - 1,
631 "unref");
632
633 if (old_refcount == 1)
634 _dbus_pending_call_last_unref(pending);
635 }
636
647 dbus_bool_t
648 dbus_pending_call_set_notify (DBusPendingCall *pending,
649 DBusPendingCallNotifyFunction function,
650 void *user_data,
651 DBusFreeFunction free_user_data)
652 {
653 dbus_bool_t ret = FALSE;
654
655 _dbus_return_val_if_fail (pending != NULL, FALSE);
656
657 CONNECTION_LOCK (pending->connection);
658
659 /* could invoke application code! */
660 if (!_dbus_pending_call_set_data_unlocked (pending, notify_user_data_slot,
661 user_data, free_user_data))
662 goto out;
663
664 pending->function = function;
665 ret = TRUE;
666
667 out:
668 CONNECTION_UNLOCK (pending->connection);
669
670 return ret;
671 }
672
688 void
689 dbus_pending_call_cancel (DBusPendingCall *pending)
690 {
691 _dbus_return_if_fail (pending != NULL);
692
693 _dbus_connection_remove_pending_call (pending->connection,
694 pending);
695 }
696
704 dbus_bool_t
705 dbus_pending_call_get_completed (DBusPendingCall *pending)
706 {
707 dbus_bool_t completed;
708
709 _dbus_return_val_if_fail (pending != NULL, FALSE);
710
711 CONNECTION_LOCK (pending->connection);
712 completed = pending->completed;
713 CONNECTION_UNLOCK (pending->connection);
714
715 return completed;
716 }
717
727 DBusMessage*
728 dbus_pending_call_steal_reply (DBusPendingCall *pending)
729 {
730 DBusMessage *message;
731
732 _dbus_return_val_if_fail (pending != NULL, NULL);
733 _dbus_return_val_if_fail (pending->completed, NULL);
734 _dbus_return_val_if_fail (pending->reply != NULL, NULL);
735
736 CONNECTION_LOCK (pending->connection);
737
738 message = pending->reply;
739 pending->reply = NULL;
740
741 CONNECTION_UNLOCK (pending->connection);
742
743 _dbus_message_trace_ref (message, -1, -1, "dbus_pending_call_steal_reply");
744 return message;
745 }
746
762 void
763 dbus_pending_call_block (DBusPendingCall *pending)
764 {
765 _dbus_return_if_fail (pending != NULL);
766
767 _dbus_connection_block_pending_call (pending);
768 }
769
784 dbus_bool_t
785 dbus_pending_call_allocate_data_slot (dbus_int32_t *slot_p)
786 {
787 _dbus_return_val_if_fail (slot_p != NULL, FALSE);
788
789 return _dbus_data_slot_allocator_alloc (&slot_allocator,
790 slot_p);
791 }
792
804 void
805 dbus_pending_call_free_data_slot (dbus_int32_t *slot_p)
806 {
807 _dbus_return_if_fail (slot_p != NULL);
808 _dbus_return_if_fail (*slot_p >= 0);
809
810 _dbus_data_slot_allocator_free (&slot_allocator, slot_p);
811 }
812
826 dbus_bool_t
827 dbus_pending_call_set_data (DBusPendingCall *pending,
828 dbus_int32_t slot,
829 void *data,
830 DBusFreeFunction free_data_func)
831 {
832 dbus_bool_t retval;
833
834 _dbus_return_val_if_fail (pending != NULL, FALSE);
835 _dbus_return_val_if_fail (slot >= 0, FALSE);
836
837
838 CONNECTION_LOCK (pending->connection);
839 retval = _dbus_pending_call_set_data_unlocked (pending, slot, data, free_data_func);
840 CONNECTION_UNLOCK (pending->connection);
841 return retval;
842 }
843
852 void*
853 dbus_pending_call_get_data (DBusPendingCall *pending,
854 dbus_int32_t slot)
855 {
856 void *res;
857
858 _dbus_return_val_if_fail (pending != NULL, NULL);
859
860 CONNECTION_LOCK (pending->connection);
861 res = _dbus_data_slot_list_get (&slot_allocator,
862 &pending->slot_list,
863 slot);
864 CONNECTION_UNLOCK (pending->connection);
865
866 return res;
867 }
868
_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
_dbus_atomic_dec
dbus_int32_t _dbus_atomic_dec(DBusAtomic *atomic)
Atomically decrement an integer.
Definition: dbus-sysdeps-unix.c:2866
_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:285
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:853
CONNECTION_LOCK
#define CONNECTION_LOCK(connection)
Internals of DBusPendingCall.
Definition: dbus-pending-call.c:53
_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:545
_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:319
dbus_message_ref
DBusMessage * dbus_message_ref(DBusMessage *message)
Increments the reference count of a DBusMessage.
Definition: dbus-message.c:1689
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:827
DBusPendingCall::refcount
DBusAtomic refcount
reference count
Definition: dbus-pending-call.c:64
_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:117
_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:542
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:1712
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
DBusFreeFunction
void(* DBusFreeFunction)(void *memory)
Definition: dbus-memory.h:63
DBusPendingCall::timeout_added
unsigned int timeout_added
TRUE if we have added the timeout.
Definition: dbus-pending-call.c:87
_dbus_list_alloc_link
DBusList * _dbus_list_alloc_link(void *data)
Allocates a linked list node.
Definition: dbus-list.c:242
_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:483
_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:420
_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:274
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:805
DBusConnection
Implementation details of DBusConnection.
Definition: dbus-connection.c:257
DBusPendingCall::reply_serial
dbus_uint32_t reply_serial
Expected serial of reply.
Definition: dbus-pending-call.c:76
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:648
_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:2380
DBusPendingCall::function
DBusPendingCallNotifyFunction function
Notifier when reply arrives.
Definition: dbus-pending-call.c:68
dbus_int32_t
int dbus_int32_t
Definition: dbus-arch-deps.h:42
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:623
TRUE
#define TRUE
DBUS_TIMEOUT_INFINITE
#define DBUS_TIMEOUT_INFINITE
Definition: dbus-pending-call.h:41
_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:221
DBusPendingCallNotifyFunction
void(* DBusPendingCallNotifyFunction)(DBusPendingCall *pending, void *user_data)
Called when a pending call now has a reply available.
Definition: dbus-connection.h:163
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:728
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:689
dbus_pending_call_block
void dbus_pending_call_block(DBusPendingCall *pending)
Block until the pending call is completed.
Definition: dbus-pending-call.c:763
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:705
DBusPendingCall::slot_list
DBusDataSlotList slot_list
Data stored by allocated integer ID.
Definition: dbus-pending-call.c:66
_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:289
_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:180
dbus_free
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition: dbus-memory.c:702
_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_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:254
CONNECTION_UNLOCK
#define CONNECTION_UNLOCK(connection)
shorter and more visible way to write _dbus_connection_unlock()
Definition: dbus-pending-call.c:57
_DBUS_LOCK_NAME
#define _DBUS_LOCK_NAME(name)
Definition: dbus-internals.h:371
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:363
DBusPendingCall::reply
DBusMessage * reply
Reply (after we've received it)
Definition: dbus-pending-call.c:71
_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:528
dbus_uint32_t
unsigned int dbus_uint32_t
Definition: dbus-arch-deps.h:43
DBusTimeout
Internals of DBusTimeout.
Definition: dbus-timeout.c:41
_dbus_data_slot_list_init
void _dbus_data_slot_list_init(DBusDataSlotList *list)
Initializes a slot list.
Definition: dbus-dataslot.c:197
_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:69
_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:349
FALSE
#define FALSE
DBusPendingCall::connection
DBusConnection * connection
Connections we're associated with.
Definition: dbus-pending-call.c:70
_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:340
_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:380
DBusMessage
Internals of DBusMessage.
Definition: dbus-message-private.h:100
DBusList::data
void * data
Data stored at this element.
Definition: dbus-list.h:38
_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:254
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_pending_call_ref
DBusPendingCall * dbus_pending_call_ref(DBusPendingCall *pending)
Increments the reference count on a pending call.
Definition: dbus-pending-call.c:603
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:1185
DBusAtomic
An atomic integer safe to increment or decrement from multiple threads.
Definition: dbus-sysdeps.h:307
_dbus_assert
#define _dbus_assert(condition)
Definition: dbus-internals.h:152
_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:1044
DBusPendingCall::timeout_link
DBusList * timeout_link
Preallocated timeout response.
Definition: dbus-pending-call.c:74
DBusDataSlotAllocator
An allocator that tracks a set of slot IDs.
Definition: dbus-dataslot.h:56
_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:364
_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:232
_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:215
DBusList
Definition: dbus-list.h:35
_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:154
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:2818
DBusTimeoutHandler
dbus_bool_t(* DBusTimeoutHandler)(void *data)
function to run when the timeout is handled
Definition: dbus-timeout.h:41
_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:506
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:785
_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:333
_dbus_atomic_inc
dbus_int32_t _dbus_atomic_inc(DBusAtomic *atomic)
Atomically increments an integer.
Definition: dbus-sysdeps-unix.c:2843
DBusDataSlotList
Data structure that stores the actual user data set at a given slot.
Definition: dbus-dataslot.h:70
_dbus_pending_call_get_timeout_unlocked
DBusTimeout * _dbus_pending_call_get_timeout_unlocked(DBusPendingCall *pending)
Retrives the timeout.
Definition: dbus-pending-call.c:305
dbus_message_get_type
int dbus_message_get_type(DBusMessage *message)
Gets the type of a message.
Definition: dbus-message.c:1744
DBusPendingCall
Implementation details of DBusPendingCall - all fields are private.
Definition: dbus-pending-call.c:63
dbus_new0
#define dbus_new0(type, count)
Definition: dbus-memory.h:58
_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:1419
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:1492
DBusPendingCall::timeout
DBusTimeout * timeout
Timeout.
Definition: dbus-pending-call.c:72
dbus_bool_t
dbus_uint32_t dbus_bool_t
Definition: dbus-types.h:35
NULL
#define NULL