diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-05-10 16:06:13 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-05-10 16:06:13 +0000 |
commit | ef14230266cc6f855622fbad1e482fb739756274 (patch) | |
tree | 3269b52fef86c6e9bbe928196036e598cbfba8f5 /src | |
parent | d53c2eea5634af37d4c35067cc9b79c9189591f4 (diff) | |
download | gnunet-ef14230266cc6f855622fbad1e482fb739756274.tar.gz gnunet-ef14230266cc6f855622fbad1e482fb739756274.zip |
- fix poll for lost ack
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh-new.c | 79 |
1 files changed, 50 insertions, 29 deletions
diff --git a/src/mesh/gnunet-service-mesh-new.c b/src/mesh/gnunet-service-mesh-new.c index 72169769e..3252d2703 100644 --- a/src/mesh/gnunet-service-mesh-new.c +++ b/src/mesh/gnunet-service-mesh-new.c | |||
@@ -283,6 +283,19 @@ struct MeshFlowControl | |||
283 | * Task to poll the peer in case of a lost ACK causes stall. | 283 | * Task to poll the peer in case of a lost ACK causes stall. |
284 | */ | 284 | */ |
285 | GNUNET_SCHEDULER_TaskIdentifier poll_task; | 285 | GNUNET_SCHEDULER_TaskIdentifier poll_task; |
286 | |||
287 | /** | ||
288 | * How frequently to poll for ACKs. | ||
289 | */ | ||
290 | struct GNUNET_TIME_Relative poll_time; | ||
291 | |||
292 | /** | ||
293 | * On which tunnel to poll. | ||
294 | * Using an explicit poll_ctx would not help memory wise, | ||
295 | * since the allocated context would have to be stored in the | ||
296 | * fc struct in order to free it upon cancelling poll_task. | ||
297 | */ | ||
298 | struct MeshTunnel *t; | ||
286 | }; | 299 | }; |
287 | 300 | ||
288 | 301 | ||
@@ -1825,40 +1838,45 @@ peer_info_add_path_to_origin (struct MeshPeerInfo *peer_info, | |||
1825 | } | 1838 | } |
1826 | 1839 | ||
1827 | 1840 | ||
1828 | /** FIXME | 1841 | /** |
1829 | * Function called if the connection to the peer has been stalled for a while, | 1842 | * Function called if the connection to the peer has been stalled for a while, |
1830 | * possibly due to a missed ACK. Poll the peer about its ACK status. | 1843 | * possibly due to a missed ACK. Poll the peer about its ACK status. |
1831 | * | 1844 | * |
1832 | * @param cls Closure (cinfo). | 1845 | * @param cls Closure (poll ctx). |
1833 | * @param tc TaskContext. | 1846 | * @param tc TaskContext. |
1834 | */ | 1847 | */ |
1835 | static void | 1848 | static void |
1836 | tunnel_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1849 | tunnel_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
1837 | { | 1850 | { |
1838 | // struct GNUNET_MESH_Poll msg; | 1851 | struct MeshFlowControl *fc = cls; |
1839 | // struct GNUNET_PeerIdentity id; | 1852 | struct GNUNET_MESH_Poll msg; |
1840 | // struct MeshTunnel *t; | 1853 | struct MeshTunnel *t = fc->t; |
1854 | GNUNET_PEER_Id peer; | ||
1841 | 1855 | ||
1842 | // cinfo->fc_poll = GNUNET_SCHEDULER_NO_TASK; | 1856 | fc->poll_task = GNUNET_SCHEDULER_NO_TASK; |
1843 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1857 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1844 | { | 1858 | { |
1845 | return; | 1859 | return; |
1846 | } | 1860 | } |
1847 | 1861 | ||
1848 | // t = cinfo->t; | 1862 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_POLL); |
1849 | // msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_POLL); | 1863 | msg.header.size = htons (sizeof (msg)); |
1850 | // msg.header.size = htons (sizeof (msg)); | 1864 | msg.tid = htonl (t->id.tid); |
1851 | // msg.tid = htonl (t->id.tid); | 1865 | GNUNET_PEER_resolve (t->id.oid, &msg.oid); |
1852 | // GNUNET_PEER_resolve (t->id.oid, &msg.oid); | 1866 | msg.last_ack = htonl (fc->last_ack_recv); |
1853 | // msg.last_ack = htonl (cinfo->fwd_ack); | 1867 | |
1854 | // | 1868 | if (fc == &t->prev_fc) |
1855 | // GNUNET_PEER_resolve (cinfo->id, &id); | 1869 | { |
1856 | // send_prebuilt_message (&msg.header, &id, cinfo->t); | 1870 | peer = t->prev_hop; |
1857 | // cinfo->fc_poll_time = GNUNET_TIME_relative_min ( | 1871 | } |
1858 | // MESH_MAX_POLL_TIME, | 1872 | else |
1859 | // GNUNET_TIME_relative_multiply (cinfo->fc_poll_time, 2)); | 1873 | { |
1860 | // cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed (cinfo->fc_poll_time, | 1874 | peer = t->next_hop; |
1861 | // &tunnel_poll, cinfo); | 1875 | } |
1876 | send_prebuilt_message (&msg.header, peer, t); | ||
1877 | fc->poll_time = GNUNET_TIME_STD_BACKOFF (fc->poll_time); | ||
1878 | fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time, | ||
1879 | &tunnel_poll, fc); | ||
1862 | } | 1880 | } |
1863 | 1881 | ||
1864 | 1882 | ||
@@ -3312,6 +3330,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
3312 | struct MeshPeerQueue *queue; | 3330 | struct MeshPeerQueue *queue; |
3313 | struct MeshTunnel *t; | 3331 | struct MeshTunnel *t; |
3314 | struct GNUNET_PeerIdentity dst_id; | 3332 | struct GNUNET_PeerIdentity dst_id; |
3333 | struct MeshFlowControl *fc; | ||
3315 | size_t data_size; | 3334 | size_t data_size; |
3316 | 3335 | ||
3317 | peer->core_transmit = NULL; | 3336 | peer->core_transmit = NULL; |
@@ -3324,7 +3343,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
3324 | { | 3343 | { |
3325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not ready, return\n"); | 3344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not ready, return\n"); |
3326 | if (NULL == peer->queue_head) | 3345 | if (NULL == peer->queue_head) |
3327 | GNUNET_break (0); // Should've been canceled | 3346 | GNUNET_break (0); /* Core tmt_rdy should've been canceled */ |
3328 | return 0; | 3347 | return 0; |
3329 | } | 3348 | } |
3330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not empty\n"); | 3349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not empty\n"); |
@@ -3477,14 +3496,16 @@ queue_send (void *cls, size_t size, void *buf) | |||
3477 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 3496 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
3478 | "********* %s stalled\n", | 3497 | "********* %s stalled\n", |
3479 | GNUNET_i2s(&my_full_id)); | 3498 | GNUNET_i2s(&my_full_id)); |
3480 | // if (NULL == cinfo) FIXME | 3499 | if (peer->id == t->next_hop) |
3481 | // cinfo = tunnel_get_neighbor_fc (t, &dst_id); | 3500 | fc = &t->next_fc; |
3482 | // // FIXME unify bck/fwd structures, bck does not have cinfo right now | 3501 | else |
3483 | // if (NULL != cinfo && GNUNET_SCHEDULER_NO_TASK == cinfo->fc_poll) | 3502 | fc = &t->prev_fc; |
3484 | // { | 3503 | if (GNUNET_SCHEDULER_NO_TASK == fc->poll_task) |
3485 | // cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed (cinfo->fc_poll_time, | 3504 | { |
3486 | // &tunnel_poll, cinfo); | 3505 | fc->t = t; |
3487 | // } | 3506 | fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time, |
3507 | &tunnel_poll, fc); | ||
3508 | } | ||
3488 | } | 3509 | } |
3489 | } | 3510 | } |
3490 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* return %d\n", data_size); | 3511 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* return %d\n", data_size); |