summaryrefslogtreecommitdiffstats
path: root/bus/test.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-06-22 19:39:47 +0000
committerHavoc Pennington <hp@redhat.com>2003-06-22 19:39:47 +0000
commit6843ad31769c088ca259020fd9ea8dfb3a51f68e (patch)
tree208e287bc200298da5514f4d32704f3e8ef42423 /bus/test.c
parent8a71cf33ef8f35669dbdb39ef2f12c5a3dfebf33 (diff)
2003-06-22 Havoc Pennington <hp@pobox.com>
* dbus/dbus-dataslot.c (_dbus_data_slot_allocator_unref) (_dbus_data_slot_allocator_alloc): rework these to keep a reference count on each slot and automatically manage a global slot ID variable passed in by address * bus/bus.c: convert to new dataslot API * dbus/dbus-bus.c: convert to new dataslot API * dbus/dbus-connection.c: convert to new dataslot API * dbus/dbus-server.c: convert to new dataslot API * glib/dbus-gmain.c: ditto * bus/test.c: ditto * bus/connection.c: ditto
Diffstat (limited to 'bus/test.c')
-rw-r--r--bus/test.c42
1 files changed, 4 insertions, 38 deletions
diff --git a/bus/test.c b/bus/test.c
index f8d4c5f3..30cbcd05 100644
--- a/bus/test.c
+++ b/bus/test.c
@@ -123,41 +123,7 @@ client_disconnect_handler (DBusMessageHandler *handler,
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
-static int handler_slot = -1;
-static int handler_slot_refcount = 0;
-
-static dbus_bool_t
-handler_slot_ref (void)
-{
- if (handler_slot < 0)
- {
- handler_slot = dbus_connection_allocate_data_slot ();
-
- if (handler_slot < 0)
- return FALSE;
-
- _dbus_assert (handler_slot_refcount == 0);
- }
-
- handler_slot_refcount += 1;
-
- return TRUE;
-
-}
-
-static void
-handler_slot_unref (void)
-{
- _dbus_assert (handler_slot_refcount > 0);
-
- handler_slot_refcount -= 1;
-
- if (handler_slot_refcount == 0)
- {
- dbus_connection_free_data_slot (handler_slot);
- handler_slot = -1;
- }
-}
+static dbus_int32_t handler_slot = -1;
static void
free_handler (void *data)
@@ -165,7 +131,7 @@ free_handler (void *data)
DBusMessageHandler *handler = data;
dbus_message_handler_unref (handler);
- handler_slot_unref ();
+ dbus_connection_free_data_slot (&handler_slot);
}
dbus_bool_t
@@ -217,7 +183,7 @@ bus_setup_debug_client (DBusConnection *connection)
if (!_dbus_list_append (&clients, connection))
goto out;
- if (!handler_slot_ref ())
+ if (!dbus_connection_allocate_data_slot (&handler_slot))
goto out;
/* Set up handler to be destroyed */
@@ -225,7 +191,7 @@ bus_setup_debug_client (DBusConnection *connection)
disconnect_handler,
free_handler))
{
- handler_slot_unref ();
+ dbus_connection_free_data_slot (&handler_slot);
goto out;
}