aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-09 07:31:49 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-09 07:31:49 +0100
commit71c1409cfbe726f7e8b4e33fed784c8896bc0fcd (patch)
treec037c9aca8403ce6f823af61bd119a92d313680a
parent1f7e0c6ec773642c25aed5411c3498d4979776d2 (diff)
downloadgnunet-71c1409cfbe726f7e8b4e33fed784c8896bc0fcd.tar.gz
gnunet-71c1409cfbe726f7e8b4e33fed784c8896bc0fcd.zip
properly handle case of should-drop by asynchronously running continuation
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index f149fd31f..c3701a39e 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -73,6 +73,11 @@ struct CadetPeerQueue {
73 void *cont_cls; 73 void *cont_cls;
74 74
75 /** 75 /**
76 * Task to asynchronously run the drop continuation.
77 */
78 struct GNUNET_SCHEDULER_Task *drop_task;
79
80 /**
76 * Time when message was queued for sending. 81 * Time when message was queued for sending.
77 */ 82 */
78 struct GNUNET_TIME_Absolute queue_timestamp; 83 struct GNUNET_TIME_Absolute queue_timestamp;
@@ -1132,6 +1137,22 @@ mq_sent (void *cls)
1132 1137
1133 1138
1134/** 1139/**
1140 * Finish the drop operation.
1141 *
1142 * @param cls queue entry to finish drop for
1143 */
1144static void
1145drop_cb (void *cls)
1146{
1147 struct CadetPeerQueue *q = cls;
1148
1149 GNUNET_MQ_discard (q->env);
1150 call_peer_cont (q, GNUNET_YES);
1151 GNUNET_free (q);
1152}
1153
1154
1155/**
1135 * @brief Send a message to another peer (using CORE). 1156 * @brief Send a message to another peer (using CORE).
1136 * 1157 *
1137 * @param peer Peer towards which to queue the message. 1158 * @param peer Peer towards which to queue the message.
@@ -1206,10 +1227,9 @@ GCP_send (struct CadetPeer *peer,
1206 LOG (GNUNET_ERROR_TYPE_WARNING, "DD %s (%s %u) on conn %s %s\n", 1227 LOG (GNUNET_ERROR_TYPE_WARNING, "DD %s (%s %u) on conn %s %s\n",
1207 GC_m2s (q->type), GC_m2s (q->payload_type), 1228 GC_m2s (q->type), GC_m2s (q->payload_type),
1208 q->payload_id, GCC_2s (c), GC_f2s (q->c_fwd)); 1229 q->payload_id, GCC_2s (c), GC_f2s (q->c_fwd));
1209 GNUNET_MQ_discard (q->env); 1230 q->drop_task = GNUNET_SCHEDULER_add_now (&drop_cb,
1210 call_peer_cont (q, GNUNET_YES); 1231 q);
1211 GNUNET_free (q); 1232 return q;
1212 return NULL;
1213 } 1233 }
1214 GNUNET_MQ_send (peer->core_mq, q->env); 1234 GNUNET_MQ_send (peer->core_mq, q->env);
1215 peer->queue_n++; 1235 peer->queue_n++;
@@ -1232,9 +1252,18 @@ GCP_send (struct CadetPeer *peer,
1232void 1252void
1233GCP_send_cancel (struct CadetPeerQueue *q) 1253GCP_send_cancel (struct CadetPeerQueue *q)
1234{ 1254{
1235 call_peer_cont (q, GNUNET_NO); 1255 if (NULL != q->drop_task)
1256 {
1257 GNUNET_SCHEDULER_cancel (q->drop_task);
1258 q->drop_task = NULL;
1259 GNUNET_MQ_discard (q->env);
1260 }
1261 else
1262 {
1236 GNUNET_MQ_send_cancel (q->env); 1263 GNUNET_MQ_send_cancel (q->env);
1237 GNUNET_free (q); 1264 }
1265 call_peer_cont (q, GNUNET_NO);
1266 GNUNET_free (q);
1238} 1267}
1239 1268
1240 1269