From 45e99c8ffe2b2f86caf02b1cc5cefca280fd3b53 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 23 Jun 2010 08:59:34 +0000 Subject: [PATCH] mst api fix --- src/include/gnunet_server_lib.h | 2 +- src/transport/plugin_transport_http.c | 4 ++-- src/util/server.c | 5 ++--- src/util/server_mst.c | 15 ++++----------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/include/gnunet_server_lib.h b/src/include/gnunet_server_lib.h index c3d11eae1..6dd756a61 100644 --- a/src/include/gnunet_server_lib.h +++ b/src/include/gnunet_server_lib.h @@ -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, diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 70edfc132..9c999727a 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -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; } diff --git a/src/util/server.c b/src/util/server.c index 4fa296f4a..940aad363 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -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; diff --git a/src/util/server_mst.c b/src/util/server_mst.c index bf9a3a007..b124b80b6 100644 --- a/src/util/server_mst.c +++ b/src/util/server_mst.c @@ -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; } -- 2.25.1