aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-03-11 12:57:57 +0000
committerChristian Grothoff <christian@grothoff.org>2011-03-11 12:57:57 +0000
commitd984e2895f96f67fe2c44f27cdacfbb404485ada (patch)
treea9a355b13cc8d57096ff2de763d9cfd311a742b6 /src/core
parent914ec7ef9e59b69868b92fced96d6693b2097e13 (diff)
downloadgnunet-d984e2895f96f67fe2c44f27cdacfbb404485ada.tar.gz
gnunet-d984e2895f96f67fe2c44f27cdacfbb404485ada.zip
implement cork option, fix testcases
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.h10
-rw-r--r--src/core/core_api.c8
-rw-r--r--src/core/gnunet-service-core.c3
-rw-r--r--src/core/test_core_api.c1
-rw-r--r--src/core/test_core_api_reliability.c3
-rw-r--r--src/core/test_core_api_send_to_self.c1
-rw-r--r--src/core/test_core_quota_compliance.c13
7 files changed, 34 insertions, 5 deletions
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
430 */ 430 */
431 struct GNUNET_PeerIdentity peer; 431 struct GNUNET_PeerIdentity peer;
432 432
433 /**
434 * GNUNET_YES if corking is allowed, GNUNET_NO if not.
435 */
436 uint32_t cork GNUNET_PACKED;
437
438 /**
439 * Always 0.
440 */
441 uint64_t reserved GNUNET_PACKED;
442
433}; 443};
434 444
435 445
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
346 */ 346 */
347 uint16_t smr_id; 347 uint16_t smr_id;
348 348
349 /**
350 * Is corking allowed?
351 */
352 int cork;
353
349}; 354};
350 355
351 356
@@ -707,6 +712,8 @@ transmit_message (void *cls,
707 sm->priority = htonl (th->priority); 712 sm->priority = htonl (th->priority);
708 sm->deadline = GNUNET_TIME_absolute_hton (th->timeout); 713 sm->deadline = GNUNET_TIME_absolute_hton (th->timeout);
709 sm->peer = pr->peer; 714 sm->peer = pr->peer;
715 sm->cork = htonl ((uint32_t) th->cork);
716 sm->reserved = htonl (0);
710 ret = th->get_message (th->get_message_cls, 717 ret = th->get_message (th->get_message_cls,
711 size - sizeof (struct SendMessage), 718 size - sizeof (struct SendMessage),
712 &sm[1]); 719 &sm[1]);
@@ -1532,6 +1539,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
1532 th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay); 1539 th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay);
1533 th->priority = priority; 1540 th->priority = priority;
1534 th->msize = notify_size; 1541 th->msize = notify_size;
1542 th->cork = cork;
1535 /* bound queue size */ 1543 /* bound queue size */
1536 if (pr->queue_size == handle->queue_size) 1544 if (pr->queue_size == handle->queue_size)
1537 { 1545 {
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,
2886 GNUNET_i2s (&sm->peer), 2886 GNUNET_i2s (&sm->peer),
2887 (unsigned int) msize); 2887 (unsigned int) msize);
2888#endif 2888#endif
2889 GNUNET_break (0 == ntohl (sm->reserved));
2889 e = GNUNET_malloc (sizeof (struct MessageEntry) + msize); 2890 e = GNUNET_malloc (sizeof (struct MessageEntry) + msize);
2890 e->deadline = GNUNET_TIME_absolute_ntoh (sm->deadline); 2891 e->deadline = GNUNET_TIME_absolute_ntoh (sm->deadline);
2891 e->priority = ntohl (sm->priority); 2892 e->priority = ntohl (sm->priority);
2892 e->size = msize; 2893 e->size = msize;
2894 if (GNUNET_YES != (int) ntohl (sm->cork))
2895 e->got_slack = GNUNET_YES;
2893 memcpy (&e[1], &sm[1], msize); 2896 memcpy (&e[1], &sm[1], msize);
2894 2897
2895 /* insert, keep list sorted by deadline */ 2898 /* 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,
138 "Asking core (1) for transmission to peer `%4s'\n", 138 "Asking core (1) for transmission to peer `%4s'\n",
139 GNUNET_i2s (&p2.id)); 139 GNUNET_i2s (&p2.id));
140 if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch, 140 if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch,
141 GNUNET_YES,
141 0, 142 0,
142 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45), 143 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45),
143 &p2.id, 144 &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)
167 if (p1.ch != NULL) 167 if (p1.ch != NULL)
168 GNUNET_break (NULL != 168 GNUNET_break (NULL !=
169 GNUNET_CORE_notify_transmit_ready (p1.ch, 169 GNUNET_CORE_notify_transmit_ready (p1.ch,
170 GNUNET_NO,
170 0, 171 0,
171 FAST_TIMEOUT, 172 FAST_TIMEOUT,
172 &p2.id, 173 &p2.id,
@@ -244,6 +245,7 @@ connect_notify (void *cls,
244 start_time = GNUNET_TIME_absolute_get (); 245 start_time = GNUNET_TIME_absolute_get ();
245 GNUNET_break (NULL != 246 GNUNET_break (NULL !=
246 GNUNET_CORE_notify_transmit_ready (p1.ch, 247 GNUNET_CORE_notify_transmit_ready (p1.ch,
248 GNUNET_NO,
247 0, 249 0,
248 TIMEOUT, 250 TIMEOUT,
249 &p2.id, 251 &p2.id,
@@ -356,6 +358,7 @@ process_mtype (void *cls,
356 if (n == tr_n) 358 if (n == tr_n)
357 GNUNET_break (NULL != 359 GNUNET_break (NULL !=
358 GNUNET_CORE_notify_transmit_ready (p1.ch, 360 GNUNET_CORE_notify_transmit_ready (p1.ch,
361 GNUNET_NO,
359 0, 362 0,
360 FAST_TIMEOUT, 363 FAST_TIMEOUT,
361 &p2.id, 364 &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,
141 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 141 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
142 "Connected to myself; sending message!\n"); 142 "Connected to myself; sending message!\n");
143 GNUNET_CORE_notify_transmit_ready (core, 143 GNUNET_CORE_notify_transmit_ready (core,
144 GNUNET_YES,
144 0, GNUNET_TIME_UNIT_FOREVER_REL, 145 0, GNUNET_TIME_UNIT_FOREVER_REL,
145 peer, 146 peer,
146 sizeof (struct GNUNET_MessageHeader), 147 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)
319 (p1.connect_status == 1) ) 319 (p1.connect_status == 1) )
320 GNUNET_break (NULL != 320 GNUNET_break (NULL !=
321 GNUNET_CORE_notify_transmit_ready (p1.ch, 321 GNUNET_CORE_notify_transmit_ready (p1.ch,
322 GNUNET_NO,
322 0, 323 0,
323 FAST_TIMEOUT, 324 FAST_TIMEOUT,
324 &p2.id, 325 &p2.id,
@@ -395,11 +396,12 @@ connect_notify (void *cls,
395 measure_task = GNUNET_SCHEDULER_add_delayed(MEASUREMENT_LENGTH, &measurement_stop, NULL); 396 measure_task = GNUNET_SCHEDULER_add_delayed(MEASUREMENT_LENGTH, &measurement_stop, NULL);
396 397
397 GNUNET_break (NULL != GNUNET_CORE_notify_transmit_ready (p1.ch, 398 GNUNET_break (NULL != GNUNET_CORE_notify_transmit_ready (p1.ch,
398 0, 399 GNUNET_NO,
399 TIMEOUT, 400 0,
400 &p2.id, 401 TIMEOUT,
401 MESSAGESIZE, 402 &p2.id,
402 &transmit_ready, &p1)); 403 MESSAGESIZE,
404 &transmit_ready, &p1));
403 } 405 }
404} 406}
405 407
@@ -503,6 +505,7 @@ process_mtype (void *cls,
503 if (running == GNUNET_YES) 505 if (running == GNUNET_YES)
504 GNUNET_break (NULL != 506 GNUNET_break (NULL !=
505 GNUNET_CORE_notify_transmit_ready (p1.ch, 507 GNUNET_CORE_notify_transmit_ready (p1.ch,
508 GNUNET_NO,
506 0, 509 0,
507 FAST_TIMEOUT, 510 FAST_TIMEOUT,
508 &p2.id, 511 &p2.id,