aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-31 22:04:27 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-31 22:04:27 +0000
commit5848ebddf1977bbe346550b77a305e4f5d243e95 (patch)
tree4e88b8b4fe0f6293c21e992e9037e61cfbff7d14 /src/core
parente27921c7cfbc5b69aabf408d81d7fe85aab91e19 (diff)
downloadgnunet-5848ebddf1977bbe346550b77a305e4f5d243e95.tar.gz
gnunet-5848ebddf1977bbe346550b77a305e4f5d243e95.zip
use larger queue, proper handling of messages with short transmission time, more logging
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gnunet-service-core.c55
1 files changed, 35 insertions, 20 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index cdd2b857e..2d06bd440 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -58,7 +58,7 @@
58 * notifications to a client? (this can cause notifications 58 * notifications to a client? (this can cause notifications
59 * about outgoing messages to be dropped). 59 * about outgoing messages to be dropped).
60 */ 60 */
61#define MAX_NOTIFY_QUEUE 16 61#define MAX_NOTIFY_QUEUE 1024
62 62
63/** 63/**
64 * Minimum bandwidth (out) to assign to any connected peer. 64 * Minimum bandwidth (out) to assign to any connected peer.
@@ -142,14 +142,6 @@
142 */ 142 */
143#define MAX_MESSAGE_AGE GNUNET_TIME_UNIT_DAYS 143#define MAX_MESSAGE_AGE GNUNET_TIME_UNIT_DAYS
144 144
145/**
146 * What is the maximum size for encrypted messages? Note that this
147 * number imposes a clear limit on the maximum size of any message.
148 * Set to a value close to 64k but not so close that transports will
149 * have trouble with their headers.
150 */
151#define MAX_ENCRYPTED_MESSAGE_SIZE (63 * 1024)
152
153 145
154/** 146/**
155 * State machine for our P2P encryption handshake. Everyone starts in 147 * State machine for our P2P encryption handshake. Everyone starts in
@@ -794,7 +786,8 @@ send_to_client (struct Client *client,
794{ 786{
795#if DEBUG_CORE_CLIENT 787#if DEBUG_CORE_CLIENT
796 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 788 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
797 "Preparing to send message of type %u to client.\n", 789 "Preparing to send %u bytes of message of type %u to client.\n",
790 (unsigned int) ntohs (msg->size),
798 (unsigned int) ntohs (msg->type)); 791 (unsigned int) ntohs (msg->type));
799#endif 792#endif
800 GNUNET_SERVER_notification_context_unicast (notifier, 793 GNUNET_SERVER_notification_context_unicast (notifier,
@@ -1561,7 +1554,7 @@ select_messages (struct Neighbour *n,
1561 off = 0; 1554 off = 0;
1562 /* maximum time we can wait before transmitting anything 1555 /* maximum time we can wait before transmitting anything
1563 and still make all of our deadlines */ 1556 and still make all of our deadlines */
1564 slack = GNUNET_CONSTANTS_MAX_CORK_DELAY; 1557 slack = GNUNET_TIME_UNIT_FOREVER_REL;
1565 pos = n->messages; 1558 pos = n->messages;
1566 /* note that we use "*2" here because we want to look 1559 /* note that we use "*2" here because we want to look
1567 a bit further into the future; much more makes no 1560 a bit further into the future; much more makes no
@@ -1641,7 +1634,7 @@ select_messages (struct Neighbour *n,
1641 } 1634 }
1642 /* guard against sending "tiny" messages with large headers without 1635 /* guard against sending "tiny" messages with large headers without
1643 urgent deadlines */ 1636 urgent deadlines */
1644 if ( (slack.value > 0) && 1637 if ( (slack.value > GNUNET_CONSTANTS_MAX_CORK_DELAY.value) &&
1645 (size > 4 * off) && 1638 (size > 4 * off) &&
1646 (queue_size <= MAX_PEER_QUEUE_SIZE - 2) ) 1639 (queue_size <= MAX_PEER_QUEUE_SIZE - 2) )
1647 { 1640 {
@@ -1659,7 +1652,7 @@ select_messages (struct Neighbour *n,
1659#if DEBUG_CORE 1652#if DEBUG_CORE
1660 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1653 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1661 "Deferring transmission for %llums due to underfull message buffer size (%u/%u)\n", 1654 "Deferring transmission for %llums due to underfull message buffer size (%u/%u)\n",
1662 (unsigned long long) slack.value, 1655 (unsigned long long) retry_time->value,
1663 (unsigned int) off, 1656 (unsigned int) off,
1664 (unsigned int) size); 1657 (unsigned int) size);
1665#endif 1658#endif
@@ -1675,9 +1668,22 @@ select_messages (struct Neighbour *n,
1675 pos->do_transmit = GNUNET_YES; /* mark for transmission */ 1668 pos->do_transmit = GNUNET_YES; /* mark for transmission */
1676 off += pos->size; 1669 off += pos->size;
1677 size -= pos->size; 1670 size -= pos->size;
1671#if DEBUG_CORE
1672 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1673 "Selecting message of size %u for transmission\n",
1674 (unsigned int) pos->size);
1675#endif
1678 } 1676 }
1679 else 1677 else
1680 pos->do_transmit = GNUNET_NO; /* mark for not transmitting! */ 1678 {
1679#if DEBUG_CORE
1680 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1681 "Not selecting message of size %u for transmission at this time (maximum is %u)\n",
1682 (unsigned int) pos->size,
1683 size);
1684#endif
1685 pos->do_transmit = GNUNET_NO; /* mark for not transmitting! */
1686 }
1681 pos = pos->next; 1687 pos = pos->next;
1682 } 1688 }
1683#if DEBUG_CORE 1689#if DEBUG_CORE
@@ -1735,7 +1741,6 @@ batch_message (struct Neighbour *n,
1735 ntm->distance = htonl (n->last_distance); 1741 ntm->distance = htonl (n->last_distance);
1736 ntm->latency = GNUNET_TIME_relative_hton (n->last_latency); 1742 ntm->latency = GNUNET_TIME_relative_hton (n->last_latency);
1737 ntm->peer = n->peer; 1743 ntm->peer = n->peer;
1738
1739 pos = n->messages; 1744 pos = n->messages;
1740 prev = NULL; 1745 prev = NULL;
1741 while ((pos != NULL) && (size >= sizeof (struct GNUNET_MessageHeader))) 1746 while ((pos != NULL) && (size >= sizeof (struct GNUNET_MessageHeader)))
@@ -1772,8 +1777,10 @@ batch_message (struct Neighbour *n,
1772 GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND); 1777 GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND);
1773#if DEBUG_HANDSHAKE 1778#if DEBUG_HANDSHAKE
1774 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1779 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1775 "Encrypting message of type %u\n", 1780 "Encrypting %u bytes with message of type %u and size %u\n",
1776 (unsigned int) ntohs(((struct GNUNET_MessageHeader*)&pos[1])->type)); 1781 pos->size,
1782 (unsigned int) ntohs(((const struct GNUNET_MessageHeader*)&pos[1])->type),
1783 (unsigned int) ntohs(((const struct GNUNET_MessageHeader*)&pos[1])->size));
1777#endif 1784#endif
1778 /* copy for encrypted transmission */ 1785 /* copy for encrypted transmission */
1779 memcpy (&buf[ret], &pos[1], pos->size); 1786 memcpy (&buf[ret], &pos[1], pos->size);
@@ -1905,7 +1912,7 @@ set_key_retry_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1905static void 1912static void
1906process_plaintext_neighbour_queue (struct Neighbour *n) 1913process_plaintext_neighbour_queue (struct Neighbour *n)
1907{ 1914{
1908 char pbuf[MAX_ENCRYPTED_MESSAGE_SIZE]; /* plaintext */ 1915 char pbuf[GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE + sizeof (struct EncryptedMessage)]; /* plaintext */
1909 size_t used; 1916 size_t used;
1910 size_t esize; 1917 size_t esize;
1911 struct EncryptedMessage *em; /* encrypted message */ 1918 struct EncryptedMessage *em; /* encrypted message */
@@ -1985,7 +1992,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
1985 used = sizeof (struct EncryptedMessage); 1992 used = sizeof (struct EncryptedMessage);
1986 used += batch_message (n, 1993 used += batch_message (n,
1987 &pbuf[used], 1994 &pbuf[used],
1988 MAX_ENCRYPTED_MESSAGE_SIZE - used, 1995 GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE,
1989 &deadline, &retry_time, &priority); 1996 &deadline, &retry_time, &priority);
1990 if (used == sizeof (struct EncryptedMessage)) 1997 if (used == sizeof (struct EncryptedMessage))
1991 { 1998 {
@@ -3258,7 +3265,7 @@ deliver_messages (struct Neighbour *sender,
3258 int need_align; 3265 int need_align;
3259 3266
3260 while (offset + sizeof (struct GNUNET_MessageHeader) <= buffer_size) 3267 while (offset + sizeof (struct GNUNET_MessageHeader) <= buffer_size)
3261 { 3268 {
3262 if (0 != offset % sizeof (uint16_t)) 3269 if (0 != offset % sizeof (uint16_t))
3263 { 3270 {
3264 /* outch, need to copy to access header */ 3271 /* outch, need to copy to access header */
@@ -3283,6 +3290,14 @@ deliver_messages (struct Neighbour *sender,
3283#else 3290#else
3284 need_align = (0 != offset % 8) ? GNUNET_YES : GNUNET_NO; 3291 need_align = (0 != offset % 8) ? GNUNET_YES : GNUNET_NO;
3285#endif 3292#endif
3293#if DEBUG_CORE
3294 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3295 "Delivering %u bytes of message at offset %u/%u to clients.\n",
3296 (unsigned int) msize,
3297 (unsigned int) offset,
3298 (unsigned int) buffer_size);
3299#endif
3300
3286 if (GNUNET_YES == need_align) 3301 if (GNUNET_YES == need_align)
3287 align_and_deliver (sender, &buffer[offset], msize); 3302 align_and_deliver (sender, &buffer[offset], msize);
3288 else 3303 else