-fix time assertion introduce in last patch
[oweals/gnunet.git] / src / transport / gnunet-service-transport_neighbours.c
index 16826e957e08a6b490dbd1be7b24d4f3038824ae..6c51d20d838ac530f1bd82bbeb877f73780610b5 100644 (file)
@@ -1719,7 +1719,6 @@ send_session_connect_cont (void *cls,
         GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
     break;
   default:
-    GNUNET_break(0);
     disconnect_neighbour (n);
     break;
   }
@@ -1805,7 +1804,6 @@ send_session_connect (struct NeighbourAddress *na)
           GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
         break;
       default:
-        GNUNET_break (0);
         disconnect_neighbour (n);
         break;
     }
@@ -2338,7 +2336,7 @@ GST_neighbours_handle_connect (const struct GNUNET_MessageHeader *message,
   n->ack_state = ACK_SEND_CONNECT_ACK;
   n->connect_ack_timestamp = ts;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Received CONNECT for peer `%s' in state %s/%s\n",
               GNUNET_i2s (peer),
               GNUNET_TRANSPORT_ps2s (n->state),
@@ -3201,7 +3199,6 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
     set_primary_address (n, n->alternative_address.address,
         n->alternative_address.session, n->alternative_address.bandwidth_in,
         n->alternative_address.bandwidth_out, GNUNET_YES);
-
     GNUNET_STATISTICS_update (GST_stats, gettext_noop
         ("# Successful attempts to switch addresses"), 1, GNUNET_NO);
 
@@ -3389,7 +3386,7 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
 {
   struct NeighbourMapEntry *n;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Received SESSION_ACK message from peer `%s'\n",
               GNUNET_i2s (peer));
   if (ntohs (message->size) != sizeof (struct GNUNET_MessageHeader))
@@ -3406,6 +3403,14 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
   }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Received %s for peer `%s' in state %s/%s\n",
+              "SESSION_ACK",
+              GNUNET_i2s (peer),
+              GNUNET_TRANSPORT_ps2s (n->state),
+              print_ack_state (n->ack_state));
+
   /* Check if we are in a plausible state for having sent
      a CONNECT_ACK.  If not, return, otherwise break.
 
@@ -3446,8 +3451,16 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message,
                             GNUNET_NO);
   }
 
+  if (GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT == n->state)
+  {
+    /* We tried to switch addresses while being connect. We explicitly wait
+     * for a CONNECT_ACK before going to GNUNET_TRANSPORT_PS_CONNECTED,
+     * so we do not want to set the address as in use! */
+    return GNUNET_OK;
+  }
+
   set_state_and_timeout (n, GNUNET_TRANSPORT_PS_CONNECTED,
-      GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
+    GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT));
 
   /* Add session to ATS since no session was given (NULL) and we may have
    * obtained a new session */