static void
ats_suggest_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+
static void
reset_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct NeighbourMapEntry *n = cls;
n->state_reset = GNUNET_SCHEDULER_NO_TASK;
+ if (n->state == S_CONNECTED)
+ return;
#if DEBUG_TRANSPORT
-#endif
-
GNUNET_STATISTICS_update (GST_stats,
gettext_noop
("# failed connection attempts due to timeout"), 1,
GNUNET_NO);
+#endif
/* resetting state */
n->state = S_NOT_CONNECTED;
/* destroying address */
+
GNUNET_ATS_address_destroyed (GST_ats, n->address, n->session);
/* request new address */
struct NeighbourMapEntry *n = lookup_neighbour (&cc->address->peer);
if (GNUNET_YES != success)
- GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
- //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
+ GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
if ( (NULL == neighbours) ||
(NULL == n) ||
(n->state == S_DISCONNECT))
n->session);
#endif
change_state (n, S_NOT_CONNECTED);
- GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
- //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
+
+ GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->ats_suggest);
GNUNET_i2s (&n->id),
GST_plugins_a2s (n->address), n->session);
#endif
- GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
- //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
+ GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->ats_suggest);
cc->address,
cc->session,
GNUNET_YES);
+ GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0);
GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES);
n->address_state = USED;
}
cc->address,
cc->session,
GNUNET_YES);
+ GNUNET_ATS_address_update (GST_ats, cc->address, cc->session, NULL, 0);
GNUNET_ATS_address_in_use (GST_ats, cc->address, cc->session, GNUNET_YES);
n->address_state = USED;
}
#endif
change_state (n, S_NOT_CONNECTED);
- GNUNET_ATS_address_destroyed (GST_ats, cc->address, NULL);
- //GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
+ GNUNET_ATS_address_destroyed (GST_ats, cc->address, cc->session);
if (n->ats_suggest != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->ats_suggest);
}
}
-
- //GNUNET_ATS_address_destroyed(GST_ats, n->address, n->session);
-
if (NULL != n->address)
{
GNUNET_HELLO_address_free (n->address);
n->session = NULL;
/* not connected anymore anyway, shouldn't matter */
- if ((S_CONNECTED != n->state) && (!is_connecting (n)))
+ if (S_CONNECTED != n->state)
return;
/* connected, try fast reconnect */
if (n->latency.rel_value == GNUNET_TIME_relative_get_forever().rel_value)
+ {
GNUNET_ATS_address_update (GST_ats, n->address, n->session, ats, ats_count);
+ }
else
{
ats_new = GNUNET_malloc (sizeof (struct GNUNET_ATS_Information) * (ats_count + 1));
return;
}
+ change_state (n, S_CONNECTED);
+
if (NULL != session)
+ {
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"transport-ats",
"Giving ATS session %p of plugin %s for peer %s\n",
session, address->transport_name, GNUNET_i2s (peer));
+ }
GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
GNUNET_assert (NULL != n->address);
-
- change_state (n, S_CONNECTED);
if (n->address_state == FRESH)
{
GST_validation_set_address_use (&n->id,
GNUNET_NO);
return;
}
+ change_state (n, S_CONNECTED);
if (NULL != session)
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"transport-ats",
session, address->transport_name, GNUNET_i2s (peer));
GNUNET_ATS_address_update (GST_ats, address, session, ats, ats_count);
GNUNET_assert (n->address != NULL);
- change_state (n, S_CONNECTED);
-
- GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
- if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
- n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
if (n->address_state == FRESH)
{
GST_validation_set_address_use (&n->id,
GNUNET_ATS_address_in_use (GST_ats, n->address, n->session, GNUNET_YES);
n->address_state = USED;
}
+
neighbours_connected++;
GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
GNUNET_NO);
+ GST_neighbours_set_incoming_quota (&n->id, n->bandwidth_in);
+ if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
+ n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, n);
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Notify about connect of `%4s' using address '%s' session %X LINE %u\n",
bcc->session,
GST_plugins_a2s (bcc->address),
GNUNET_i2s (peer));
- GNUNET_ATS_address_update (GST_ats, bcc->address,
- bcc->session, bcc->ats, bcc->ats_count);
+ /* Tell ATS about the session, so ATS can suggest it if it likes it. */
+
+ GNUNET_ATS_address_update (GST_ats,
+ bcc->address,
+ bcc->session,
+ bcc->ats,
+ bcc->ats_count);
n->connect_ts = bcc->ts;
}