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

D-Bus 1.10.22

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;
78 unsigned int completed : 1;
79 unsigned int timeout_added : 1;
80 };
81
82 static void
83 _dbus_pending_call_trace_ref (DBusPendingCall *pending_call,
84 int old_refcount,
85 int new_refcount,
86 const char *why)
87 {
88 #ifdef DBUS_ENABLE_VERBOSE_MODE
89 static int enabled = -1;
90
91 _dbus_trace_ref ("DBusPendingCall", pending_call, old_refcount,
92 new_refcount, why, "DBUS_PENDING_CALL_TRACE", &enabled);
93 #endif
94 }
95
96 static dbus_int32_t notify_user_data_slot = -1;
97
108 DBusPendingCall*
109 _dbus_pending_call_new_unlocked (DBusConnection *connection,
110 int timeout_milliseconds,
111 DBusTimeoutHandler timeout_handler)
112 {
113 DBusPendingCall *pending;
114 DBusTimeout *timeout;
115
116 _dbus_assert (timeout_milliseconds >= 0 || timeout_milliseconds == -1);
117
118 if (timeout_milliseconds == -1)
119 timeout_milliseconds = _DBUS_DEFAULT_TIMEOUT_VALUE;
120
121 if (!dbus_pending_call_allocate_data_slot (&notify_user_data_slot))
122 return NULL;
123
124 pending = dbus_new0 (DBusPendingCall, 1);
125
126 if (pending == NULL)
127 {
128 dbus_pending_call_free_data_slot (&notify_user_data_slot);
129 return NULL;
130 }
131
132 if (timeout_milliseconds != DBUS_TIMEOUT_INFINITE)
133 {
134 timeout = _dbus_timeout_new (timeout_milliseconds,
135 timeout_handler,
136 pending, NULL);
137
138 if (timeout == NULL)
139 {
140 dbus_pending_call_free_data_slot (&notify_user_data_slot);
141 dbus_free (pending);
142 return NULL;
143 }
144
145 pending->timeout = timeout;
146 }
147 else
148 {
149 pending->timeout = NULL;
150 }
151
152 _dbus_atomic_inc (&pending->refcount);
153 pending->connection = connection;
154 _dbus_connection_ref_unlocked (pending->connection);
155
156 _dbus_data_slot_list_init (&pending->slot_list);
157
158 _dbus_pending_call_trace_ref (pending, 0, 1, "new_unlocked");
159
160 return pending;
161 }
162
171 void
172 _dbus_pending_call_set_reply_unlocked (DBusPendingCall *pending,
173 DBusMessage *message)
174 {
175 if (message == NULL)
176 {
177 message = pending->timeout_link->data;
178 _dbus_list_clear (&pending->timeout_link);
179 }
180 else
181 dbus_message_ref (message);
182
183 _dbus_verbose (" handing message %p (%s) to pending call serial %u\n",
184 message,
185 dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN ?
186 "method return" :
187 dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR ?
188 "error" : "other type",
189 pending->reply_serial);
190
191 _dbus_assert (pending->reply == NULL);
192 _dbus_assert (pending->reply_serial == dbus_message_get_reply_serial (message));
193 pending->reply = message;
194 }
195
203 void
204 _dbus_pending_call_complete (DBusPendingCall *pending)
205 {
206 _dbus_assert (!pending->completed);
207
208 pending->completed = TRUE;
209
210 if (pending->function)
211 {
212 void *user_data;
213 user_data = dbus_pending_call_get_data (pending,
214 notify_user_data_slot);
215
216 (* pending->function) (pending, user_data);
217 }
218 }
219
227 void
228 _dbus_pending_call_queue_timeout_error_unlocked (DBusPendingCall *pending,
229 DBusConnection *connection)
230 {
231 _dbus_assert (connection == pending->connection);
232
233 if (pending->timeout_link)
234 {
235 _dbus_connection_queue_synthesized_message_link (connection,
236 pending->timeout_link);
237 pending->timeout_link = NULL;
238 }
239 }
240
247 dbus_bool_t
248 _dbus_pending_call_is_timeout_added_unlocked (DBusPendingCall *pending)
249 {
250 _dbus_assert (pending != NULL);
251
252 return pending->timeout_added;
253 }
254
255
262 void
263 _dbus_pending_call_set_timeout_added_unlocked (DBusPendingCall *pending,
264 dbus_bool_t is_added)
265 {
266 _dbus_assert (pending != NULL);
267
268 pending->timeout_added = is_added;
269 }
270
271
278 DBusTimeout *
279 _dbus_pending_call_get_timeout_unlocked (DBusPendingCall *pending)
280 {
281 _dbus_assert (pending != NULL);
282
283 return pending->timeout;
284 }
285
292 dbus_uint32_t
293 _dbus_pending_call_get_reply_serial_unlocked (DBusPendingCall *pending)
294 {
295 _dbus_assert (pending != NULL);
296
297 return pending->reply_serial;
298 }
299
306 void
307 _dbus_pending_call_set_reply_serial_unlocked (DBusPendingCall *pending,
308 dbus_uint32_t serial)
309 {
310 _dbus_assert (pending != NULL);
311 _dbus_assert (pending->reply_serial == 0);
312
313 pending->reply_serial = serial;
314 }
315
322 DBusConnection *
323 _dbus_pending_call_get_connection_and_lock (DBusPendingCall *pending)
324 {
325 _dbus_assert (pending != NULL);
326
327 CONNECTION_LOCK (pending->connection);
328 return pending->connection;
329 }
330
337 DBusConnection *
338 _dbus_pending_call_get_connection_unlocked (DBusPendingCall *pending)
339 {
340 _dbus_assert (pending != NULL);
341
342 return pending->connection;
343 }
344
353 dbus_bool_t
354 _dbus_pending_call_set_timeout_error_unlocked (DBusPendingCall *pending,
355 DBusMessage *message,
356 dbus_uint32_t serial)
357 {
358 DBusList *reply_link;
359 DBusMessage *reply;
360
361 reply = dbus_message_new_error (message, DBUS_ERROR_NO_REPLY,
362 "Did not receive a reply. Possible causes include: "
363 "the remote application did not send a reply, "
364 "the message bus security policy blocked the reply, "
365 "the reply timeout expired, or "
366 "the network connection was broken.");
367 if (reply == NULL)
368 return FALSE;
369
370 reply_link = _dbus_list_alloc_link (reply);
371 if (reply_link == NULL)
372 {
373 /* it's OK to unref this, nothing that could have attached a callback
374 * has ever seen it */
375 dbus_message_unref (reply);
376 return FALSE;
377 }
378
379 pending->timeout_link = reply_link;
380
381 _dbus_pending_call_set_reply_serial_unlocked (pending, serial);
382
383 return TRUE;
384 }
385
393 DBusPendingCall *
394 _dbus_pending_call_ref_unlocked (DBusPendingCall *pending)
395 {
396 dbus_int32_t old_refcount;
397
398 old_refcount = _dbus_atomic_inc (&pending->refcount);
399 _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount + 1,
400 "ref_unlocked");
401
402 return pending;
403 }
404
405
406 static void
407 _dbus_pending_call_last_unref (DBusPendingCall *pending)
408 {
409 DBusConnection *connection;
410
411 /* If we get here, we should be already detached
412 * from the connection, or never attached.
413 */
414 _dbus_assert (!pending->timeout_added);
415
416 connection = pending->connection;
417
418 /* this assumes we aren't holding connection lock... */
419 _dbus_data_slot_list_free (&pending->slot_list);
420
421 if (pending->timeout != NULL)
422 _dbus_timeout_unref (pending->timeout);
423
424 if (pending->timeout_link)
425 {
426 dbus_message_unref ((DBusMessage *)pending->timeout_link->data);
427 _dbus_list_free_link (pending->timeout_link);
428 pending->timeout_link = NULL;
429 }
430
431 if (pending->reply)
432 {
433 dbus_message_unref (pending->reply);
434 pending->reply = NULL;
435 }
436
437 dbus_free (pending);
438
439 dbus_pending_call_free_data_slot (&notify_user_data_slot);
440
441 /* connection lock should not be held. */
442 /* Free the connection last to avoid a weird state while
443 * calling out to application code where the pending exists
444 * but not the connection.
445 */
446 dbus_connection_unref (connection);
447 }
448
456 void
457 _dbus_pending_call_unref_and_unlock (DBusPendingCall *pending)
458 {
459 dbus_int32_t old_refcount;
460
461 old_refcount = _dbus_atomic_dec (&pending->refcount);
462 _dbus_assert (old_refcount > 0);
463 _dbus_pending_call_trace_ref (pending, old_refcount,
464 old_refcount - 1, "unref_and_unlock");
465
466 CONNECTION_UNLOCK (pending->connection);
467
468 if (old_refcount == 1)
469 _dbus_pending_call_last_unref (pending);
470 }
471
479 dbus_bool_t
480 _dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending)
481 {
482 return pending->completed;
483 }
484
485 static DBusDataSlotAllocator slot_allocator =
486 _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (pending_call_slots));
487
501 dbus_bool_t
502 _dbus_pending_call_set_data_unlocked (DBusPendingCall *pending,
503 dbus_int32_t slot,
504 void *data,
505 DBusFreeFunction free_data_func)
506 {
507 DBusFreeFunction old_free_func;
508 void *old_data;
509 dbus_bool_t retval;
510
511 retval = _dbus_data_slot_list_set (&slot_allocator,
512 &pending->slot_list,
513 slot, data, free_data_func,
514 &old_free_func, &old_data);
515
516 /* Drop locks to call out to app code */
517 CONNECTION_UNLOCK (pending->connection);
518
519 if (retval)
520 {
521 if (old_free_func)
522 (* old_free_func) (old_data);
523 }
524
525 CONNECTION_LOCK (pending->connection);
526
527 return retval;
528 }
529
576 DBusPendingCall *
577 dbus_pending_call_ref (DBusPendingCall *pending)
578 {
579 dbus_int32_t old_refcount;
580
581 _dbus_return_val_if_fail (pending != NULL, NULL);
582
583 old_refcount = _dbus_atomic_inc (&pending->refcount);
584 _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount + 1,
585 "ref");
586
587 return pending;
588 }
589
596 void
597 dbus_pending_call_unref (DBusPendingCall *pending)
598 {
599 dbus_int32_t old_refcount;
600
601 _dbus_return_if_fail (pending != NULL);
602
603 old_refcount = _dbus_atomic_dec (&pending->refcount);
604 _dbus_pending_call_trace_ref (pending, old_refcount, old_refcount - 1,
605 "unref");
606
607 if (old_refcount == 1)
608 _dbus_pending_call_last_unref(pending);
609 }
610
621 dbus_bool_t
622 dbus_pending_call_set_notify (DBusPendingCall *pending,
623 DBusPendingCallNotifyFunction function,
624 void *user_data,
625 DBusFreeFunction free_user_data)
626 {
627 dbus_bool_t ret = FALSE;
628
629 _dbus_return_val_if_fail (pending != NULL, FALSE);
630
631 CONNECTION_LOCK (pending->connection);
632
633 /* could invoke application code! */
634 if (!_dbus_pending_call_set_data_unlocked (pending, notify_user_data_slot,
635 user_data, free_user_data))
636 goto out;
637
638 pending->function = function;
639 ret = TRUE;
640
641 out:
642 CONNECTION_UNLOCK (pending->connection);
643
644 return ret;
645 }
646
662 void
663 dbus_pending_call_cancel (DBusPendingCall *pending)
664 {
665 _dbus_return_if_fail (pending != NULL);
666
667 _dbus_connection_remove_pending_call (pending->connection,
668 pending);
669 }
670
678 dbus_bool_t
679 dbus_pending_call_get_completed (DBusPendingCall *pending)
680 {
681 dbus_bool_t completed;
682
683 _dbus_return_val_if_fail (pending != NULL, FALSE);
684
685 CONNECTION_LOCK (pending->connection);
686 completed = pending->completed;
687 CONNECTION_UNLOCK (pending->connection);
688
689 return completed;
690 }
691
701 DBusMessage*
702 dbus_pending_call_steal_reply (DBusPendingCall *pending)
703 {
704 DBusMessage *message;
705
706 _dbus_return_val_if_fail (pending != NULL, NULL);
707 _dbus_return_val_if_fail (pending->completed, NULL);
708 _dbus_return_val_if_fail (pending->reply != NULL, NULL);
709
710 CONNECTION_LOCK (pending->connection);
711
712 message = pending->reply;
713 pending->reply = NULL;
714
715 CONNECTION_UNLOCK (pending->connection);
716
717 _dbus_message_trace_ref (message, -1, -1, "dbus_pending_call_steal_reply");
718 return message;
719 }
720
736 void
737 dbus_pending_call_block (DBusPendingCall *pending)
738 {
739 _dbus_return_if_fail (pending != NULL);
740
741 _dbus_connection_block_pending_call (pending);
742 }
743
758 dbus_bool_t
759 dbus_pending_call_allocate_data_slot (dbus_int32_t *slot_p)
760 {
761 _dbus_return_val_if_fail (slot_p != NULL, FALSE);
762
763 return _dbus_data_slot_allocator_alloc (&slot_allocator,
764 slot_p);
765 }
766
778 void
779 dbus_pending_call_free_data_slot (dbus_int32_t *slot_p)
780 {
781 _dbus_return_if_fail (slot_p != NULL);
782 _dbus_return_if_fail (*slot_p >= 0);
783
784 _dbus_data_slot_allocator_free (&slot_allocator, slot_p);
785 }
786
800 dbus_bool_t
801 dbus_pending_call_set_data (DBusPendingCall *pending,
802 dbus_int32_t slot,
803 void *data,
804 DBusFreeFunction free_data_func)
805 {
806 dbus_bool_t retval;
807
808 _dbus_return_val_if_fail (pending != NULL, FALSE);
809 _dbus_return_val_if_fail (slot >= 0, FALSE);
810
811
812 CONNECTION_LOCK (pending->connection);
813 retval = _dbus_pending_call_set_data_unlocked (pending, slot, data, free_data_func);
814 CONNECTION_UNLOCK (pending->connection);
815 return retval;
816 }
817
826 void*
827 dbus_pending_call_get_data (DBusPendingCall *pending,
828 dbus_int32_t slot)
829 {
830 void *res;
831
832 _dbus_return_val_if_fail (pending != NULL, NULL);
833
834 CONNECTION_LOCK (pending->connection);
835 res = _dbus_data_slot_list_get (&slot_allocator,
836 &pending->slot_list,
837 slot);
838 CONNECTION_UNLOCK (pending->connection);
839
840 return res;
841 }
842
DBusAtomic
An atomic integer safe to increment or decrement from multiple threads.
Definition: dbus-sysdeps.h:279
_dbus_pending_call_complete
void _dbus_pending_call_complete(DBusPendingCall *pending)
Calls notifier function for the pending call and sets the call to completed.
Definition: dbus-pending-call.c:204
dbus_message_ref
DBusMessage * dbus_message_ref(DBusMessage *message)
Increments the reference count of a DBusMessage.
Definition: dbus-message.c:1694
_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:63
DBusTimeout
Internals of DBusTimeout.
Definition: dbus-timeout.c:40
NULL
#define NULL
A null pointer, defined appropriately for C or C++.
DBusFreeFunction
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
Definition: dbus-memory.h:64
_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_connection_unlocked
DBusConnection * _dbus_pending_call_get_connection_unlocked(DBusPendingCall *pending)
Gets the connection associated with this pending call.
Definition: dbus-pending-call.c:338
dbus_free
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition: dbus-memory.c:701
DBusPendingCallNotifyFunction
void(* DBusPendingCallNotifyFunction)(DBusPendingCall *pending, void *user_data)
Called when a pending call now has a reply available.
Definition: dbus-connection.h:162
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:702
_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:502
DBusPendingCall::slot_list
DBusDataSlotList slot_list
Data stored by allocated integer ID.
Definition: dbus-pending-call.c:66
_dbus_assert
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
Definition: dbus-internals.h:148
DBusList::data
void * data
Data stored at this element.
Definition: dbus-list.h:38
DBusPendingCall
Implementation details of DBusPendingCall - all fields are private.
Definition: dbus-pending-call.c:62
DBusConnection
Implementation details of DBusConnection.
Definition: dbus-connection.c:256
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_list_alloc_link
DBusList * _dbus_list_alloc_link(void *data)
Allocates a linked list node.
Definition: dbus-list.c:242
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_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:622
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:801
_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:480
_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:2379
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:827
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:779
DBusMessage
Internals of DBusMessage.
Definition: dbus-message-private.h:99
DBusPendingCall::timeout_added
unsigned int timeout_added
Have added the timeout.
Definition: dbus-pending-call.c:79
DBusPendingCall::connection
DBusConnection * connection
Connections we&#39;re associated with.
Definition: dbus-pending-call.c:70
_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:354
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:679
dbus_new0
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
Definition: dbus-memory.h:59
DBusPendingCall::timeout_link
DBusList * timeout_link
Preallocated timeout response.
Definition: dbus-pending-call.c:74
_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:248
dbus_bool_t
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:35
DBusPendingCall::timeout
DBusTimeout * timeout
Timeout.
Definition: dbus-pending-call.c:72
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:663
_dbus_atomic_inc
dbus_int32_t _dbus_atomic_inc(DBusAtomic *atomic)
Atomically increments an integer.
Definition: dbus-sysdeps-unix.c:2753
_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
_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:107
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
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:759
DBusPendingCall::function
DBusPendingCallNotifyFunction function
Notifier when reply arrives.
Definition: dbus-pending-call.c:68
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:1190
dbus_pending_call_ref
DBusPendingCall * dbus_pending_call_ref(DBusPendingCall *pending)
Increments the reference count on a pending call.
Definition: dbus-pending-call.c:577
_dbus_pending_call_get_reply_serial_unlocked
dbus_uint32_t _dbus_pending_call_get_reply_serial_unlocked(DBusPendingCall *pending)
Gets the reply&#39;s serial number.
Definition: dbus-pending-call.c:293
_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
CONNECTION_UNLOCK
#define CONNECTION_UNLOCK(connection)
shorter and more visible way to write _dbus_connection_unlock()
Definition: dbus-pending-call.c:57
TRUE
#define TRUE
Expands to "1".
_dbus_data_slot_list_init
void _dbus_data_slot_list_init(DBusDataSlotList *list)
Initializes a slot list.
Definition: dbus-dataslot.c:197
DBusDataSlotList
Data structure that stores the actual user data set at a given slot.
Definition: dbus-dataslot.h:69
_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_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:597
DBusDataSlotAllocator
An allocator that tracks a set of slot IDs.
Definition: dbus-dataslot.h:55
DBUS_TIMEOUT_INFINITE
#define DBUS_TIMEOUT_INFINITE
An integer constant representing an infinite timeout.
Definition: dbus-pending-call.h:41
_dbus_pending_call_queue_timeout_error_unlocked
void _dbus_pending_call_queue_timeout_error_unlocked(DBusPendingCall *pending, DBusConnection *connection)
If the pending call hasn&#39;t been timed out, add its timeout error reply to the connection&#39;s incoming m...
Definition: dbus-pending-call.c:228
dbus_pending_call_block
void dbus_pending_call_block(DBusPendingCall *pending)
Block until the pending call is completed.
Definition: dbus-pending-call.c:737
_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:109
_dbus_atomic_dec
dbus_int32_t _dbus_atomic_dec(DBusAtomic *atomic)
Atomically decrement an integer.
Definition: dbus-sysdeps-unix.c:2776
_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, by timing out the pending call.
Definition: dbus-pending-call.c:172
DBusList
A node in a linked list.
Definition: dbus-list.h:34
DBusPendingCall::completed
unsigned int completed
TRUE if completed.
Definition: dbus-pending-call.c:78
_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::reply_serial
dbus_uint32_t reply_serial
Expected serial of reply.
Definition: dbus-pending-call.c:76
FALSE
#define FALSE
Expands to "0".
dbus_message_get_type
int dbus_message_get_type(DBusMessage *message)
Gets the type of a message.
Definition: dbus-message.c:1749
_DBUS_LOCK_NAME
#define _DBUS_LOCK_NAME(name)
Expands to name of a global lock variable.
Definition: dbus-internals.h:367
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:2819
_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_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:394
_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
CONNECTION_LOCK
#define CONNECTION_LOCK(connection)
Internals of DBusPendingCall.
Definition: dbus-pending-call.c:53
_dbus_pending_call_get_timeout_unlocked
DBusTimeout * _dbus_pending_call_get_timeout_unlocked(DBusPendingCall *pending)
Retrives the timeout.
Definition: dbus-pending-call.c:279
_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
DBusPendingCall::refcount
DBusAtomic refcount
reference count
Definition: dbus-pending-call.c:64
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:1717
_dbus_pending_call_set_reply_serial_unlocked
void _dbus_pending_call_set_reply_serial_unlocked(DBusPendingCall *pending, dbus_uint32_t serial)
Sets the reply&#39;s serial number.
Definition: dbus-pending-call.c:307
_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:457
_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:263
_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:323
_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_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
DBusTimeoutHandler
dbus_bool_t(* DBusTimeoutHandler)(void *data)
function to run when the timeout is handled
Definition: dbus-timeout.h:41
DBusPendingCall::reply
DBusMessage * reply
Reply (after we&#39;ve received it)
Definition: dbus-pending-call.c:71
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:1497