[phodav] spice: use int64 keys for clients
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [phodav] spice: use int64 keys for clients
- Date: Wed, 5 Feb 2014 11:21:53 +0000 (UTC)
commit 74654f6b6ae873a340e9dd07595ea14eb7af91a1
Author: Marc-André Lureau <marcandre lureau gmail com>
Date: Tue Feb 4 17:20:34 2014 +0100
spice: use int64 keys for clients
GINT_TO_POINTER(GPOINTER_TO_INT(x)) can be != x
spice/spice-webdavd.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/spice/spice-webdavd.c b/spice/spice-webdavd.c
index 5a2f57e..e7f82ff 100644
--- a/spice/spice-webdavd.c
+++ b/spice/spice-webdavd.c
@@ -228,11 +228,13 @@ add_client (GSocketConnection *client_connection)
client = g_new0 (Client, 1);
client->client_connection = g_object_ref (client_connection);
+ // TODO: check if usage of this idiom is portable, or if we need to check collisions
client->id = GPOINTER_TO_INT (client_connection);
client->queue = output_queue_new (bostream);
g_object_unref (bostream);
- g_hash_table_insert (clients, g_object_ref (client_connection), client);
+ g_hash_table_insert (clients, &client->id, client);
+ g_warn_if_fail (g_hash_table_lookup (clients, &client->id));
return client;
}
@@ -359,7 +361,9 @@ mux_data_read_cb (GObject *source_object,
return;
}
- Client *c = g_hash_table_lookup (clients, GINT_TO_POINTER (demux.client));
+ g_debug ("looking up client %" G_GINT64_FORMAT, demux.client);
+ Client *c = g_hash_table_lookup (clients, &demux.client);
+ g_warn_if_fail(c != NULL);
if (c)
output_queue_push (c->queue, (guint8 *) demux.buf, demux.size,
@@ -689,8 +693,8 @@ main (int argc, char *argv[])
"incoming", G_CALLBACK (incoming_callback),
NULL);
- clients = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- g_object_unref, (GDestroyNotify) client_free);
+ clients = g_hash_table_new_full (g_int64_hash, g_int64_equal,
+ NULL, (GDestroyNotify) client_free);
#ifdef G_OS_UNIX
open_mux_path ("/dev/virtio-ports/org.spice-space.webdav.0");
#else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]