/*
This file is part of GNUnet.
- Copyright (C) 2010,2011 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2010,2011 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
* @file ats/ats_api_performance.c
* Request multiplexing
*/
uint32_t id;
+
+ /**
+ * Is the receive loop active?
+ */
+ int in_receive;
};
/**
* Re-establish the connection to the ATS service.
*
* @param cls handle to use to re-connect.
- * @param tc scheduler context
*/
static void
-reconnect_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+reconnect_task (void *cls)
{
struct GNUNET_ATS_PerformanceHandle *ph = cls;
GNUNET_free(p);
}
do_transmit (ph);
+ if (GNUNET_NO == ph->in_receive)
+ {
+ ph->in_receive = GNUNET_YES;
+ GNUNET_CLIENT_receive (ph->client,
+ &process_ats_message,
+ ph,
+ GNUNET_TIME_UNIT_FOREVER_REL);
+ }
return ret;
}
GNUNET_ATS_properties_ntoh (&prop,
&pi->properties);
address.peer = pi->peer;
+ address.local_info = (enum GNUNET_HELLO_AddressInfo) ntohl (pi->address_local_info);
address.address = plugin_address;
address.address_length = plugin_address_length;
address.transport_name = plugin_name;
/**
- * We received a reservation result message. Validate and process it.
+ * We received a PeerInformationMessage. Validate and process it.
*
* @param ph our context with the callback
* @param msg the message
{
case GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION:
if (GNUNET_OK != process_pi_message (ph, msg))
+ {
+ GNUNET_break (0);
goto reconnect;
+ }
break;
case GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT:
if (GNUNET_OK != process_rr_message (ph, msg))
+ {
+ GNUNET_break (0);
goto reconnect;
+ }
break;
case GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE:
if (GNUNET_OK != process_ar_message (ph, msg))
+ {
+ GNUNET_break (0);
goto reconnect;
+ }
break;
default:
- GNUNET_break(0);
+ GNUNET_break (0);
goto reconnect;
}
ph->backoff = GNUNET_TIME_UNIT_ZERO;
GNUNET_CLIENT_notify_transmit_ready_cancel (ph->th);
ph->th = NULL;
}
- GNUNET_CLIENT_disconnect (ph->client);
- ph->client = NULL;
- if (NULL != ph->addr_info_cb)
+ if (NULL != ph->client)
{
- /* Indicate reconnect */
- ph->addr_info_cb (ph->addr_info_cb_cls,
- NULL,
- GNUNET_NO,
- GNUNET_BANDWIDTH_value_init (0),
- GNUNET_BANDWIDTH_value_init (0),
- NULL);
+ GNUNET_CLIENT_disconnect (ph->client);
+ ph->client = NULL;
+ ph->in_receive = GNUNET_NO;
+ if (NULL != ph->addr_info_cb)
+ {
+ /* Indicate reconnect */
+ ph->addr_info_cb (ph->addr_info_cb_cls,
+ NULL,
+ GNUNET_NO,
+ GNUNET_BANDWIDTH_value_init (0),
+ GNUNET_BANDWIDTH_value_init (0),
+ NULL);
+ }
}
ph->backoff = GNUNET_TIME_STD_BACKOFF (ph->backoff);
ph->task = GNUNET_SCHEDULER_add_delayed (ph->backoff,
ph->client = GNUNET_CLIENT_connect ("ats",
ph->cfg);
GNUNET_assert (NULL != ph->client);
- GNUNET_CLIENT_receive (ph->client,
- &process_ats_message,
- ph,
- GNUNET_TIME_UNIT_FOREVER_REL);
if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init))
{
p = GNUNET_malloc (sizeof (struct PendingMessage) +