* Tail of linked list of all clients to this service.
*/
static struct PerformanceClient *pc_tail;
+
+
+static struct PerformanceClient *
+find_client (struct GNUNET_SERVER_Client *client)
+{
+ struct PerformanceClient * pc;
+
+ for (pc = pc_head; pc != NULL; pc = pc->next)
+ if (pc->client == client)
+ return pc;
+ return NULL;
+}
void
{
struct PerformanceClient * pc;
+ GNUNET_break (NULL == find_client (client));
pc = GNUNET_malloc (sizeof (struct PerformanceClient));
pc->client = client;
GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, pc);
void
GAS_remove_performance_client (struct GNUNET_SERVER_Client *client)
{
+ struct PerformanceClient * pc;
+
+ pc = find_client (client);
+ if (NULL == pc)
+ return;
+ GNUNET_CONTAINER_DLL_remove (pc_head, pc_tail, pc);
+ GNUNET_SERVER_client_drop (client);
+ GNUNET_free (pc);
}
/**
* Head of linked list of all clients to this service.
*/
-static struct SchedulingClient *ac_head;
+static struct SchedulingClient *sc_head;
/**
* Tail of linked list of all clients to this service.
*/
-static struct SchedulingClient *ac_tail;
+static struct SchedulingClient *sc_tail;
+
+
+static struct SchedulingClient *
+find_client (struct GNUNET_SERVER_Client *client)
+{
+ struct SchedulingClient * sc;
+
+ for (sc = sc_head; sc != NULL; sc = sc->next)
+ if (sc->client == client)
+ return sc;
+ return NULL;
+}
void
GAS_add_scheduling_client (struct GNUNET_SERVER_Client *client)
{
- struct SchedulingClient *ac;
+ struct SchedulingClient *sc;
- ac = GNUNET_malloc (sizeof (struct SchedulingClient));
- ac->client = client;
+ GNUNET_break (NULL == find_client (client));
+ sc = GNUNET_malloc (sizeof (struct SchedulingClient));
+ sc->client = client;
GNUNET_SERVER_client_keep (client);
- GNUNET_CONTAINER_DLL_insert(ac_head, ac_tail, ac);
+ GNUNET_CONTAINER_DLL_insert(sc_head, sc_tail, sc);
}
void
GAS_remove_scheduling_client (struct GNUNET_SERVER_Client *client)
{
+ struct SchedulingClient * sc;
+
+ sc = find_client (client);
+ if (NULL == sc)
+ return;
+ GNUNET_CONTAINER_DLL_remove (sc_head, sc_tail, sc);
+ GNUNET_SERVER_client_drop (client);
+ GNUNET_free (sc);
}