2005-02-10 Havoc Pennington <hp@redhat.com>
+ * dbus/dbus-object-tree.c (handle_default_introspect_and_unlock):
+ change to be _and_unlock instead of _unlocked
+
+ * dbus/dbus-connection.c
+ (_dbus_connection_send_preallocated_unlocked_no_update): rename to
+ have no_update so we can find this bug quickly in future
+
+2005-02-10 Havoc Pennington <hp@redhat.com>
+
* dbus/dbus-message-util.c (verify_test_message): tests for string
array
int timeout_milliseconds);
void _dbus_pending_call_complete_and_unlock (DBusPendingCall *pending,
DBusMessage *message);
-dbus_bool_t _dbus_connection_send_unlocked (DBusConnection *connection,
+dbus_bool_t _dbus_connection_send_and_unlock (DBusConnection *connection,
DBusMessage *message,
dbus_uint32_t *client_serial);
dbus_free (preallocated);
}
+/* Called with lock held, does not update dispatch status */
static void
-_dbus_connection_send_preallocated_unlocked (DBusConnection *connection,
- DBusPreallocatedSend *preallocated,
- DBusMessage *message,
- dbus_uint32_t *client_serial)
+_dbus_connection_send_preallocated_unlocked_no_update (DBusConnection *connection,
+ DBusPreallocatedSend *preallocated,
+ DBusMessage *message,
+ dbus_uint32_t *client_serial)
{
dbus_uint32_t serial;
const char *sig;
{
DBusDispatchStatus status;
- _dbus_connection_send_preallocated_unlocked (connection,
- preallocated,
- message, client_serial);
+ _dbus_connection_send_preallocated_unlocked_no_update (connection,
+ preallocated,
+ message, client_serial);
status = _dbus_connection_get_dispatch_status_unlocked (connection);
message, client_serial);
}
-dbus_bool_t
-_dbus_connection_send_unlocked (DBusConnection *connection,
- DBusMessage *message,
- dbus_uint32_t *client_serial)
+static dbus_bool_t
+_dbus_connection_send_unlocked_no_update (DBusConnection *connection,
+ DBusMessage *message,
+ dbus_uint32_t *client_serial)
{
DBusPreallocatedSend *preallocated;
if (preallocated == NULL)
return FALSE;
-
- _dbus_connection_send_preallocated_unlocked (connection,
- preallocated,
- message,
- client_serial);
+ _dbus_connection_send_preallocated_unlocked_no_update (connection,
+ preallocated,
+ message,
+ client_serial);
return TRUE;
}
-static dbus_bool_t
+dbus_bool_t
_dbus_connection_send_and_unlock (DBusConnection *connection,
DBusMessage *message,
dbus_uint32_t *client_serial)
pending))
goto error;
- if (!_dbus_connection_send_unlocked (connection, message, NULL))
+ if (!_dbus_connection_send_unlocked_no_update (connection, message, NULL))
{
_dbus_connection_detach_pending_call_and_unlock (connection,
pending);
goto out;
}
- _dbus_connection_send_preallocated_unlocked (connection, preallocated,
- reply, NULL);
+ _dbus_connection_send_preallocated_unlocked_no_update (connection, preallocated,
+ reply, NULL);
dbus_message_unref (reply);
}
static DBusHandlerResult
-handle_default_introspect_unlocked (DBusObjectTree *tree,
- DBusMessage *message,
- const char **path)
+handle_default_introspect_and_unlock (DBusObjectTree *tree,
+ DBusMessage *message,
+ const char **path)
{
DBusString xml;
DBusHandlerResult result;
DBusMessage *reply;
DBusMessageIter iter;
const char *v_STRING;
+ dbus_bool_t already_unlocked;
/* We have the connection lock here */
+
+ already_unlocked = FALSE;
_dbus_verbose (" considering default Introspect() handler...\n");
if (!dbus_message_is_method_call (message,
DBUS_INTERFACE_ORG_FREEDESKTOP_INTROSPECTABLE,
"Introspect"))
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ {
+#ifdef DBUS_BUILD_TESTS
+ if (tree->connection)
+#endif
+ _dbus_connection_unlock (tree->connection);
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
_dbus_verbose (" using default Introspect() handler!\n");
if (!_dbus_string_init (&xml))
- return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ {
+#ifdef DBUS_BUILD_TESTS
+ if (tree->connection)
+#endif
+ _dbus_connection_unlock (tree->connection);
+
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ }
result = DBUS_HANDLER_RESULT_NEED_MEMORY;
if (tree->connection)
#endif
{
- if (!_dbus_connection_send_unlocked (tree->connection, reply, NULL))
+ if (!_dbus_connection_send_and_unlock (tree->connection, reply, NULL))
goto out;
}
result = DBUS_HANDLER_RESULT_HANDLED;
out:
+#ifdef DBUS_BUILD_TESTS
+ if (tree->connection)
+#endif
+ {
+ if (!already_unlocked)
+ _dbus_connection_unlock (tree->connection);
+ }
+
_dbus_string_free (&xml);
dbus_free_string_array (children);
if (reply)
{
/* This hardcoded default handler does a minimal Introspect()
*/
- result = handle_default_introspect_unlocked (tree, message,
- (const char**) path);
+ result = handle_default_introspect_and_unlock (tree, message,
+ (const char**) path);
}
-
+ else
+ {
#ifdef DBUS_BUILD_TESTS
- if (tree->connection)
+ if (tree->connection)
#endif
- _dbus_connection_unlock (tree->connection);
+ _dbus_connection_unlock (tree->connection);
+ }
while (list != NULL)
{
*
*/
+/* #define G_DEBUG_LOCKS 1 */
+
#include <glib.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>