use new MQ in_flight API to support cancel in new service/client implementations
authorChristian Grothoff <christian@grothoff.org>
Fri, 21 Oct 2016 05:13:17 +0000 (05:13 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 21 Oct 2016 05:13:17 +0000 (05:13 +0000)
src/util/client_new.c
src/util/service_new.c

index a5bd996bb9e35378f24a899919af0d38bb251646..b5c0147b3f99e831ad80a667e372ab0c610d1d32 100644 (file)
@@ -261,7 +261,7 @@ transmit_ready (void *cls)
   }
   if (0 == cstate->msg_off)
   {
-    // FIXME: tell MQ that cancel is no longer possible!
+    GNUNET_MQ_impl_send_in_flight (cstate->mq);
   }
   cstate->msg_off += pos;
   if (cstate->msg_off < len)
index 744adc387dff2f3324e899ba7f09aeb325b7d697..8433c42bff67600cfce72904451411d6f2e8e5aa 100644 (file)
@@ -1974,6 +1974,10 @@ do_send (void *cls)
       return;
     }
   }
+  if (0 == client->msg_pos)
+  {
+    GNUNET_MQ_impl_send_in_flight (client->mq);
+  }
   client->msg_pos += ret;
   if (left > ret)
   {
@@ -2026,9 +2030,10 @@ service_mq_cancel (struct GNUNET_MQ_Handle *mq,
 {
   struct GNUNET_SERVICE_Client *client = impl_state;
 
-  GNUNET_assert (0); // not implemented
-  // FIXME: stop transmission! (must be possible, otherwise
-  // we must have told MQ that the message was sent!)
+  GNUNET_assert (0 == client->msg_pos);
+  client->msg = NULL;
+  GNUNET_SCHEDULER_cancel (client->send_task);
+  client->send_task = NULL;
 }