mst api fix
authorChristian Grothoff <christian@grothoff.org>
Wed, 23 Jun 2010 08:59:34 +0000 (08:59 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 23 Jun 2010 08:59:34 +0000 (08:59 +0000)
src/include/gnunet_server_lib.h
src/transport/plugin_transport_http.c
src/util/server.c
src/util/server_mst.c

index c3d11eae1506a55381b3306ed57940d066206a97..6dd756a6126b0f063e2539f210f7a1d382c6c9b4 100644 (file)
@@ -529,7 +529,6 @@ typedef void (*GNUNET_SERVER_MessageTokenizerCallback) (void *cls,
  */
 struct GNUNET_SERVER_MessageStreamTokenizer *
 GNUNET_SERVER_mst_create (size_t maxbuf,
-                         void *client_identity,
                          GNUNET_SERVER_MessageTokenizerCallback cb,
                          void *cb_cls);
 
@@ -550,6 +549,7 @@ GNUNET_SERVER_mst_create (size_t maxbuf,
  */
 int
 GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
+                          void *client_identity,
                           const char *buf,
                           size_t size,
                           int purge,
index 70edfc132c7fb270266f9915909d9ed06fb4abe9..9c999727ac6c60c733f0d292e4353f6a7c944e3a 100644 (file)
@@ -509,7 +509,7 @@ accessHandlerCallback (void *cls,
       }
       */
       if (cs->msgtok==NULL)
-        cs->msgtok = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE, cs, &messageTokenizerCallback, cs);
+        cs->msgtok = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE, &messageTokenizerCallback, cs);
     }
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has new an incoming `%s' request from peer `%s'\n",method, GNUNET_i2s(&cs->partner));
   }
@@ -579,7 +579,7 @@ accessHandlerCallback (void *cls,
       if (cs->pending_inbound_msg->pos >= sizeof (struct GNUNET_MessageHeader))
       {
         cur_msg = (struct GNUNET_MessageHeader *) cs->pending_inbound_msg->buf;
-        res = GNUNET_SERVER_mst_receive(cs->msgtok,cs->pending_inbound_msg->buf,cs->pending_inbound_msg->pos, GNUNET_YES, GNUNET_NO);
+        res = GNUNET_SERVER_mst_receive(cs->msgtok, cs, cs->pending_inbound_msg->buf,cs->pending_inbound_msg->pos, GNUNET_YES, GNUNET_NO);
         if ((res != GNUNET_SYSERR) && (res != GNUNET_NO))
           send_error_to_client = GNUNET_NO;
       }
index 4fa296f4ac1536fc4046a0386874cdb7e353c288..940aad363cb23a81d1102ccb4d1523893a3e9d44 100644 (file)
@@ -675,7 +675,7 @@ process_mst (struct GNUNET_SERVER_Client *client,
 #if DEBUG_SERVER
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server processes additional messages instantly.\n");
 #endif
-      ret = GNUNET_SERVER_mst_receive (client->mst, NULL, 0, GNUNET_NO, GNUNET_YES);
+      ret = GNUNET_SERVER_mst_receive (client->mst, client, NULL, 0, GNUNET_NO, GNUNET_YES);
     }
 #if DEBUG_SERVER
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -743,7 +743,7 @@ process_incoming (void *cls,
 #endif
   GNUNET_SERVER_client_keep (client);
   client->last_activity = GNUNET_TIME_absolute_get ();
-  ret = GNUNET_SERVER_mst_receive (client->mst, buf, available, GNUNET_NO, GNUNET_YES);
+  ret = GNUNET_SERVER_mst_receive (client->mst, client, buf, available, GNUNET_NO, GNUNET_YES);
   process_mst (client, ret);
 }
 
@@ -844,7 +844,6 @@ GNUNET_SERVER_connect_socket (struct
   client = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Client));
   client->connection = connection;
   client->mst = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE,
-                                         client,
                                          &client_message_tokenizer_callback,
                                          server);
   client->reference_count = 1;
index bf9a3a0072cccc79fae5eb1bc86a7205522f941c..b124b80b6f62b6a431723ae868613ff7a6c8023c 100644 (file)
@@ -56,11 +56,6 @@ struct GNUNET_SERVER_MessageStreamTokenizer
    */
   void *cb_cls;
 
-  /**
-   * Client to pass to cb.
-   */
-  void *client_identity;
-
   /**
    * Size of the buffer (starting at 'hdr').
    */
@@ -90,15 +85,12 @@ struct GNUNET_SERVER_MessageStreamTokenizer
  *
  * @param maxbuf maximum message size to support (typically
  *    GNUNET_SERVER_MAX_MESSAGE_SIZE)
- * @param client_identity ID of client for which this is a buffer,
- *        can be NULL (will be passed back to 'cb')
  * @param cb function to call on completed messages
  * @param cb_cls closure for cb
  * @return handle to tokenizer
  */
 struct GNUNET_SERVER_MessageStreamTokenizer *
 GNUNET_SERVER_mst_create (size_t maxbuf,
-                         void *client_identity,
                          GNUNET_SERVER_MessageTokenizerCallback cb,
                          void *cb_cls)
 {
@@ -106,7 +98,6 @@ GNUNET_SERVER_mst_create (size_t maxbuf,
 
   ret = GNUNET_malloc (maxbuf + sizeof (struct GNUNET_SERVER_MessageStreamTokenizer));
   ret->maxbuf = maxbuf;
-  ret->client_identity = client_identity;
   ret->cb = cb;
   ret->cb_cls = cb_cls;
   return ret;
@@ -118,6 +109,7 @@ GNUNET_SERVER_mst_create (size_t maxbuf,
  * callback for all complete messages.
  *
  * @param mst tokenizer to use
+ * @param client_identity ID of client for which this is a buffer
  * @param buf input data to add
  * @param size number of bytes in buf
  * @param purge should any excess bytes in the buffer be discarded 
@@ -129,6 +121,7 @@ GNUNET_SERVER_mst_create (size_t maxbuf,
  */
 int
 GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
+                          void *client,
                           const char *buf,
                           size_t size,
                           int purge,
@@ -228,7 +221,7 @@ GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
        }
       if (one_shot == GNUNET_YES)
        one_shot = GNUNET_SYSERR;
-      mst->cb (mst->cb_cls, mst->client_identity, hdr);
+      mst->cb (mst->cb_cls, client, hdr);
       mst->off += want;
       if (mst->off == mst->pos)
        {
@@ -264,7 +257,7 @@ GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
            }
          if (one_shot == GNUNET_YES)
            one_shot = GNUNET_SYSERR;
-         mst->cb (mst->cb_cls, mst->client_identity, hdr);
+         mst->cb (mst->cb_cls, client, hdr);
          buf += want;
          size -= want;
        }