aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-12-01 19:07:03 +0000
committerChristian Grothoff <christian@grothoff.org>2010-12-01 19:07:03 +0000
commitd4be8ac1581999d563cdefafc555cc0cb1dbf272 (patch)
tree0054c7bf73c478c9e98a64faa71ea2b322f65d1e /src/transport/transport_api.c
parent3c4d9d3e55788f7e15ad660e8b39160be0616f0a (diff)
downloadgnunet-d4be8ac1581999d563cdefafc555cc0cb1dbf272.tar.gz
gnunet-d4be8ac1581999d563cdefafc555cc0cb1dbf272.zip
cleanup
Diffstat (limited to 'src/transport/transport_api.c')
-rw-r--r--src/transport/transport_api.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index 1dbf8cb10..0ab92659b 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -209,11 +209,6 @@ struct TryTransmitContext
209 struct GNUNET_TRANSPORT_TransmitHandle *ret; 209 struct GNUNET_TRANSPORT_TransmitHandle *ret;
210 210
211 /** 211 /**
212 * Temporary transmit handle.
213 */
214 struct GNUNET_TRANSPORT_TransmitHandle *th;
215
216 /**
217 * Time to retry the send task. 212 * Time to retry the send task.
218 */ 213 */
219 struct GNUNET_TIME_Relative retry_time; 214 struct GNUNET_TIME_Relative retry_time;
@@ -439,6 +434,7 @@ quota_transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
439 schedule_transmission (h); 434 schedule_transmission (h);
440} 435}
441 436
437
442/** 438/**
443 * Iterator over hash map entries, attempt to schedule 439 * Iterator over hash map entries, attempt to schedule
444 * a transmission to entries in the neighbour hashmap. 440 * a transmission to entries in the neighbour hashmap.
@@ -459,19 +455,20 @@ try_schedule_transmission (void *cls,
459 struct TryTransmitContext *try_transmit_ctx = cls; 455 struct TryTransmitContext *try_transmit_ctx = cls;
460 struct GNUNET_TIME_Relative duration; 456 struct GNUNET_TIME_Relative duration;
461 GNUNET_CONNECTION_TransmitReadyNotify notify; 457 GNUNET_CONNECTION_TransmitReadyNotify notify;
458 struct GNUNET_TRANSPORT_TransmitHandle *th;
462 459
463 if (n->transmit_stage != TS_QUEUED) 460 if (n->transmit_stage != TS_QUEUED)
464 return GNUNET_YES; /* not eligible, keep iterating */ 461 return GNUNET_YES; /* not eligible, keep iterating */
465 if (n->is_connected != GNUNET_YES) 462 if (n->is_connected != GNUNET_YES)
466 return GNUNET_YES; /* keep iterating */ 463 return GNUNET_YES; /* keep iterating */
467 464
468 try_transmit_ctx->th = &n->transmit_handle; 465 th = &n->transmit_handle;
469 GNUNET_break (n == try_transmit_ctx->th->neighbour); 466 GNUNET_break (n == th->neighbour);
470 /* check outgoing quota */ 467 /* check outgoing quota */
471 duration = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker, 468 duration = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker,
472 try_transmit_ctx->th->notify_size - sizeof (struct OutboundMessage)); 469 th->notify_size - sizeof (struct OutboundMessage));
473 struct GNUNET_TIME_Absolute duration_abs = GNUNET_TIME_relative_to_absolute (duration); 470 struct GNUNET_TIME_Absolute duration_abs = GNUNET_TIME_relative_to_absolute (duration);
474 if (try_transmit_ctx->th->timeout.abs_value < duration_abs.abs_value) 471 if (th->timeout.abs_value < duration_abs.abs_value)
475 { 472 {
476 /* signal timeout! */ 473 /* signal timeout! */
477#if DEBUG_TRANSPORT 474#if DEBUG_TRANSPORT
@@ -480,16 +477,16 @@ try_schedule_transmission (void *cls,
480 duration.rel_value, 477 duration.rel_value,
481 GNUNET_i2s (&n->id)); 478 GNUNET_i2s (&n->id));
482#endif 479#endif
483 if (try_transmit_ctx->th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) 480 if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK)
484 { 481 {
485 GNUNET_SCHEDULER_cancel (try_transmit_ctx->th->notify_delay_task); 482 GNUNET_SCHEDULER_cancel (th->notify_delay_task);
486 try_transmit_ctx->th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; 483 th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
487 } 484 }
488 n->transmit_stage = TS_NEW; 485 n->transmit_stage = TS_NEW;
489 if (NULL != (notify = try_transmit_ctx->th->notify)) 486 if (NULL != (notify = th->notify))
490 { 487 {
491 try_transmit_ctx->th->notify = NULL; 488 th->notify = NULL;
492 GNUNET_assert (0 == notify (try_transmit_ctx->th->notify_cls, 0, NULL)); 489 GNUNET_assert (0 == notify (th->notify_cls, 0, NULL));
493 } 490 }
494 return GNUNET_YES; /* keep iterating */ 491 return GNUNET_YES; /* keep iterating */
495 } 492 }
@@ -499,7 +496,7 @@ try_schedule_transmission (void *cls,
499 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 496 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
500 "Need more bandwidth (%u b/s allowed, %u b needed), delaying delivery to `%4s' by %llu ms\n", 497 "Need more bandwidth (%u b/s allowed, %u b needed), delaying delivery to `%4s' by %llu ms\n",
501 (unsigned int) n->out_tracker.available_bytes_per_s__, 498 (unsigned int) n->out_tracker.available_bytes_per_s__,
502 (unsigned int) try_transmit_ctx->th->notify_size - sizeof (struct OutboundMessage), 499 (unsigned int) th->notify_size - sizeof (struct OutboundMessage),
503 GNUNET_i2s (&n->id), 500 GNUNET_i2s (&n->id),
504 duration.rel_value); 501 duration.rel_value);
505#endif 502#endif
@@ -510,14 +507,13 @@ try_schedule_transmission (void *cls,
510#if DEBUG_TRANSPORT 507#if DEBUG_TRANSPORT
511 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
512 "Have %u bytes of bandwidth available for transmission to `%4s' right now\n", 509 "Have %u bytes of bandwidth available for transmission to `%4s' right now\n",
513 try_transmit_ctx->th->notify_size - sizeof (struct OutboundMessage), 510 th->notify_size - sizeof (struct OutboundMessage),
514 GNUNET_i2s (&n->id)); 511 GNUNET_i2s (&n->id));
515#endif 512#endif
516 513
517 if ( (try_transmit_ctx->ret == NULL) || 514 if ( (try_transmit_ctx->ret == NULL) ||
518 (try_transmit_ctx->ret->priority < try_transmit_ctx->th->priority) ) 515 (try_transmit_ctx->ret->priority < th->priority) )
519 try_transmit_ctx->ret = try_transmit_ctx->th; 516 try_transmit_ctx->ret = th;
520
521 return GNUNET_YES; 517 return GNUNET_YES;
522} 518}
523 519