hacky fix for cadet issues
authorChristian Grothoff <christian@grothoff.org>
Wed, 29 Jun 2016 18:53:57 +0000 (18:53 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 29 Jun 2016 18:53:57 +0000 (18:53 +0000)
src/core/core_api.c
src/core/gnunet-service-core_clients.c

index 4c55d0e5f42c8b03308466d6c385d99ce71f2f90..061a929e0068d54586c55c355f8f3df57c52c58a 100644 (file)
@@ -411,7 +411,7 @@ handle_init_reply (void *cls,
  */
 static void
 handle_connect_notify (void *cls,
-                       const struct ConnectNotifyMessage * cnm)
+                       const struct ConnectNotifyMessage *cnm)
 {
   struct GNUNET_CORE_Handle *h = cls;
   struct PeerRecord *pr;
@@ -713,6 +713,18 @@ handle_send_ready (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Calling get_message with buffer of %u bytes\n",
               (unsigned int) th->msize);
+  /* FIXME: this is ugly and a bit brutal, but "get_message"
+     may call GNUNET_CORE_notify_transmit_ready() which
+     may call GNUNET_MQ_send() as well, and we MUST get this
+     message out before the next SEND_REQUEST.  So we queue
+     it (even though incomplete) and then---relying on MQ being
+     nice and not actually touching 'env' until much later---
+     fill it afterwards.  This is horrible style, and once
+     the core_api abandons GNUNET_CORE_notify_transmit_ready
+     in favor of an MQ-style API, this hack should no longer
+     be required */
+  GNUNET_MQ_send (h->mq,
+                  env);
   ret = th->get_message (th->get_message_cls,
                          th->msize,
                          &sm[1]);
@@ -737,8 +749,6 @@ handle_send_ready (void *cls,
          GNUNET_STRINGS_relative_time_to_string (delay,
                                                  GNUNET_YES),
          (th->cork) ? " (corked)" : "");
-  GNUNET_MQ_send (h->mq,
-                  env);
 }
 
 
@@ -838,13 +848,13 @@ reconnect (struct GNUNET_CORE_Handle *h)
  * @param inbound_notify function to call for all inbound messages, can be NULL
  * @param inbound_hdr_only set to #GNUNET_YES if inbound_notify will only read the
  *                GNUNET_MessageHeader and hence we do not need to give it the full message;
- *                can be used to improve efficiency, ignored if @a inbound_notify is NULLL
+ *                can be used to improve efficiency, ignored if @a inbound_notify is NULL
  * @param outbound_notify function to call for all outbound messages, can be NULL
  * @param outbound_hdr_only set to #GNUNET_YES if outbound_notify will only read the
  *                GNUNET_MessageHeader and hence we do not need to give it the full message
- *                can be used to improve efficiency, ignored if @a outbound_notify is NULLL
+ *                can be used to improve efficiency, ignored if @a outbound_notify is NULL
  * @param handlers callbacks for messages we care about, NULL-terminated
- * @return handle to the core service (only useful for disconnect until 'init' is called);
+ * @return handle to the core service (only useful for disconnect until @a init is called);
  *                NULL on error (in this case, init is never called)
  */
 struct GNUNET_CORE_Handle *
index c90b674e0372566a28ffc1a5b41c573449eacbfd..c2198848fea452ac4d67f65e7895cd8902bf0453 100644 (file)
@@ -401,7 +401,14 @@ handle_client_send_request (void *cls,
   {
     /* dequeue and recycle memory from pending request, there can only
        be at most one per client and peer */
+    GNUNET_STATISTICS_update (GSC_stats,
+                              gettext_noop
+                              ("# dequeuing CAR (duplicate request)"), 1,
+                              GNUNET_NO);
     GSC_SESSIONS_dequeue_request (car);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Transmission request to `%s' was a duplicate!\n",
+                GNUNET_i2s (&req->peer));
   }
   car->target = req->peer;
   car->received_time = GNUNET_TIME_absolute_get ();