diff options
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.c | 24 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.c | 24 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.h | 8 |
3 files changed, 34 insertions, 22 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 47f555503..a5b569b48 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c | |||
@@ -557,6 +557,7 @@ send_ack (struct MeshConnection *c, unsigned int buffer, int fwd, int force) | |||
557 | * | 557 | * |
558 | * @param cls Closure (ConnectionQueue Handle). | 558 | * @param cls Closure (ConnectionQueue Handle). |
559 | * @param c Connection this message was on. | 559 | * @param c Connection this message was on. |
560 | * @param sent Was it really sent? (Could have been canceled) | ||
560 | * @param type Type of message sent. | 561 | * @param type Type of message sent. |
561 | * @param fwd Was this a FWD going message? | 562 | * @param fwd Was this a FWD going message? |
562 | * @param size Size of the message. | 563 | * @param size Size of the message. |
@@ -564,8 +565,8 @@ send_ack (struct MeshConnection *c, unsigned int buffer, int fwd, int force) | |||
564 | */ | 565 | */ |
565 | static void | 566 | static void |
566 | message_sent (void *cls, | 567 | message_sent (void *cls, |
567 | struct MeshConnection *c, uint16_t type, | 568 | struct MeshConnection *c, int sent, |
568 | int fwd, size_t size, | 569 | uint16_t type, int fwd, size_t size, |
569 | struct GNUNET_TIME_Relative wait) | 570 | struct GNUNET_TIME_Relative wait) |
570 | { | 571 | { |
571 | struct MeshConnectionPerformance *p; | 572 | struct MeshConnectionPerformance *p; |
@@ -575,10 +576,8 @@ message_sent (void *cls, | |||
575 | int forced; | 576 | int forced; |
576 | 577 | ||
577 | fc = fwd ? &c->fwd_fc : &c->bck_fc; | 578 | fc = fwd ? &c->fwd_fc : &c->bck_fc; |
578 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 579 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! %ssent %s %s\n", |
579 | "! sent %s %s\n", | 580 | sent ? "" : "not ", GM_f2s (fwd), GM_m2s (type)); |
580 | GM_f2s (fwd), | ||
581 | GM_m2s (type)); | ||
582 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! C_P- %p %u\n", c, c->pending_messages); | 581 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! C_P- %p %u\n", c, c->pending_messages); |
583 | if (NULL != q) | 582 | if (NULL != q) |
584 | { | 583 | { |
@@ -618,7 +617,9 @@ message_sent (void *cls, | |||
618 | break; | 617 | break; |
619 | 618 | ||
620 | case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: | 619 | case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: |
621 | fc->last_pid_sent++; | 620 | if (GNUNET_YES == sent) |
621 | fc->last_pid_sent++; | ||
622 | |||
622 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! Q_N- %p %u\n", fc, fc->queue_n); | 623 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! Q_N- %p %u\n", fc, fc->queue_n); |
623 | if (GNUNET_NO == forced) | 624 | if (GNUNET_NO == forced) |
624 | { | 625 | { |
@@ -633,8 +634,11 @@ message_sent (void *cls, | |||
633 | "! forced, Q_N not accounting pid %u\n", | 634 | "! forced, Q_N not accounting pid %u\n", |
634 | fc->last_pid_sent); | 635 | fc->last_pid_sent); |
635 | } | 636 | } |
636 | GMC_send_ack (c, fwd, GNUNET_NO); | 637 | if (GNUNET_YES == sent) |
637 | connection_reset_timeout (c, fwd); | 638 | { |
639 | GMC_send_ack (c, fwd, GNUNET_NO); | ||
640 | connection_reset_timeout (c, fwd); | ||
641 | } | ||
638 | break; | 642 | break; |
639 | 643 | ||
640 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | 644 | case GNUNET_MESSAGE_TYPE_MESH_POLL: |
@@ -2936,7 +2940,7 @@ GMC_cancel (struct MeshConnectionQueue *q) | |||
2936 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! GMC cancel message\n"); | 2940 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! GMC cancel message\n"); |
2937 | 2941 | ||
2938 | /* queue destroy calls message_sent, which calls q->cont and frees q */ | 2942 | /* queue destroy calls message_sent, which calls q->cont and frees q */ |
2939 | GMP_queue_destroy (q->q, GNUNET_YES); | 2943 | GMP_queue_destroy (q->q, GNUNET_YES, GNUNET_NO); |
2940 | } | 2944 | } |
2941 | 2945 | ||
2942 | 2946 | ||
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index e433ba97e..089b0da95 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c | |||
@@ -946,7 +946,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
946 | } | 946 | } |
947 | 947 | ||
948 | /* Free queue, but cls was freed by send_core_* */ | 948 | /* Free queue, but cls was freed by send_core_* */ |
949 | GMP_queue_destroy (queue, GNUNET_NO); | 949 | GMP_queue_destroy (queue, GNUNET_NO, GNUNET_YES); |
950 | 950 | ||
951 | /* If more data in queue, send next */ | 951 | /* If more data in queue, send next */ |
952 | queue = peer_get_first_message (peer); | 952 | queue = peer_get_first_message (peer); |
@@ -993,9 +993,10 @@ queue_send (void *cls, size_t size, void *buf) | |||
993 | * | 993 | * |
994 | * @param queue Queue handler to cancel. | 994 | * @param queue Queue handler to cancel. |
995 | * @param clear_cls Is it necessary to free associated cls? | 995 | * @param clear_cls Is it necessary to free associated cls? |
996 | * @param sent Was it really sent? (Could have been canceled) | ||
996 | */ | 997 | */ |
997 | void | 998 | void |
998 | GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls) | 999 | GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls, int sent) |
999 | { | 1000 | { |
1000 | struct MeshPeer *peer; | 1001 | struct MeshPeer *peer; |
1001 | 1002 | ||
@@ -1039,7 +1040,7 @@ GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls) | |||
1039 | { | 1040 | { |
1040 | LOG (GNUNET_ERROR_TYPE_DEBUG, "# Calling callback\n"); | 1041 | LOG (GNUNET_ERROR_TYPE_DEBUG, "# Calling callback\n"); |
1041 | queue->callback (queue->callback_cls, | 1042 | queue->callback (queue->callback_cls, |
1042 | queue->c, queue->type, | 1043 | queue->c, sent, queue->type, |
1043 | queue->fwd, queue->size, | 1044 | queue->fwd, queue->size, |
1044 | GNUNET_TIME_absolute_get_duration (queue->start_waiting)); | 1045 | GNUNET_TIME_absolute_get_duration (queue->start_waiting)); |
1045 | } | 1046 | } |
@@ -1137,11 +1138,16 @@ GMP_queue_add (struct MeshPeer *peer, void *cls, uint16_t type, size_t size, | |||
1137 | peer); | 1138 | peer); |
1138 | queue->start_waiting = GNUNET_TIME_absolute_get (); | 1139 | queue->start_waiting = GNUNET_TIME_absolute_get (); |
1139 | } | 1140 | } |
1141 | else if (GNUNET_NO == call_core) | ||
1142 | { | ||
1143 | LOG (GNUNET_ERROR_TYPE_DEBUG, "core tmt rdy towards %s not needed\n", | ||
1144 | GMP_2s (peer)); | ||
1145 | |||
1146 | } | ||
1140 | else | 1147 | else |
1141 | { | 1148 | { |
1142 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1149 | LOG (GNUNET_ERROR_TYPE_DEBUG, "core tmt rdy towards %s already called\n", |
1143 | "core tmt rdy towards %s already called\n", | 1150 | GMP_2s (peer)); |
1144 | GMP_2s (peer)); | ||
1145 | 1151 | ||
1146 | } | 1152 | } |
1147 | return queue; | 1153 | return queue; |
@@ -1168,7 +1174,7 @@ GMP_queue_cancel (struct MeshPeer *peer, struct MeshConnection *c) | |||
1168 | if (q->c == c) | 1174 | if (q->c == c) |
1169 | { | 1175 | { |
1170 | LOG (GNUNET_ERROR_TYPE_DEBUG, "GMP_cancel_queue %s\n", GM_m2s (q->type)); | 1176 | LOG (GNUNET_ERROR_TYPE_DEBUG, "GMP_cancel_queue %s\n", GM_m2s (q->type)); |
1171 | GMP_queue_destroy (q, GNUNET_YES); | 1177 | GMP_queue_destroy (q, GNUNET_YES, GNUNET_NO); |
1172 | 1178 | ||
1173 | /* Get next from prev, q->next might be already freed: | 1179 | /* Get next from prev, q->next might be already freed: |
1174 | * queue destroy -> callback -> GMC_destroy -> cancel_queues -> here | 1180 | * queue destroy -> callback -> GMC_destroy -> cancel_queues -> here |
@@ -1250,13 +1256,13 @@ GMP_connection_pop (struct MeshPeer *peer, struct MeshConnection *c) | |||
1250 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN: | 1256 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN: |
1251 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | 1257 | case GNUNET_MESSAGE_TYPE_MESH_ACK: |
1252 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | 1258 | case GNUNET_MESSAGE_TYPE_MESH_POLL: |
1253 | GMP_queue_destroy (q, GNUNET_YES); | 1259 | GMP_queue_destroy (q, GNUNET_YES, GNUNET_NO); |
1254 | continue; | 1260 | continue; |
1255 | 1261 | ||
1256 | case GNUNET_MESSAGE_TYPE_MESH_KX: | 1262 | case GNUNET_MESSAGE_TYPE_MESH_KX: |
1257 | case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: | 1263 | case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: |
1258 | msg = (struct GNUNET_MessageHeader *) q->cls; | 1264 | msg = (struct GNUNET_MessageHeader *) q->cls; |
1259 | GMP_queue_destroy (q, GNUNET_NO); | 1265 | GMP_queue_destroy (q, GNUNET_NO, GNUNET_NO); |
1260 | return msg; | 1266 | return msg; |
1261 | 1267 | ||
1262 | default: | 1268 | default: |
diff --git a/src/mesh/gnunet-service-mesh_peer.h b/src/mesh/gnunet-service-mesh_peer.h index 49bfd4050..dca31a94a 100644 --- a/src/mesh/gnunet-service-mesh_peer.h +++ b/src/mesh/gnunet-service-mesh_peer.h | |||
@@ -57,14 +57,15 @@ struct MeshPeerQueue; | |||
57 | * | 57 | * |
58 | * @param cls Closure. | 58 | * @param cls Closure. |
59 | * @param c Connection this message was on. | 59 | * @param c Connection this message was on. |
60 | * @param sent Was it really sent? (Could have been canceled) | ||
60 | * @param type Type of message sent. | 61 | * @param type Type of message sent. |
61 | * @param fwd Was this a FWD going message? | 62 | * @param fwd Was this a FWD going message? |
62 | * @param size Size of the message. | 63 | * @param size Size of the message. |
63 | * @param wait Time spent waiting for core (only the time for THIS message) | 64 | * @param wait Time spent waiting for core (only the time for THIS message) |
64 | */ | 65 | */ |
65 | typedef void (*GMP_sent) (void *cls, | 66 | typedef void (*GMP_sent) (void *cls, |
66 | struct MeshConnection *c, uint16_t type, | 67 | struct MeshConnection *c, int sent, |
67 | int fwd, size_t size, | 68 | uint16_t type, int fwd, size_t size, |
68 | struct GNUNET_TIME_Relative wait); | 69 | struct GNUNET_TIME_Relative wait); |
69 | 70 | ||
70 | /******************************************************************************/ | 71 | /******************************************************************************/ |
@@ -125,9 +126,10 @@ GMP_connect (struct MeshPeer *peer); | |||
125 | * | 126 | * |
126 | * @param queue Queue handler to cancel. | 127 | * @param queue Queue handler to cancel. |
127 | * @param clear_cls Is it necessary to free associated cls? | 128 | * @param clear_cls Is it necessary to free associated cls? |
129 | * @param sent Was it really sent? (Could have been canceled) | ||
128 | */ | 130 | */ |
129 | void | 131 | void |
130 | GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls); | 132 | GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls, int sent); |
131 | 133 | ||
132 | /** | 134 | /** |
133 | * @brief Queue and pass message to core when possible. | 135 | * @brief Queue and pass message to core when possible. |