[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25420 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25420 - gnunet/src/mesh |
Date: |
Wed, 12 Dec 2012 12:25:13 +0100 |
Author: bartpolot
Date: 2012-12-12 12:25:13 +0100 (Wed, 12 Dec 2012)
New Revision: 25420
Modified:
gnunet/src/mesh/gnunet-service-mesh.c
Log:
mesh now accepts REGEXes longer than 64KiB
Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c 2012-12-12 11:11:12 UTC (rev
25419)
+++ gnunet/src/mesh/gnunet-service-mesh.c 2012-12-12 11:25:13 UTC (rev
25420)
@@ -748,6 +748,11 @@
*/
GNUNET_SCHEDULER_TaskIdentifier regex_announce_task;
+ /**
+ * Tmp store for partially retrieved regex.
+ */
+ char *partial_regex;
+
};
@@ -6982,6 +6987,7 @@
struct MeshClient *c;
char *regex;
size_t len;
+ size_t offset;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "announce regex started\n");
@@ -6995,10 +7001,34 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id);
msg = (const struct GNUNET_MESH_RegexAnnounce *) message;
+
len = ntohs (message->size) - sizeof(struct GNUNET_MESH_RegexAnnounce);
- regex = GNUNET_malloc (len + 1);
- memcpy (regex, &msg[1], len);
- regex[len] = '\0';
+ if (NULL != c->partial_regex)
+ {
+ regex = c->partial_regex;
+ offset = strlen (c->partial_regex);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ " continuation, already have %u bytes\n",
+ offset);
+ }
+ else
+ {
+ regex = NULL;
+ offset = 0;
+ }
+
+ regex = GNUNET_realloc (regex, offset + len + 1);
+ memcpy (®ex[offset], &msg[1], len);
+ regex[offset + len] = '\0';
+ if (0 == ntohs (msg->last))
+ {
+ c->partial_regex = regex;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ " not ended, stored %u bytes for later\n",
+ len);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
rd.regex = regex;
rd.compression = ntohs (msg->compression_characters);
rd.dfa = NULL;
@@ -7006,6 +7036,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " regex %s\n", regex);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " cm %u\n", ntohs(rd.compression));
GNUNET_array_append (c->regexes, c->n_regex, rd);
+ c->partial_regex = NULL;
if (GNUNET_SCHEDULER_NO_TASK == c->regex_announce_task)
{
c->regex_announce_task = GNUNET_SCHEDULER_add_now(&announce_regex, c);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25420 - gnunet/src/mesh,
gnunet <=