diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-01-20 13:51:20 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-01-20 13:51:20 +0000 |
commit | 7d9f187d106394b2451660294df9428eb50e82d7 (patch) | |
tree | 373a78f3c10529689791b65a5ab885d3f4c761b7 /src/transport | |
parent | 924137ff73bab48b720d41cf73a1197df2d4b04d (diff) | |
download | gnunet-7d9f187d106394b2451660294df9428eb50e82d7.tar.gz gnunet-7d9f187d106394b2451660294df9428eb50e82d7.zip |
fixing core API issues
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/transport_api.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 155347bf0..e17ba742e 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -22,10 +22,6 @@ | |||
22 | * @file transport/transport_api.c | 22 | * @file transport/transport_api.c |
23 | * @brief library to access the low-level P2P IO service | 23 | * @brief library to access the low-level P2P IO service |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | ||
26 | * TODO: | ||
27 | * - set_quota with low bandwidth should cause peer | ||
28 | * disconnects (currently never does that) (MINOR) | ||
29 | */ | 25 | */ |
30 | #include "platform.h" | 26 | #include "platform.h" |
31 | #include "gnunet_client_lib.h" | 27 | #include "gnunet_client_lib.h" |
@@ -395,7 +391,8 @@ transport_notify_ready (void *cls, size_t size, void *buf) | |||
395 | GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); | 391 | GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); |
396 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 392 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
397 | } | 393 | } |
398 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); | 394 | if (NULL != th->notify) |
395 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); | ||
399 | GNUNET_free (th); | 396 | GNUNET_free (th); |
400 | if (h->connect_ready_head != NULL) | 397 | if (h->connect_ready_head != NULL) |
401 | schedule_transmission (h); /* FIXME: is this ok? */ | 398 | schedule_transmission (h); /* FIXME: is this ok? */ |
@@ -427,7 +424,8 @@ transport_notify_ready (void *cls, size_t size, void *buf) | |||
427 | GNUNET_assert (n->transmit_handle == th); | 424 | GNUNET_assert (n->transmit_handle == th); |
428 | n->transmit_handle = NULL; | 425 | n->transmit_handle = NULL; |
429 | } | 426 | } |
430 | ret += th->notify (th->notify_cls, size, &cbuf[ret]); | 427 | if (NULL != th->notify) |
428 | ret += th->notify (th->notify_cls, size, &cbuf[ret]); | ||
431 | GNUNET_free (th); | 429 | GNUNET_free (th); |
432 | if (n != NULL) | 430 | if (n != NULL) |
433 | n->last_sent += ret; | 431 | n->last_sent += ret; |
@@ -585,7 +583,8 @@ peer_transmit_timeout (void *cls, | |||
585 | GNUNET_i2s (&th->target)); | 583 | GNUNET_i2s (&th->target)); |
586 | #endif | 584 | #endif |
587 | remove_from_any_list (th); | 585 | remove_from_any_list (th); |
588 | th->notify (th->notify_cls, 0, NULL); | 586 | if (NULL != th->notify) |
587 | th->notify (th->notify_cls, 0, NULL); | ||
589 | GNUNET_free (th); | 588 | GNUNET_free (th); |
590 | } | 589 | } |
591 | 590 | ||
@@ -735,10 +734,8 @@ send_set_quota (void *cls, size_t size, void *buf) | |||
735 | * | 734 | * |
736 | * @param handle connection to transport service | 735 | * @param handle connection to transport service |
737 | * @param target who's bandwidth quota is being changed | 736 | * @param target who's bandwidth quota is being changed |
738 | * @param quota_in incoming bandwidth quota in bytes per ms; 0 can | 737 | * @param quota_in incoming bandwidth quota in bytes per ms |
739 | * be used to force all traffic to be discarded | 738 | * @param quota_out outgoing bandwidth quota in bytes per ms |
740 | * @param quota_out outgoing bandwidth quota in bytes per ms; 0 can | ||
741 | * be used to force all traffic to be discarded | ||
742 | * @param timeout how long to wait until signaling failure if | 739 | * @param timeout how long to wait until signaling failure if |
743 | * we can not communicate the quota change | 740 | * we can not communicate the quota change |
744 | * @param cont continuation to call when done, will be called | 741 | * @param cont continuation to call when done, will be called |
@@ -992,7 +989,8 @@ request_connect (void *cls, size_t size, void *buf) | |||
992 | GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); | 989 | GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); |
993 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 990 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
994 | } | 991 | } |
995 | th->notify (th->notify_cls, 0, NULL); | 992 | if (NULL != th->notify) |
993 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); | ||
996 | GNUNET_free (th); | 994 | GNUNET_free (th); |
997 | return 0; | 995 | return 0; |
998 | } | 996 | } |
@@ -1288,7 +1286,8 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th) | |||
1288 | duration.value, GNUNET_i2s (&th->target)); | 1286 | duration.value, GNUNET_i2s (&th->target)); |
1289 | #endif | 1287 | #endif |
1290 | remove_from_wait_list (th); | 1288 | remove_from_wait_list (th); |
1291 | th->notify (th->notify_cls, 0, NULL); | 1289 | if (NULL != th->notify) |
1290 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); | ||
1292 | GNUNET_free (th); | 1291 | GNUNET_free (th); |
1293 | return; | 1292 | return; |
1294 | } | 1293 | } |
@@ -1472,7 +1471,8 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) | |||
1472 | GNUNET_SCHEDULER_cancel (handle->sched, th->notify_delay_task); | 1471 | GNUNET_SCHEDULER_cancel (handle->sched, th->notify_delay_task); |
1473 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 1472 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
1474 | } | 1473 | } |
1475 | th->notify (th->notify_cls, 0, NULL); | 1474 | if (NULL != th->notify) |
1475 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); | ||
1476 | GNUNET_free (th); | 1476 | GNUNET_free (th); |
1477 | } | 1477 | } |
1478 | while (NULL != (th = handle->connect_wait_head)) | 1478 | while (NULL != (th = handle->connect_wait_head)) |
@@ -1483,7 +1483,8 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) | |||
1483 | GNUNET_SCHEDULER_cancel (handle->sched, th->notify_delay_task); | 1483 | GNUNET_SCHEDULER_cancel (handle->sched, th->notify_delay_task); |
1484 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 1484 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
1485 | } | 1485 | } |
1486 | th->notify (th->notify_cls, 0, NULL); | 1486 | if (NULL != th->notify) |
1487 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); | ||
1487 | GNUNET_free (th); | 1488 | GNUNET_free (th); |
1488 | } | 1489 | } |
1489 | while (NULL != (n = handle->neighbours)) | 1490 | while (NULL != (n = handle->neighbours)) |
@@ -1496,7 +1497,8 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) | |||
1496 | GNUNET_SCHEDULER_cancel (handle->sched, th->notify_delay_task); | 1497 | GNUNET_SCHEDULER_cancel (handle->sched, th->notify_delay_task); |
1497 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 1498 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
1498 | } | 1499 | } |
1499 | th->notify (th->notify_cls, 0, NULL); | 1500 | if (NULL != th->notify) |
1501 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); | ||
1500 | GNUNET_free (th); | 1502 | GNUNET_free (th); |
1501 | } | 1503 | } |
1502 | GNUNET_free (n); | 1504 | GNUNET_free (n); |
@@ -1788,16 +1790,19 @@ client_notify_wrapper (void *cls, size_t size, void *buf) | |||
1788 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1790 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1789 | "Transmission request could not be satisfied.\n"); | 1791 | "Transmission request could not be satisfied.\n"); |
1790 | #endif | 1792 | #endif |
1791 | ret = ctw->notify (ctw->notify_cls, 0, NULL); | 1793 | if (NULL != ctw->notify) |
1792 | GNUNET_assert (ret == 0); | 1794 | GNUNET_assert (0 == ctw->notify (ctw->notify_cls, 0, NULL)); |
1793 | GNUNET_free (ctw); | 1795 | GNUNET_free (ctw); |
1794 | return 0; | 1796 | return 0; |
1795 | } | 1797 | } |
1796 | GNUNET_assert (size >= sizeof (struct OutboundMessage)); | 1798 | GNUNET_assert (size >= sizeof (struct OutboundMessage)); |
1797 | obm = buf; | 1799 | obm = buf; |
1798 | ret = ctw->notify (ctw->notify_cls, | 1800 | if (ctw->notify != NULL) |
1799 | size - sizeof (struct OutboundMessage), | 1801 | ret = ctw->notify (ctw->notify_cls, |
1800 | (void *) &obm[1]); | 1802 | size - sizeof (struct OutboundMessage), |
1803 | (void *) &obm[1]); | ||
1804 | else | ||
1805 | ret = 0; | ||
1801 | if (ret == 0) | 1806 | if (ret == 0) |
1802 | { | 1807 | { |
1803 | /* Need to reset flag, no SEND means no SEND_OK! */ | 1808 | /* Need to reset flag, no SEND means no SEND_OK! */ |