cleaner
authorChristian Grothoff <christian@grothoff.org>
Mon, 10 Oct 2011 11:54:09 +0000 (11:54 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 10 Oct 2011 11:54:09 +0000 (11:54 +0000)
src/core/gnunet-service-core.h
src/core/gnunet-service-core_clients.c

index 10d2cd534e48bac139dda15ce52933f341c8b15d..2d5156efec14a24916a7635f54997ef4675f794f 100644 (file)
@@ -82,11 +82,6 @@ struct GSC_ClientActiveRequest
    */
   int was_solicited;
 
-  /**
-   * Is corking allowed (set only once we have the real message).
-   */
-  int cork;
-
   /**
    * How many bytes does the client intend to send?
    */
index f30a3ba4babaea5a6561c92cb59b317e68747187..c9eb587b550c6e48622c37a9e5d6cfed28c8ddb8 100644 (file)
@@ -350,6 +350,25 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
 }
 
 
+/**
+ * Closure for the 'client_tokenizer_callback'.
+ */
+struct TokenizerContext
+{
+
+  /**
+   * Active request handle for the message.
+   */ 
+  struct GSC_ClientActiveRequest *car;
+
+  /**
+   * Is corking allowed (set only once we have the real message).
+   */
+  int cork;
+
+};
+
+
 /**
  * Handle CORE_SEND request.
  *
@@ -363,7 +382,7 @@ handle_client_send (void *cls, struct GNUNET_SERVER_Client *client,
 {
   const struct SendMessage *sm;
   struct GSC_Client *c;
-  struct GSC_ClientActiveRequest *car;
+  struct TokenizerContext tc;
   uint16_t msize;
 
   msize = ntohs (message->size);
@@ -385,8 +404,8 @@ handle_client_send (void *cls, struct GNUNET_SERVER_Client *client,
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
-  car = GNUNET_CONTAINER_multihashmap_get (c->requests, &sm->peer.hashPubKey);
-  if (NULL == car)
+  tc.car = GNUNET_CONTAINER_multihashmap_get (c->requests, &sm->peer.hashPubKey);
+  if (NULL == tc.car)
   {
     /* client did not request transmission first! */
     GNUNET_break (0);
@@ -396,17 +415,17 @@ handle_client_send (void *cls, struct GNUNET_SERVER_Client *client,
   GNUNET_assert (GNUNET_YES ==
                 GNUNET_CONTAINER_multihashmap_remove (c->requests, 
                                                       &sm->peer.hashPubKey,
-                                                      car));
-  car->cork = ntohl (sm->cork);
+                                                      tc.car));
+  tc.cork = ntohl (sm->cork);
   GNUNET_SERVER_mst_receive (client_mst,
-                            car
+                            &tc
                             (const char*) &sm[1], msize,
                             GNUNET_YES,
                             GNUNET_NO);
   if (0 !=
-      memcmp (&car->target, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))  
-    GSC_SESSIONS_dequeue_request (car);
-  GNUNET_free (car);  
+      memcmp (&tc.car->target, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))  
+    GSC_SESSIONS_dequeue_request (tc.car);
+  GNUNET_free (tc.car);  
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
@@ -425,7 +444,8 @@ static void
 client_tokenizer_callback (void *cls, void *client,
                           const struct GNUNET_MessageHeader *message)
 {
-  struct GSC_ClientActiveRequest *car = client;
+  struct TokenizerContext *tc = cls;
+  struct GSC_ClientActiveRequest *car = tc->car;
 
   if (0 ==
       memcmp (&car->target, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))  
@@ -442,7 +462,7 @@ client_tokenizer_callback (void *cls, void *client,
                                 GNUNET_CORE_OPTION_SEND_HDR_INBOUND | GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND);  
   }
   else
-    GSC_SESSIONS_transmit (car, message, car->cork);
+    GSC_SESSIONS_transmit (car, message, tc->cork);
 }