-makefile for new test_stream_local (commented)
[oweals/gnunet.git] / src / transport / gnunet-service-transport_validation.c
index b631d8fdfb3ced87bfe4e3b8b5d0b24b432027ae..99db005618cc85081f3587f6e55ba033fa664bde 100644 (file)
@@ -251,6 +251,10 @@ struct ValidationEntry
    * Are we expecting a PONG message for this validation entry?
    */
   int expecting_pong;
+
+  /* FIXME: DEBUGGING */
+  int last_line_set_to_no;
+  int last_line_set_to_yes;
 };
 
 
@@ -494,9 +498,8 @@ transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid,
       else
       {
         /* Could not get a valid session */
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not get a valid session for `%s' %s\n",
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Could not get a valid session for `%s' %s\n",
                     GNUNET_i2s (pid), GST_plugins_a2s (ve->address));
-        GNUNET_break (0);
         ret = -1;
       }
     }
@@ -601,6 +604,9 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
   if (public_key == NULL)
     return NULL;
   ve = GNUNET_malloc (sizeof (struct ValidationEntry));
+  ve->in_use = GNUNET_SYSERR; /* not defined */
+  ve->last_line_set_to_no  = 0;
+  ve->last_line_set_to_yes  = 0;
   ve->address = GNUNET_HELLO_address_copy (address);
   ve->public_key = *public_key;
   ve->pid = address->peer;
@@ -880,6 +886,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
   }
   pong->signature = *sig_cache;
 
+  GNUNET_assert (sender_address != NULL);
+
   /* first see if the session we got this PING from can be used to transmit
    * a response reliably */
   papi = GST_plugins_find (sender_address->transport_name);
@@ -890,7 +898,7 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender,
     GNUNET_assert (papi->send != NULL);
     GNUNET_assert (papi->get_session != NULL);
 
-    if ((session == NULL) && (sender_address != NULL))
+    if (session == NULL)
     {
       session = papi->get_session (papi->cls, sender_address);
     }
@@ -1210,11 +1218,13 @@ GST_validation_get_addresses (const struct GNUNET_PeerIdentity *target,
  * @param session the session
  * @param in_use GNUNET_YES if we are now using the address for a connection,
  *               GNUNET_NO if we are no longer using the address for a connection
+ * @param line line of caller just for DEBUGGING!
  */
 void
 GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
                                 struct Session *session,
-                                int in_use)
+                                int in_use,
+                                int line)
 {
   struct ValidationEntry *ve;
 
@@ -1228,10 +1238,33 @@ GST_validation_set_address_use (const struct GNUNET_HELLO_Address *address,
     return;
   }
   if (ve->in_use == in_use)
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "GST_validation_set_address_use: %s %s: ve->in_use %i <-> in_use %i\n",
-                GNUNET_i2s (&address->peer), GST_plugins_a2s (address), ve->in_use,
-                in_use);
+  {
+
+    if (GNUNET_YES == in_use)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Error setting address in use for peer `%s' `%s' to USED: set last time by %i, called now by %i\n",
+                  GNUNET_i2s (&address->peer), GST_plugins_a2s (address),
+                  ve->last_line_set_to_yes, line);
+    }
+    if (GNUNET_NO == in_use)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Error setting address in use for peer `%s' `%s' to NOT_USED: set last time by %i, called now by %i\n",
+                  GNUNET_i2s (&address->peer), GST_plugins_a2s (address),
+                  ve->last_line_set_to_no, line);
+    }
+  }
+
+  if (GNUNET_YES == in_use)
+  {
+    ve->last_line_set_to_yes = line;
+  }
+  if (GNUNET_NO == in_use)
+  {
+    ve->last_line_set_to_no = line;
+  }
+
   GNUNET_break (ve->in_use != in_use);  /* should be different... */
   ve->in_use = in_use;
   if (in_use == GNUNET_YES)