n->keepalive_task =
GNUNET_SCHEDULER_add_delayed (KEEPALIVE_FREQUENCY,
&neighbour_keepalive_task, n);
- GNUNET_assert (is_connected (n));
+ GNUNET_assert (S_CONNECTED == n->state);
GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# keepalives sent"), 1,
GNUNET_NO);
m.size = htons (sizeof (struct GNUNET_MessageHeader));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n",
GNUNET_i2s (&n->id), "SHUTDOWN_TASK");
#endif
- if (is_connected (n))
+ if (S_CONNECTED == n->state)
GNUNET_STATISTICS_update (GST_stats,
gettext_noop
("# peers disconnected due to global disconnect"),
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ATS tells us to switch to address '%s' session %p for %s peer `%s'\n",
GST_plugins_a2s (address),
- session, (is_connected (n) ? "CONNECTED" : "NOT CONNECTED"),
+ session, (S_CONNECTED == n->state) ? "CONNECTED" : "NOT CONNECTED",
GNUNET_i2s (peer));
#endif
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
if (n->state == S_CONNECTED)
{
/* mark old address as no longer used */
+ GNUNET_assert (NULL != n->address);
GST_validation_set_address_use (&n->id,
n->address,
n->session,
if (NULL != n)
{
- if ((is_connected (n)) || (is_connecting (n)))
+ if ((S_CONNECTED == n->state) || (is_connecting (n)))
return; /* already connecting or connected */
if (is_disconnecting (n))
change_state (n, S_NOT_CONNECTED);
n = lookup_neighbour (target);
- if ((NULL == n) || (!is_connected (n)))
+ if ((NULL == n) || (S_CONNECTED != n->state))
return GNUNET_NO; /* not connected */
return GNUNET_YES;
}
{
struct NeighbourMapEntry *n;
- // This can happen during shutdown
if (neighbours == NULL)
{
+ /* This can happen during shutdown */
return;
}
return;
if (session != n->session)
return; /* doesn't affect us */
-
+ if (n->state == S_CONNECTED)
+ GST_validation_set_address_use (&n->id,
+ n->address,
+ n->session,
+ GNUNET_NO);
n->session = NULL;
if (NULL != n->address)
{
GNUNET_HELLO_address_free (n->address);
n->address = NULL;
}
-
+
/* not connected anymore anyway, shouldn't matter */
- if ((!is_connected (n)) && (!is_connecting (n)))
+ if ((S_CONNECTED != n->state) && (!is_connecting (n)))
return;
+ // FIXME: n->state = S_FAST_RECONNECT;
/* We are connected, so ask ATS to switch addresses */
GNUNET_SCHEDULER_cancel (n->timeout_task);
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->ats_suggest);
n->ats_suggest =
- GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, ats_suggest_cancel,
+ GNUNET_SCHEDULER_add_delayed (ATS_RESPONSE_TIMEOUT, &ats_suggest_cancel,
n);
GNUNET_ATS_suggest_address (GST_ats, peer);
}
GNUNET_break (0);
return;
}
- if (is_connected (n))
+ if (S_CONNECTED == n->state)
return;
if (!is_connecting(n))
{
GNUNET_break_op (ntohl (scm->reserved) == 0);
n = lookup_neighbour (peer);
- if (n != NULL)
+ if ( (n != NULL) &&
+ (S_CONNECTED == n->state) )
{
/* connected peer switches addresses */
- if (is_connected (n))
- {
- GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
- return;
- }
+ GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
+ return;
}
/* we are not connected to this peer */