dbus_message_finalize (message);
}
+#ifndef DBUS_DISABLE_CHECKS
+static dbus_bool_t
+_dbus_message_iter_check (DBusMessageRealIter *iter)
+{
+ if (iter == NULL)
+ {
+ _dbus_warn_check_failed ("dbus message iterator is NULL\n");
+ return FALSE;
+ }
+
+ if (iter->iter_type == DBUS_MESSAGE_ITER_TYPE_READER)
+ {
+ if (iter->u.reader.byte_order != iter->message->byte_order)
+ {
+ _dbus_warn_check_failed ("dbus message changed byte order since iterator was created\n");
+ return FALSE;
+ }
+ /* because we swap the message into compiler order when you init an iter */
+ _dbus_assert (iter->u.reader.byte_order == DBUS_COMPILER_BYTE_ORDER);
+ }
+ else if (iter->iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER)
+ {
+ if (iter->u.writer.byte_order != iter->message->byte_order)
+ {
+ _dbus_warn_check_failed ("dbus message changed byte order since append iterator was created\n");
+ return FALSE;
+ }
+ /* because we swap the message into compiler order when you init an iter */
+ _dbus_assert (iter->u.writer.byte_order == DBUS_COMPILER_BYTE_ORDER);
+ }
+ else
+ {
+ _dbus_warn_check_failed ("dbus message iterator looks uninitialized or corrupted\n");
+ return FALSE;
+ }
+
+ if (iter->changed_stamp != iter->message->changed_stamp)
+ {
+ _dbus_warn_check_failed ("dbus message iterator invalid because the message has been modified (or perhaps the iterator is just uninitialized)\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+#endif /* DBUS_DISABLE_CHECKS */
+
/**
* Implementation of the varargs arg-getting functions.
* dbus_message_get_args() is the place to go for complete
return _dbus_type_reader_get_current_type (&real->u.reader) != DBUS_TYPE_INVALID;
}
-#ifndef DBUS_DISABLE_CHECKS
-static dbus_bool_t
-_dbus_message_iter_check (DBusMessageRealIter *iter)
-{
- if (iter == NULL)
- {
- _dbus_warn_check_failed ("dbus message iterator is NULL\n");
- return FALSE;
- }
-
- if (iter->iter_type == DBUS_MESSAGE_ITER_TYPE_READER)
- {
- if (iter->u.reader.byte_order != iter->message->byte_order)
- {
- _dbus_warn_check_failed ("dbus message changed byte order since iterator was created\n");
- return FALSE;
- }
- /* because we swap the message into compiler order when you init an iter */
- _dbus_assert (iter->u.reader.byte_order == DBUS_COMPILER_BYTE_ORDER);
- }
- else if (iter->iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER)
- {
- if (iter->u.writer.byte_order != iter->message->byte_order)
- {
- _dbus_warn_check_failed ("dbus message changed byte order since append iterator was created\n");
- return FALSE;
- }
- /* because we swap the message into compiler order when you init an iter */
- _dbus_assert (iter->u.writer.byte_order == DBUS_COMPILER_BYTE_ORDER);
- }
- else
- {
- _dbus_warn_check_failed ("dbus message iterator looks uninitialized or corrupted\n");
- return FALSE;
- }
-
- if (iter->changed_stamp != iter->message->changed_stamp)
- {
- _dbus_warn_check_failed ("dbus message iterator invalid because the message has been modified (or perhaps the iterator is just uninitialized)\n");
- return FALSE;
- }
-
- return TRUE;
-}
-#endif /* DBUS_DISABLE_CHECKS */
-
/**
* Checks if an iterator has any more fields.
*
return TRUE;
}
-/** @} */
-
-/**
- * @defgroup DBusPendingCall DBusPendingCall
- * @ingroup DBus
- * @brief Pending reply to a method call message
- *
- * A DBusPendingCall is an object representing an
- * expected reply. A #DBusPendingCall can be created
- * when you send a message that should have a reply.
- *
- * @{
- */
-
-/**
- * @typedef DBusPendingCall
- *
- * Opaque data type representing a message pending.
- */
-
/**
* Increments the reference count on a pending call,
* while the lock on its connection is already held.
return pending;
}
-/**
- * Increments the reference count on a pending call.
- *
- * @param pending the pending call object
- * @returns the pending call object
- */
-DBusPendingCall *
-dbus_pending_call_ref (DBusPendingCall *pending)
-{
- _dbus_return_val_if_fail (pending != NULL, NULL);
-
- /* The connection lock is better than the global
- * lock in the atomic increment fallback
- */
-#ifdef DBUS_HAVE_ATOMIC_INT
- _dbus_atomic_inc (&pending->refcount);
-#else
- CONNECTION_LOCK (pending->connection);
- _dbus_assert (pending->refcount.value > 0);
-
- pending->refcount.value += 1;
- CONNECTION_UNLOCK (pending->connection);
-#endif
-
- return pending;
-}
static void
_dbus_pending_call_last_unref (DBusPendingCall *pending)
_dbus_pending_call_last_unref (pending);
}
+/**
+ * Checks whether the pending call has received a reply
+ * yet, or not. Assumes connection lock is held.
+ *
+ * @param pending the pending call
+ * @returns #TRUE if a reply has been received
+ */
+dbus_bool_t
+_dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending)
+{
+ return pending->completed;
+}
+
+static DBusDataSlotAllocator slot_allocator;
+_DBUS_DEFINE_GLOBAL_LOCK (pending_call_slots);
+
+/**
+ * Stores a pointer on a #DBusPendingCall, along
+ * with an optional function to be used for freeing
+ * the data when the data is set again, or when
+ * the pending call is finalized. The slot number
+ * must have been allocated with dbus_pending_call_allocate_data_slot().
+ *
+ * @param pending the pending_call
+ * @param slot the slot number
+ * @param data the data to store
+ * @param free_data_func finalizer function for the data
+ * @returns #TRUE if there was enough memory to store the data
+ */
+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;
+}
+
+/** @} */
+
+/**
+ * @defgroup DBusPendingCall DBusPendingCall
+ * @ingroup DBus
+ * @brief Pending reply to a method call message
+ *
+ * A DBusPendingCall is an object representing an
+ * expected reply. A #DBusPendingCall can be created
+ * when you send a message that should have a reply.
+ *
+ * @{
+ */
+
+/**
+ * @typedef DBusPendingCall
+ *
+ * Opaque data type representing a message pending.
+ */
+
+/**
+ * Increments the reference count on a pending call.
+ *
+ * @param pending the pending call object
+ * @returns the pending call object
+ */
+DBusPendingCall *
+dbus_pending_call_ref (DBusPendingCall *pending)
+{
+ _dbus_return_val_if_fail (pending != NULL, NULL);
+
+ /* The connection lock is better than the global
+ * lock in the atomic increment fallback
+ */
+#ifdef DBUS_HAVE_ATOMIC_INT
+ _dbus_atomic_inc (&pending->refcount);
+#else
+ CONNECTION_LOCK (pending->connection);
+ _dbus_assert (pending->refcount.value > 0);
+
+ pending->refcount.value += 1;
+ CONNECTION_UNLOCK (pending->connection);
+#endif
+
+ return pending;
+}
+
/**
* Decrements the reference count on a pending call,
* freeing it if the count reaches 0.
pending);
}
-/**
- * Checks whether the pending call has received a reply
- * yet, or not. Assumes connection lock is held.
- *
- * @param pending the pending call
- * @returns #TRUE if a reply has been received
- */
-dbus_bool_t
-_dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending)
-{
- return pending->completed;
-}
-
/**
* Checks whether the pending call has received a reply
* yet, or not.
_dbus_connection_block_pending_call (pending);
}
-static DBusDataSlotAllocator slot_allocator;
-_DBUS_DEFINE_GLOBAL_LOCK (pending_call_slots);
-
/**
* Allocates an integer ID to be used for storing application-specific
* data on any DBusPendingCall. The allocated ID may then be used
_dbus_data_slot_allocator_free (&slot_allocator, slot_p);
}
-/**
- * Stores a pointer on a #DBusPendingCall, along
- * with an optional function to be used for freeing
- * the data when the data is set again, or when
- * the pending call is finalized. The slot number
- * must have been allocated with dbus_pending_call_allocate_data_slot().
- *
- * @param pending the pending_call
- * @param slot the slot number
- * @param data the data to store
- * @param free_data_func finalizer function for the data
- * @returns #TRUE if there was enough memory to store the data
- */
-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;
-}
-
/**
* Stores a pointer on a #DBusPendingCall, along
* with an optional function to be used for freeing
enabled);
}
+
+/**
+ * Like dbus_server_ref() but does not acquire the lock (must already be held)
+ *
+ * @param server the server.
+ */
+void
+_dbus_server_ref_unlocked (DBusServer *server)
+{
+ _dbus_assert (server != NULL);
+ _dbus_assert (server->refcount.value > 0);
+
+ HAVE_LOCK_CHECK (server);
+
+#ifdef DBUS_HAVE_ATOMIC_INT
+ _dbus_atomic_inc (&server->refcount);
+#else
+ _dbus_assert (server->refcount.value > 0);
+
+ server->refcount.value += 1;
+#endif
+}
+
+/**
+ * Like dbus_server_unref() but does not acquire the lock (must already be held)
+ *
+ * @param server the server.
+ */
+void
+_dbus_server_unref_unlocked (DBusServer *server)
+{
+ dbus_bool_t last_unref;
+
+ /* Keep this in sync with dbus_server_unref */
+
+ _dbus_assert (server != NULL);
+ _dbus_assert (server->refcount.value > 0);
+
+ HAVE_LOCK_CHECK (server);
+
+#ifdef DBUS_HAVE_ATOMIC_INT
+ last_unref = (_dbus_atomic_dec (&server->refcount) == 1);
+#else
+ _dbus_assert (server->refcount.value > 0);
+
+ server->refcount.value -= 1;
+ last_unref = (server->refcount.value == 0);
+#endif
+
+ if (last_unref)
+ {
+ _dbus_assert (server->disconnected);
+
+ SERVER_UNLOCK (server);
+
+ _dbus_assert (server->vtable->finalize != NULL);
+
+ (* server->vtable->finalize) (server);
+ }
+}
+
/** @} */
/**
dbus_server_unref (DBusServer *server)
{
dbus_bool_t last_unref;
+
+ /* keep this in sync with unref_unlocked */
_dbus_return_if_fail (server != NULL);
_dbus_return_if_fail (server->refcount.value > 0);
}
}
-/**
- * Like dbus_server_ref() but does not acquire the lock (must already be held)
- *
- * @param server the server.
- */
-void
-_dbus_server_ref_unlocked (DBusServer *server)
-{
- _dbus_assert (server != NULL);
- _dbus_assert (server->refcount.value > 0);
-
- HAVE_LOCK_CHECK (server);
-
-#ifdef DBUS_HAVE_ATOMIC_INT
- _dbus_atomic_inc (&server->refcount);
-#else
- _dbus_assert (server->refcount.value > 0);
-
- server->refcount.value += 1;
-#endif
-}
-
-/**
- * Like dbus_server_unref() but does not acquire the lock (must already be held)
- *
- * @param server the server.
- */
-void
-_dbus_server_unref_unlocked (DBusServer *server)
-{
- dbus_bool_t last_unref;
-
- _dbus_assert (server != NULL);
- _dbus_assert (server->refcount.value > 0);
-
- HAVE_LOCK_CHECK (server);
-
-#ifdef DBUS_HAVE_ATOMIC_INT
- last_unref = (_dbus_atomic_dec (&server->refcount) == 1);
-#else
- _dbus_assert (server->refcount.value > 0);
-
- server->refcount.value -= 1;
- last_unref = (server->refcount.value == 0);
-#endif
-
- if (last_unref)
- {
- _dbus_assert (server->disconnected);
-
- SERVER_UNLOCK (server);
-
- _dbus_assert (server->vtable->finalize != NULL);
-
- (* server->vtable->finalize) (server);
- }
-}
-
/**
* Releases the server's address and stops listening for
* new clients. If called more than once, only the first