const struct GNUNET_PeerIdentity *target)
{
struct GNUNET_PeerIdentity *pid;
-
if (NULL == handle->client)
- return;
+ {
+ /* FIXME: handle->client can be NULL when transport api is reconnecting */
+ GNUNET_break (0);
+ return;
+ }
+
pid = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
*pid = *target;
schedule_control_transmit (handle,
struct GNUNET_MessageHeader *msg = shc->msg;
uint16_t ssize;
struct GNUNET_SCHEDULER_TaskContext tc;
+ tc.read_ready = NULL;
+ tc.write_ready = NULL;
+ tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT;
if (buf == NULL)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Timeout while trying to transmit `%s' request.\n", "HELLO");
- tc.read_ready = NULL;
- tc.write_ready = NULL;
- tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT;
- shc->cont (shc->cls, &tc);
+ if (NULL != shc->cont)
+ shc->cont (shc->cls, &tc);
GNUNET_free (msg);
GNUNET_free (shc);
return 0;
GNUNET_assert (size >= ssize);
memcpy (buf, msg, ssize);
GNUNET_free (msg);
- tc.read_ready = NULL;
- tc.write_ready = NULL;
tc.reason = GNUNET_SCHEDULER_REASON_READ_READY;
- shc->cont (shc->cls, &tc);
+ if (NULL != shc->cont)
+ shc->cont (shc->cls, &tc);
GNUNET_free (shc);
return ssize;
}
struct SendHelloContext * shc;
struct GNUNET_SCHEDULER_TaskContext tc;
+ tc.read_ready = NULL;
+ tc.write_ready = NULL;
+ tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT;
+
if (NULL == handle->client)
{
- tc.read_ready = NULL;
- tc.write_ready = NULL;
- tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT;
- cont (cls, &tc);
+ if (NULL != cont)
+ cont (cls, &tc);
return;
}
GNUNET_break (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO);
GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello, &peer))
{
GNUNET_break (0);
- tc.read_ready = NULL;
- tc.write_ready = NULL;
- tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT;
- cont (cls, &tc);
+ if (NULL != cont)
+ if (NULL != cont)
+ cont (cls, &tc);
return;
}
msg = GNUNET_malloc (size);
GNUNET_CONTAINER_multihashmap_create (STARTING_NEIGHBOURS_SIZE);
ret->ready_heap =
GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
- ret->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, ret);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service.\n");
+ ret->client = GNUNET_CLIENT_connect ("transport", cfg);
+ if (ret->client == NULL)
+ {
+ GNUNET_free (ret);
+ return NULL;
+ }
+ schedule_control_transmit (ret, sizeof (struct StartMessage), &send_start, ret);
return ret;
}