[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27972 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27972 - gnunet/src/mesh |
Date: |
Sat, 13 Jul 2013 03:20:42 +0200 |
Author: bartpolot
Date: 2013-07-13 03:20:42 +0200 (Sat, 13 Jul 2013)
New Revision: 27972
Modified:
gnunet/src/mesh/gnunet-service-mesh.c
Log:
Add context to a client immediately after connection. Otherwise calling
SERVER_get_client_context on a client that never sent an initial message (and
didn't have a chance to receive something via SERVER_set_client_context) causes
an assertion failure in server.c:355. This happens when the client can connect
to the service on multiple protocols, one of the connections will be
immediately closed (see bug for ghost client disconnects)
Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c 2013-07-13 01:13:07 UTC (rev
27971)
+++ gnunet/src/mesh/gnunet-service-mesh.c 2013-07-13 01:20:42 UTC (rev
27972)
@@ -4395,6 +4395,24 @@
/**
+ * Handler for client connection.
+ *
+ * @param cls Closure (unused).
+ * @param client Client handler.
+ */
+static void
+handle_local_client_connect (void *cls, struct GNUNET_SERVER_Client *client)
+{
+ struct MeshClient *c;
+
+ c = GNUNET_malloc (sizeof (struct MeshClient));
+ c->handle = client;
+ GNUNET_SERVER_client_keep (client);
+ GNUNET_SERVER_client_set_user_context (client, c);
+}
+
+
+/**
* Handler for client disconnection
*
* @param cls closure
@@ -4476,14 +4494,11 @@
}
size /= sizeof (uint32_t);
- /* Create new client structure */
- c = GNUNET_malloc (sizeof (struct MeshClient));
+ /* Initialize new client structure */
+ c = GNUNET_SERVER_client_get_user_context (client, struct MeshClient);
c->id = next_client_id++; /* overflow not important: just for debug */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " client id %u\n", c->id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " client has %u ports\n", size);
- c->handle = client;
- GNUNET_SERVER_client_keep (client);
- GNUNET_SERVER_client_set_user_context (client, c);
if (size > 0)
{
uint32_t u32;
@@ -5113,6 +5128,8 @@
server_init (void)
{
GNUNET_SERVER_add_handlers (server_handle, client_handlers);
+ GNUNET_SERVER_connect_notify (server_handle,
+ &handle_local_client_connect, NULL);
GNUNET_SERVER_disconnect_notify (server_handle,
&handle_local_client_disconnect, NULL);
nc = GNUNET_SERVER_notification_context_create (server_handle, 1);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27972 - gnunet/src/mesh,
gnunet <=