GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
*/
#include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_connection_lib.h"
-#include "gnunet_scheduler_lib.h"
-#include "gnunet_server_lib.h"
-#include "gnunet_time_lib.h"
+#include "gnunet_util_lib.h"
-#define DEBUG_SERVER_MST GNUNET_EXTRA_LOGGING
#if HAVE_UNALIGNED_64_ACCESS
#define ALIGN_FACTOR 4
{
struct GNUNET_SERVER_MessageStreamTokenizer *ret;
- ret = GNUNET_malloc (sizeof (struct GNUNET_SERVER_MessageStreamTokenizer));
+ ret = GNUNET_new (struct GNUNET_SERVER_MessageStreamTokenizer);
ret->hdr = GNUNET_malloc (GNUNET_SERVER_MIN_BUFFER_SIZE);
ret->curr_buf = GNUNET_SERVER_MIN_BUFFER_SIZE;
ret->cb = cb;
GNUNET_assert (mst->off <= mst->pos);
GNUNET_assert (mst->pos <= mst->curr_buf);
-#if DEBUG_SERVER_MST
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Server-mst receives %u bytes with %u bytes already in private buffer\n",
(unsigned int) size, (unsigned int) (mst->pos - mst->off));
-#endif
ret = GNUNET_OK;
ibuf = (char *) mst->hdr;
while (mst->pos > 0)
if (one_shot == GNUNET_YES)
one_shot = GNUNET_SYSERR;
mst->off += want;
- mst->cb (mst->cb_cls, client_identity, hdr);
+ if (GNUNET_SYSERR == mst->cb (mst->cb_cls, client_identity, hdr))
+ return GNUNET_SYSERR;
if (mst->off == mst->pos)
{
/* reset to beginning of buffer, it's free right now! */
GNUNET_assert (0 == mst->pos);
while (size > 0)
{
-#if DEBUG_SERVER_MST
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Server-mst has %u bytes left in inbound buffer\n",
(unsigned int) size);
-#endif
if (size < sizeof (struct GNUNET_MessageHeader))
break;
offset = (unsigned long) buf;
}
if (one_shot == GNUNET_YES)
one_shot = GNUNET_SYSERR;
- mst->cb (mst->cb_cls, client_identity, hdr);
+ if (GNUNET_SYSERR == mst->cb (mst->cb_cls, client_identity, hdr))
+ return GNUNET_SYSERR;
buf += want;
size -= want;
}
mst->off = 0;
mst->pos = 0;
}
-#if DEBUG_SERVER_MST
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Server-mst leaves %u bytes in private buffer\n",
(unsigned int) (mst->pos - mst->off));
-#endif
return ret;
}