From d984e2895f96f67fe2c44f27cdacfbb404485ada Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 11 Mar 2011 12:57:57 +0000 Subject: implement cork option, fix testcases --- src/core/core.h | 10 ++++++++++ src/core/core_api.c | 8 ++++++++ src/core/gnunet-service-core.c | 3 +++ src/core/test_core_api.c | 1 + src/core/test_core_api_reliability.c | 3 +++ src/core/test_core_api_send_to_self.c | 1 + src/core/test_core_quota_compliance.c | 13 ++++++++----- 7 files changed, 34 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/core.h b/src/core/core.h index acac7c407..fff4c3fa8 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -430,6 +430,16 @@ struct SendMessage */ struct GNUNET_PeerIdentity peer; + /** + * GNUNET_YES if corking is allowed, GNUNET_NO if not. + */ + uint32_t cork GNUNET_PACKED; + + /** + * Always 0. + */ + uint64_t reserved GNUNET_PACKED; + }; diff --git a/src/core/core_api.c b/src/core/core_api.c index a0f72090d..15e8add7e 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -346,6 +346,11 @@ struct GNUNET_CORE_TransmitHandle */ uint16_t smr_id; + /** + * Is corking allowed? + */ + int cork; + }; @@ -707,6 +712,8 @@ transmit_message (void *cls, sm->priority = htonl (th->priority); sm->deadline = GNUNET_TIME_absolute_hton (th->timeout); sm->peer = pr->peer; + sm->cork = htonl ((uint32_t) th->cork); + sm->reserved = htonl (0); ret = th->get_message (th->get_message_cls, size - sizeof (struct SendMessage), &sm[1]); @@ -1532,6 +1539,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay); th->priority = priority; th->msize = notify_size; + th->cork = cork; /* bound queue size */ if (pr->queue_size == handle->queue_size) { diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 6be71242f..298b5e277 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -2886,10 +2886,13 @@ handle_client_send (void *cls, GNUNET_i2s (&sm->peer), (unsigned int) msize); #endif + GNUNET_break (0 == ntohl (sm->reserved)); e = GNUNET_malloc (sizeof (struct MessageEntry) + msize); e->deadline = GNUNET_TIME_absolute_ntoh (sm->deadline); e->priority = ntohl (sm->priority); e->size = msize; + if (GNUNET_YES != (int) ntohl (sm->cork)) + e->got_slack = GNUNET_YES; memcpy (&e[1], &sm[1], msize); /* insert, keep list sorted by deadline */ diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index cdc5517c3..38aaf63b1 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -138,6 +138,7 @@ connect_notify (void *cls, "Asking core (1) for transmission to peer `%4s'\n", GNUNET_i2s (&p2.id)); if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch, + GNUNET_YES, 0, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45), &p2.id, diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index b7f2a8139..f21691691 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c @@ -167,6 +167,7 @@ transmit_ready (void *cls, size_t size, void *buf) if (p1.ch != NULL) GNUNET_break (NULL != GNUNET_CORE_notify_transmit_ready (p1.ch, + GNUNET_NO, 0, FAST_TIMEOUT, &p2.id, @@ -244,6 +245,7 @@ connect_notify (void *cls, start_time = GNUNET_TIME_absolute_get (); GNUNET_break (NULL != GNUNET_CORE_notify_transmit_ready (p1.ch, + GNUNET_NO, 0, TIMEOUT, &p2.id, @@ -356,6 +358,7 @@ process_mtype (void *cls, if (n == tr_n) GNUNET_break (NULL != GNUNET_CORE_notify_transmit_ready (p1.ch, + GNUNET_NO, 0, FAST_TIMEOUT, &p2.id, diff --git a/src/core/test_core_api_send_to_self.c b/src/core/test_core_api_send_to_self.c index 55137dcc9..b287ecf05 100644 --- a/src/core/test_core_api_send_to_self.c +++ b/src/core/test_core_api_send_to_self.c @@ -141,6 +141,7 @@ connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to myself; sending message!\n"); GNUNET_CORE_notify_transmit_ready (core, + GNUNET_YES, 0, GNUNET_TIME_UNIT_FOREVER_REL, peer, sizeof (struct GNUNET_MessageHeader), diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index 6a67b8606..d3b49d880 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c @@ -319,6 +319,7 @@ transmit_ready (void *cls, size_t size, void *buf) (p1.connect_status == 1) ) GNUNET_break (NULL != GNUNET_CORE_notify_transmit_ready (p1.ch, + GNUNET_NO, 0, FAST_TIMEOUT, &p2.id, @@ -395,11 +396,12 @@ connect_notify (void *cls, measure_task = GNUNET_SCHEDULER_add_delayed(MEASUREMENT_LENGTH, &measurement_stop, NULL); GNUNET_break (NULL != GNUNET_CORE_notify_transmit_ready (p1.ch, - 0, - TIMEOUT, - &p2.id, - MESSAGESIZE, - &transmit_ready, &p1)); + GNUNET_NO, + 0, + TIMEOUT, + &p2.id, + MESSAGESIZE, + &transmit_ready, &p1)); } } @@ -503,6 +505,7 @@ process_mtype (void *cls, if (running == GNUNET_YES) GNUNET_break (NULL != GNUNET_CORE_notify_transmit_ready (p1.ch, + GNUNET_NO, 0, FAST_TIMEOUT, &p2.id, -- cgit v1.2.3