diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-02-05 16:48:26 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-02-05 16:48:26 +0000 |
commit | d94d7fbcc89a3a61db7bbd87e2cd809c2cc1a623 (patch) | |
tree | 7c5cc8ddefe412f174b454b758b58db72d456ed6 /src | |
parent | f37e4f3d2345a537833d147eb7eb40f16b254c0d (diff) | |
download | gnunet-d94d7fbcc89a3a61db7bbd87e2cd809c2cc1a623.tar.gz gnunet-d94d7fbcc89a3a61db7bbd87e2cd809c2cc1a623.zip |
fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/core/gnunet-service-core.c | 65 |
1 files changed, 54 insertions, 11 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index f86514a93..a00833239 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -41,6 +41,8 @@ | |||
41 | #include "core.h" | 41 | #include "core.h" |
42 | 42 | ||
43 | 43 | ||
44 | #define DEBUG_HANDSHAKE 1 | ||
45 | |||
44 | /** | 46 | /** |
45 | * Receive and send buffer windows grow over time. For | 47 | * Receive and send buffer windows grow over time. For |
46 | * how long can 'unused' bandwidth accumulate before we | 48 | * how long can 'unused' bandwidth accumulate before we |
@@ -319,7 +321,14 @@ struct MessageEntry | |||
319 | * Was this message selected for transmission in the | 321 | * Was this message selected for transmission in the |
320 | * current round? GNUNET_YES or GNUNET_NO. | 322 | * current round? GNUNET_YES or GNUNET_NO. |
321 | */ | 323 | */ |
322 | int16_t do_transmit; | 324 | int8_t do_transmit; |
325 | |||
326 | /** | ||
327 | * Did we give this message some slack (delayed sending) previously | ||
328 | * (and hence should not give it any more slack)? GNUNET_YES or | ||
329 | * GNUNET_NO. | ||
330 | */ | ||
331 | int8_t got_slack; | ||
323 | 332 | ||
324 | }; | 333 | }; |
325 | 334 | ||
@@ -1011,6 +1020,10 @@ notify_encrypted_transmit_ready (void *cls, size_t size, void *buf) | |||
1011 | ret = m->size; | 1020 | ret = m->size; |
1012 | n->available_send_window -= m->size; | 1021 | n->available_send_window -= m->size; |
1013 | process_encrypted_neighbour_queue (n); | 1022 | process_encrypted_neighbour_queue (n); |
1023 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1024 | "Copied message of type %u and size %u into transport buffer for `%4s'\n", | ||
1025 | ntohs (((struct GNUNET_MessageHeader *) &m[1])->type), | ||
1026 | ret, GNUNET_i2s (&n->peer)); | ||
1014 | #if DEBUG_CORE | 1027 | #if DEBUG_CORE |
1015 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1028 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1016 | "Copied message of type %u and size %u into transport buffer for `%4s'\n", | 1029 | "Copied message of type %u and size %u into transport buffer for `%4s'\n", |
@@ -1268,13 +1281,20 @@ select_messages (struct Neighbour *n, | |||
1268 | and relative deadlines caused by other messages | 1281 | and relative deadlines caused by other messages |
1269 | with their respective load */ | 1282 | with their respective load */ |
1270 | slack = GNUNET_MIN (slack, avail / n->bpm_out); | 1283 | slack = GNUNET_MIN (slack, avail / n->bpm_out); |
1271 | if (pos->deadline.value < now.value) | 1284 | if ( (pos->deadline.value < now.value) || |
1272 | slack = 0; | 1285 | (GNUNET_YES == pos->got_slack) ) |
1286 | { | ||
1287 | slack = 0; | ||
1288 | } | ||
1273 | else | 1289 | else |
1274 | slack = | 1290 | { |
1275 | GNUNET_MIN (slack, pos->deadline.value - now.value); | 1291 | slack = |
1292 | GNUNET_MIN (slack, pos->deadline.value - now.value); | ||
1293 | pos->got_slack = GNUNET_YES; | ||
1294 | } | ||
1276 | } | 1295 | } |
1277 | } | 1296 | } |
1297 | |||
1278 | off += pos->size; | 1298 | off += pos->size; |
1279 | t.value = GNUNET_MAX (pos->deadline.value, t.value); | 1299 | t.value = GNUNET_MAX (pos->deadline.value, t.value); |
1280 | if (pos->priority <= min_prio) | 1300 | if (pos->priority <= min_prio) |
@@ -1297,16 +1317,21 @@ select_messages (struct Neighbour *n, | |||
1297 | urgent deadlines */ | 1317 | urgent deadlines */ |
1298 | if ( (slack > 1000) && (size > 4 * off) ) | 1318 | if ( (slack > 1000) && (size > 4 * off) ) |
1299 | { | 1319 | { |
1300 | /* less than 25% of message would be filled with | 1320 | /* less than 25% of message would be filled with deadlines still |
1301 | deadlines still being met if we delay by one | 1321 | being met if we delay by one second or more; so just wait for |
1302 | second or more; so just wait for more data */ | 1322 | more data; but do not wait longer than 1s (since we don't want |
1303 | retry_time->value = slack / 2; | 1323 | to delay messages for a really long time either). */ |
1324 | retry_time->value = 1000; | ||
1304 | /* reset do_transmit values for next time */ | 1325 | /* reset do_transmit values for next time */ |
1305 | while (pos != last) | 1326 | while (pos != last) |
1306 | { | 1327 | { |
1307 | pos->do_transmit = GNUNET_NO; | 1328 | pos->do_transmit = GNUNET_NO; |
1308 | pos = pos->next; | 1329 | pos = pos->next; |
1309 | } | 1330 | } |
1331 | #if DEBUG_CORE | ||
1332 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1333 | "Deferring transmission for 1s due to underfull message buffer size\n"); | ||
1334 | #endif | ||
1310 | return 0; | 1335 | return 0; |
1311 | } | 1336 | } |
1312 | /* select marked messages (up to size) for transmission */ | 1337 | /* select marked messages (up to size) for transmission */ |
@@ -1410,6 +1435,11 @@ batch_message (struct Neighbour *n, | |||
1410 | send_to_all_clients (&ntm->header, | 1435 | send_to_all_clients (&ntm->header, |
1411 | GNUNET_YES, | 1436 | GNUNET_YES, |
1412 | GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND); | 1437 | GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND); |
1438 | #if DEBUG_HANDSHAKE | ||
1439 | fprintf (stderr, | ||
1440 | "Encrypting message of type %u\n", | ||
1441 | ntohs(((struct GNUNET_MessageHeader*)&pos[1])->type)); | ||
1442 | #endif | ||
1413 | /* copy for encrypted transmission */ | 1443 | /* copy for encrypted transmission */ |
1414 | memcpy (&buf[ret], &pos[1], pos->size); | 1444 | memcpy (&buf[ret], &pos[1], pos->size); |
1415 | ret += pos->size; | 1445 | ret += pos->size; |
@@ -2338,7 +2368,8 @@ handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m) | |||
2338 | sizeof (struct GNUNET_PeerIdentity))) | 2368 | sizeof (struct GNUNET_PeerIdentity))) |
2339 | { | 2369 | { |
2340 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2370 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2341 | _("Received `%s' message that was not for me. Ignoring.\n")); | 2371 | _("Received `%s' message that was not for me. Ignoring.\n"), |
2372 | "SET_KEY"); | ||
2342 | return; | 2373 | return; |
2343 | } | 2374 | } |
2344 | if ((ntohl (m->purpose.size) != | 2375 | if ((ntohl (m->purpose.size) != |
@@ -2576,6 +2607,12 @@ deliver_message (struct Neighbour *sender, | |||
2576 | int deliver_full; | 2607 | int deliver_full; |
2577 | 2608 | ||
2578 | type = ntohs (m->type); | 2609 | type = ntohs (m->type); |
2610 | #if DEBUG_HANDSHAKE | ||
2611 | fprintf (stderr, | ||
2612 | "Received encapsulated message of type %u from `%4s'\n", | ||
2613 | type, | ||
2614 | GNUNET_i2s (&sender->peer)); | ||
2615 | #endif | ||
2579 | cpos = clients; | 2616 | cpos = clients; |
2580 | while (cpos != NULL) | 2617 | while (cpos != NULL) |
2581 | { | 2618 | { |
@@ -2814,6 +2851,12 @@ handle_transport_receive (void *cls, | |||
2814 | up = (n->status == PEER_STATE_KEY_CONFIRMED); | 2851 | up = (n->status == PEER_STATE_KEY_CONFIRMED); |
2815 | type = ntohs (message->type); | 2852 | type = ntohs (message->type); |
2816 | size = ntohs (message->size); | 2853 | size = ntohs (message->size); |
2854 | #if DEBUG_HANDSHAKE | ||
2855 | fprintf (stderr, | ||
2856 | "Received message of type %u from `%4s'\n", | ||
2857 | type, | ||
2858 | GNUNET_i2s (peer)); | ||
2859 | #endif | ||
2817 | switch (type) | 2860 | switch (type) |
2818 | { | 2861 | { |
2819 | case GNUNET_MESSAGE_TYPE_CORE_SET_KEY: | 2862 | case GNUNET_MESSAGE_TYPE_CORE_SET_KEY: |