call receive only after sending INIT
authorChristian Grothoff <christian@grothoff.org>
Thu, 13 Oct 2011 20:07:05 +0000 (20:07 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 13 Oct 2011 20:07:05 +0000 (20:07 +0000)
src/ats/ats_api_scheduling.c

index 6c4441d81ed1127a469a0829f427c8f1fcb0827e..53a21f996d40c3ee2875b267b0a865cba2b5babc 100644 (file)
@@ -156,6 +156,18 @@ static void
 do_transmit (struct GNUNET_ATS_SchedulingHandle *sh);
 
 
+/**
+ * Type of a function to call when we receive a message
+ * from the service.
+ *
+ * @param cls the 'struct GNUNET_ATS_SchedulingHandle'
+ * @param msg message received, NULL on timeout or fatal error
+ */
+static void
+process_ats_message (void *cls,
+                    const struct GNUNET_MessageHeader *msg);
+
+
 /**
  * We can now transmit a message to ATS. Do it.
  *
@@ -186,6 +198,10 @@ transmit_message_to_ats (void *cls,
     GNUNET_CONTAINER_DLL_remove (sh->pending_head,
                                 sh->pending_tail,
                                 p);
+    if (GNUNET_YES == p->is_init)
+      GNUNET_CLIENT_receive (sh->client,
+                            &process_ats_message, sh,
+                            GNUNET_TIME_UNIT_FOREVER_REL);
     GNUNET_free (p);
   }
   do_transmit (sh);
@@ -376,9 +392,6 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh)
   GNUNET_assert (NULL == sh->client);
   sh->client = GNUNET_CLIENT_connect ("ats", sh->cfg);
   GNUNET_assert (NULL != sh->client);
-  GNUNET_CLIENT_receive (sh->client,
-                        &process_ats_message, sh,
-                        GNUNET_TIME_UNIT_FOREVER_REL);
   if ( (NULL == (p = sh->pending_head)) ||
        (GNUNET_YES != p->is_init) )
   {