diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-06-25 21:08:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-06-25 21:08:55 +0000 |
commit | 537903a8dc4c3ecf2dfa382af0289ddf890adfc7 (patch) | |
tree | 93e448c15c843861bd5dfe86c7cad3245abedfe7 /src/transport/test_transport_api_reliability.c | |
parent | 2b61888a0bf1d41b2b25256ca9834c3040551ce9 (diff) | |
download | gnunet-537903a8dc4c3ecf2dfa382af0289ddf890adfc7.tar.gz gnunet-537903a8dc4c3ecf2dfa382af0289ddf890adfc7.zip |
fixing common off-by-one error with respect to maximum message size
Diffstat (limited to 'src/transport/test_transport_api_reliability.c')
-rw-r--r-- | src/transport/test_transport_api_reliability.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index 755d5a576..4f00fa0d9 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c | |||
@@ -46,7 +46,7 @@ | |||
46 | * 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise | 46 | * 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise |
47 | * messages may be dropped even for a reliable transport. | 47 | * messages may be dropped even for a reliable transport. |
48 | */ | 48 | */ |
49 | #define TOTAL_MSGS (60000 * 2) | 49 | #define TOTAL_MSGS (60000 * 20) |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * How long until we give up on transmitting the message? | 52 | * How long until we give up on transmitting the message? |
@@ -152,6 +152,7 @@ static unsigned int | |||
152 | get_size (unsigned int iter) | 152 | get_size (unsigned int iter) |
153 | { | 153 | { |
154 | unsigned int ret; | 154 | unsigned int ret; |
155 | |||
155 | if (iter < 60000) | 156 | if (iter < 60000) |
156 | return iter + sizeof (struct TestMessage); | 157 | return iter + sizeof (struct TestMessage); |
157 | ret = (iter * iter * iter); | 158 | ret = (iter * iter * iter); |
@@ -168,6 +169,7 @@ notify_receive (void *cls, | |||
168 | { | 169 | { |
169 | static int n; | 170 | static int n; |
170 | unsigned int s; | 171 | unsigned int s; |
172 | char cbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; | ||
171 | const struct TestMessage *hdr; | 173 | const struct TestMessage *hdr; |
172 | 174 | ||
173 | hdr = (const struct TestMessage*) message; | 175 | hdr = (const struct TestMessage*) message; |
@@ -196,6 +198,18 @@ notify_receive (void *cls, | |||
196 | die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); | 198 | die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); |
197 | return; | 199 | return; |
198 | } | 200 | } |
201 | memset (cbuf, n, s - sizeof (struct TestMessage)); | ||
202 | if (0 != memcmp (cbuf, | ||
203 | &hdr[1], | ||
204 | s - sizeof (struct TestMessage))) | ||
205 | { | ||
206 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
207 | "Expected message %u with bits %u, but body did not match\n", | ||
208 | n, (unsigned char) n); | ||
209 | GNUNET_SCHEDULER_cancel (sched, die_task); | ||
210 | die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); | ||
211 | return; | ||
212 | } | ||
199 | #if VERBOSE | 213 | #if VERBOSE |
200 | if (ntohl(hdr->num) % 5000 == 0) | 214 | if (ntohl(hdr->num) % 5000 == 0) |
201 | { | 215 | { |