misc bugfixes
authorChristian Grothoff <christian@grothoff.org>
Sun, 22 Jan 2017 17:02:13 +0000 (18:02 +0100)
committerChristian Grothoff <christian@grothoff.org>
Sun, 22 Jan 2017 17:02:13 +0000 (18:02 +0100)
src/cadet/gnunet-service-cadet-new_channel.c
src/cadet/gnunet-service-cadet-new_connection.c
src/cadet/gnunet-service-cadet-new_paths.c
src/cadet/gnunet-service-cadet-new_peer.c
src/cadet/gnunet-service-cadet-new_tunnels.c

index c129022ca970b625e034644e7bd45d749adf1c96..d83bab280c6c2dc4ec18b7d3cff0a1e09e3d829b 100644 (file)
@@ -71,7 +71,7 @@ enum CadetChannelState
   /**
    * Connection create message sent, waiting for ACK.
    */
-  CADET_CHANNEL_CREATE_SENT,
+  CADET_CHANNEL_OPEN_SENT,
 
   /**
    * Connection confirmed, ready to carry traffic.
@@ -453,7 +453,7 @@ send_channel_open (void *cls)
   msgcc.opt = htonl (options);
   msgcc.port = ch->port;
   msgcc.ctn = ch->ctn;
-  ch->state = CADET_CHANNEL_CREATE_SENT;
+  ch->state = CADET_CHANNEL_OPEN_SENT;
   ch->last_control_qe = GCT_send (ch->t,
                                   &msgcc.header,
                                   &channel_open_sent_cb,
@@ -821,7 +821,7 @@ GCCH_handle_channel_open_ack (struct CadetChannel *ch)
     /* this should be impossible */
     GNUNET_break (0);
     break;
-  case CADET_CHANNEL_CREATE_SENT:
+  case CADET_CHANNEL_OPEN_SENT:
     if (NULL == ch->owner)
     {
       /* We're not the owner, wrong direction! */
index 01fb100c8b6447efddd794fce2f392a784b7ad80..c44511400933547062b3d5b0851e6022ff498a44 100644 (file)
@@ -176,6 +176,11 @@ GCC_destroy (struct CadetConnection *cc)
   GCP_request_mq_cancel (cc->mq_man,
                          env);
   cc->mq_man = NULL;
+  if (NULL != cc->task)
+  {
+    GNUNET_SCHEDULER_cancel (cc->task);
+    cc->task = NULL;
+  }
   GCPP_del_connection (cc->path,
                        cc->off,
                        cc);
@@ -329,6 +334,7 @@ send_create_ack (void *cls)
   struct GNUNET_MQ_Envelope *env;
 
   cc->task = NULL;
+  GNUNET_assert (CADET_CONNECTION_CREATE_RECEIVED == cc->state);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Sending CONNECTION_CREATE_ACK message for %s\n",
        GCC_2s (cc));
@@ -357,8 +363,9 @@ GCC_handle_duplicate_create (struct CadetConnection *cc)
   if (GNUNET_YES == cc->mqm_ready)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Got duplicate CREATE for %s, scheduling another ACK\n",
-         GCC_2s (cc));
+         "Got duplicate CREATE for %s, scheduling another ACK (%s)\n",
+         GCC_2s (cc),
+         (GNUNET_YES == cc->mqm_ready) ? "MQM ready" : "MQM busy");
     /* Tell tunnel that we are not ready for transmission anymore
        (until CREATE_ACK is done) */
     cc->ready_cb (cc->ready_cb_cls,
@@ -366,6 +373,8 @@ GCC_handle_duplicate_create (struct CadetConnection *cc)
     /* Revert back to the state of having only received the 'CREATE',
        and immediately proceed to send the CREATE_ACK. */
     cc->state = CADET_CONNECTION_CREATE_RECEIVED;
+    if (NULL != cc->task)
+      GNUNET_SCHEDULER_cancel (cc->task);
     cc->task = GNUNET_SCHEDULER_add_now (&send_create_ack,
                                          cc);
   }
index c9fdbcb3a47afb586ed87b96a80510a662ebb668..86424968cbf37feab1c767fe4ef69343b184ae8b 100644 (file)
@@ -535,7 +535,7 @@ GCPP_try_path_from_dht (const struct GNUNET_PeerIdentity *get_path,
   /* Shrink path to actual useful length */
   GNUNET_array_grow (path->entries,
                      path->entries_length,
-                     i);
+                     i + 1);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Created new path %s based on information from DHT\n",
        GCPP_2s (path));
index f824caee662a860f21efb64f669a265825a04c05..fe40d76b65c51d23ac55bd6580e8ba6f8e5d83a7 100644 (file)
@@ -668,6 +668,8 @@ GCP_path_entry_add (struct CadetPeer *cp,
                     struct CadetPeerPathEntry *entry,
                     unsigned int off)
 {
+  GNUNET_assert (cp == GCPP_get_peer_at_offset (entry->path,
+                                                off));
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Discovered that peer %s is on path %s at offset %u\n",
        GCP_2s (cp),
@@ -759,6 +761,8 @@ GCP_attach_path (struct CadetPeer *cp,
   GNUNET_CONTAINER_HeapCostType root_desirability;
   struct GNUNET_CONTAINER_HeapNode *hn;
 
+  GNUNET_assert (cp == GCPP_get_peer_at_offset (path,
+                                                off));
   if (NULL == cp->path_heap)
   {
     /* #GCP_drop_owned_paths() was already called, we cannot take new ones! */
index 58486dce5668e9288482035da96723f4d61c4941..e5fb91f44a956f32fb05751fea2ca117ef815dc4 100644 (file)
@@ -1279,6 +1279,7 @@ send_kx (struct CadetTunnel *t,
                                       &msg->ephemeral_key);
   GNUNET_CRYPTO_ecdhe_key_get_public (ax->DHRs,
                                       &msg->ratchet_key);
+  ct->is_ready = GNUNET_NO;
   GCC_transmit (cc,
                 env);
   t->kx_retry_delay = GNUNET_TIME_STD_BACKOFF (t->kx_retry_delay);
@@ -1540,7 +1541,11 @@ destroy_tunnel (void *cls)
     GNUNET_free (ct);
   }
   while (NULL != (tq = t->tq_head))
+  {
+    if (NULL != tq->cont)
+      tq->cont (tq->cont_cls);
     GCT_send_cancel (tq);
+  }
   GCP_drop_tunnel (t->destination,
                    t);
   GNUNET_CONTAINER_multihashmap32_destroy (t->channels);
@@ -2163,36 +2168,35 @@ decrypted_error_cb (void *cls,
 struct CadetTunnel *
 GCT_create_tunnel (struct CadetPeer *destination)
 {
+  struct CadetTunnel *t = GNUNET_new (struct CadetTunnel);
   struct GNUNET_MQ_MessageHandler handlers[] = {
     GNUNET_MQ_hd_fixed_size (plaintext_keepalive,
                              GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE,
                              struct GNUNET_MessageHeader,
-                             NULL),
+                             t),
     GNUNET_MQ_hd_var_size (plaintext_data,
                            GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA,
                            struct GNUNET_CADET_ChannelAppDataMessage,
-                           NULL),
+                           t),
     GNUNET_MQ_hd_fixed_size (plaintext_data_ack,
                              GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK,
                              struct GNUNET_CADET_ChannelDataAckMessage,
-                             NULL),
+                             t),
     GNUNET_MQ_hd_fixed_size (plaintext_channel_open,
                              GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN,
                              struct GNUNET_CADET_ChannelOpenMessage,
-                             NULL),
+                             t),
     GNUNET_MQ_hd_fixed_size (plaintext_channel_open_ack,
                              GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK,
                              struct GNUNET_CADET_ChannelManageMessage,
-                             NULL),
+                             t),
     GNUNET_MQ_hd_fixed_size (plaintext_channel_destroy,
                              GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY,
                              struct GNUNET_CADET_ChannelManageMessage,
-                             NULL),
+                             t),
     GNUNET_MQ_handler_end ()
   };
-  struct CadetTunnel *t;
 
-  t = GNUNET_new (struct CadetTunnel);
   new_ephemeral (t);
   t->ax.kx_0 = GNUNET_CRYPTO_ecdhe_key_create ();
   t->destination = destination;