}
else if (get_prev_hop (c) == pi)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, " ACK\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " FINAL ACK\n");
fwd = GNUNET_YES;
connection_change_state (c, CADET_CONNECTION_READY);
}
struct CadetFlowControl *fc;
fc = fwd ? &c->fwd_fc : &c->bck_fc;
- if (GC_is_pid_bigger(fc->last_pid_recv, fc->last_ack_sent))
+ if (GC_is_pid_bigger (fc->last_pid_recv, fc->last_ack_sent))
{
return 0;
}
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS);
msg.destination = *peer;
msg.channels = htonl (GCT_count_channels (t));
- msg.connections = htonl (GCT_count_connections (t));
+ msg.connections = htonl (GCT_count_any_connections (t));
msg.cstate = htons ((uint16_t) GCT_get_cstate (t));
msg.estate = htons ((uint16_t) GCT_get_estate (t));
/* Initialize context */
ch_n = GCT_count_channels (t);
- c_n = GCT_count_connections (t);
+ c_n = GCT_count_any_connections (t);
size = sizeof (struct GNUNET_CADET_LocalInfoTunnel);
size += c_n * sizeof (struct GNUNET_CADET_Hash);
{
GCD_search_stop (peer->search_h);
peer->search_h = NULL;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- " Stopping DHT GET for peer %s\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " Stopping DHT GET for peer %s\n",
GCP_2s (peer));
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
" Starting DHT GET for peer %s\n", GCP_2s (peer));
peer->search_h = GCD_search (id, &search_handler, peer);
- if (CADET_TUNNEL_NEW == GCT_get_cstate (t))
+ if (CADET_TUNNEL_NEW == GCT_get_cstate (t)
+ || 0 == GCT_count_any_connections (t))
GCT_change_cstate (t, CADET_TUNNEL_SEARCHING);
}
}
&& CADET_TUNNEL_SHUTDOWN != t->cstate
&& GNUNET_NO == shutting_down)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, " no more connections, getting new ones\n");
- GCT_change_cstate (t, CADET_TUNNEL_SEARCHING);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " too few connections, getting new ones\n");
GCP_connect (t->peer);
return;
}
/**
- * Count created connections of a tunnel. Not necessarily ready connections!
+ * Count all created connections of a tunnel. Not necessarily ready connections!
*
* @param t Tunnel on which to count.
*
* @return Number of connections created, either being established or ready.
*/
unsigned int
+GCT_count_any_connections (struct CadetTunnel *t)
+{
+ struct CadetTConnection *iter;
+ unsigned int count;
+
+ if (NULL == t)
+ return 0;
+
+ for (count = 0, iter = t->connection_head; NULL != iter; iter = iter->next)
+ count++;
+
+ return count;
+}
+
+
+/**
+ * Count established (ready) connections of a tunnel.
+ *
+ * @param t Tunnel on which to count.
+ *
+ * @return Number of connections.
+ */
+unsigned int
GCT_count_connections (struct CadetTunnel *t)
{
struct CadetTConnection *iter;
return count;
}
+
/**
* Count channels of a tunnel.
*
CADET_TUNNEL_NEW,
/**
- * Path to the peer not known yet.
+ * No path to the peer known yet.
*/
CADET_TUNNEL_SEARCHING,
struct CadetConnection *
GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p);
+/**
+ * Count all created connections of a tunnel. Not necessarily ready connections!
+ *
+ * @param t Tunnel on which to count.
+ *
+ * @return Number of connections created, either being established or ready.
+ */
+unsigned int
+GCT_count_any_connections (struct CadetTunnel *t);
+
/**
* Count established (ready) connections of a tunnel.
*