static struct MeshClient *
client_get (struct GNUNET_SERVER_Client *client)
{
- struct MeshClient *c;
-
- c = clients_head;
- while (NULL != c)
- {
- if (c->handle == client)
- return c;
- c = c->next;
- }
- return NULL;
+ return GNUNET_SERVER_client_get_user_context (client, struct MeshClient);
}
return;
}
- c = clients_head;
- while (NULL != c)
+ c = client_get (client);
+ if (NULL != c)
{
- if (c->handle != client)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- " ... searching %p (%u)\n",
- c->handle, c->id);
- c = c->next;
- continue;
- }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "matching client found (%u)\n",
c->id);
GNUNET_SERVER_client_drop (c->handle);
GNUNET_STATISTICS_update (stats, "# clients", -1, GNUNET_NO);
c = next;
}
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " context NULL!\n");
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "done!\n");
return;
}
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;