summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-02-10 23:47:55 +0000
committerHavoc Pennington <hp@redhat.com>2005-02-10 23:47:55 +0000
commitdf0c6408805341f1ac673430ce6e92f352a473e6 (patch)
treeec4c73c0d9dabea5c7680f3c9e9d13d7486580c3
parent83dd8129a0429a2647c3a989ec73c712feb6060c (diff)
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
-rw-r--r--ChangeLog9
-rw-r--r--dbus/dbus-connection-internal.h2
-rw-r--r--dbus/dbus-connection.c40
-rw-r--r--dbus/dbus-object-tree.c49
-rw-r--r--glib/dbus-gthread.c2
5 files changed, 70 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 993294a9..eff98edb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
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
diff --git a/dbus/dbus-connection-internal.h b/dbus/dbus-connection-internal.h
index 6800fefe..21dc415f 100644
--- a/dbus/dbus-connection-internal.h
+++ b/dbus/dbus-connection-internal.h
@@ -89,7 +89,7 @@ DBusMessage* _dbus_connection_block_for_reply (DBusConnection
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);
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index 9e60aa27..dfc5d44b 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -1540,11 +1540,12 @@ dbus_connection_free_preallocated_send (DBusConnection *connection,
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;
@@ -1620,9 +1621,9 @@ _dbus_connection_send_preallocated_and_unlock (DBusConnection *connection,
{
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);
@@ -1665,10 +1666,10 @@ dbus_connection_send_preallocated (DBusConnection *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;
@@ -1679,15 +1680,14 @@ _dbus_connection_send_unlocked (DBusConnection *connection,
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)
@@ -1867,7 +1867,7 @@ dbus_connection_send_with_reply (DBusConnection *connection,
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);
@@ -2821,8 +2821,8 @@ dbus_connection_dispatch (DBusConnection *connection)
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);
diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c
index da8d8c26..ae28cc1c 100644
--- a/dbus/dbus-object-tree.c
+++ b/dbus/dbus-object-tree.c
@@ -607,9 +607,9 @@ _dbus_object_tree_list_registered_unlocked (DBusObjectTree *tree,
}
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;
@@ -618,8 +618,11 @@ handle_default_introspect_unlocked (DBusObjectTree *tree,
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");
@@ -628,12 +631,26 @@ handle_default_introspect_unlocked (DBusObjectTree *tree,
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;
@@ -673,13 +690,21 @@ handle_default_introspect_unlocked (DBusObjectTree *tree,
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)
@@ -826,14 +851,16 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree,
{
/* 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)
{
diff --git a/glib/dbus-gthread.c b/glib/dbus-gthread.c
index f7b6fafb..1b925cdd 100644
--- a/glib/dbus-gthread.c
+++ b/glib/dbus-gthread.c
@@ -21,6 +21,8 @@
*
*/
+/* #define G_DEBUG_LOCKS 1 */
+
#include <glib.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>