#include "gnunet_time_lib.h"
#include "peerinfo.h"
+#define LOG(kind,...) GNUNET_log_from (kind, "nse-api",__VA_ARGS__)
+
/**
* Function to call after transmission has succeeded.
*
* Task scheduled to re-try connecting to the peerinfo service.
*
* @param cls the 'struct GNUNET_PEERINFO_Handle'
- * @param ts scheduler context
+ * @param tc scheduler context
*/
static void
reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
return 0;
if (buf == NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
- _("Failed to transmit message to `%s' service.\n"), "PEERINFO");
+ LOG (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+ _("Failed to transmit message to `%s' service.\n"), "PEERINFO");
GNUNET_CONTAINER_DLL_remove (h->tq_head, h->tq_tail, tqe);
reconnect (h);
if (tqe->cont != NULL)
ret = tqe->size;
GNUNET_assert (size >= ret);
memcpy (buf, &tqe[1], ret);
-#if DEBUG_PEERINFO
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting request of size %u to `%s' service.\n", ret,
- "PEERINFO");
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting request of size %u to `%s' service.\n", ret, "PEERINFO");
GNUNET_CONTAINER_DLL_remove (h->tq_head, h->tq_tail, tqe);
if (tqe->cont != NULL)
tqe->cont (tqe->cont_cls, GNUNET_OK);
{
uint16_t hs = GNUNET_HELLO_size (hello);
struct TransmissionQueueEntry *tqe;
-
-#if DEBUG_PEERINFO
struct GNUNET_PeerIdentity peer;
GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_id (hello, &peer));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding peer `%s' to PEERINFO database (%u bytes of `%s')\n",
- GNUNET_i2s (&peer), hs, "HELLO");
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding peer `%s' to PEERINFO database (%u bytes of `%s')\n",
+ GNUNET_i2s (&peer), hs, "HELLO");
tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + hs);
tqe->size = hs;
tqe->timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
}
if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END)
{
-#if DEBUG_PEERINFO
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received end of list of peers from `%s' service\n",
- "PEERINFO");
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received end of list of peers from `%s' service\n", "PEERINFO");
trigger_transmit (ic->h);
if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (ic->timeout_task);
GNUNET_SCHEDULER_cancel (ic->timeout_task);
if (ic->callback != NULL)
ic->callback (ic->callback_cls, NULL, NULL,
- _("Received invalid message from `PEERINFO' service.\n"));
+ _("Received invalid message from `PEERINFO' service."));
GNUNET_free (ic);
return;
}
GNUNET_SCHEDULER_cancel (ic->timeout_task);
if (ic->callback != NULL)
ic->callback (ic->callback_cls, NULL, NULL,
- _("Received invalid message from `PEERINFO' service.\n"));
+ _("Received invalid message from `PEERINFO' service."));
GNUNET_free (ic);
return;
}
}
-#if DEBUG_PEERINFO
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received %u bytes of `%s' information about peer `%s' from `%s' service\n",
- (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello),
- "HELLO", GNUNET_i2s (&im->peer), "PEERINFO");
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received %u bytes of `%s' information about peer `%s' from `%s' service\n",
+ (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello), "HELLO",
+ GNUNET_i2s (&im->peer), "PEERINFO");
ic->h->in_receive = GNUNET_YES;
if (ic->callback != NULL)
ic->callback (ic->callback_cls, &im->peer, hello, NULL);
if (ic->callback != NULL)
ic->callback (ic->callback_cls, NULL, NULL,
_
- ("Failed to transmit iteration request to `PEERINFO' service\n"));
+ ("Failed to transmit iteration request to `PEERINFO' service"));
GNUNET_free (ic);
return;
}
-#if DEBUG_PEERINFO
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Waiting for response from `%s' service.\n", "PEERINFO");
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Waiting for response from `%s' service.\n",
+ "PEERINFO");
ic->h->in_receive = GNUNET_YES;
ic->in_receive = GNUNET_YES;
ic->tqe = NULL;
reconnect (ic->h);
ic->callback (ic->callback_cls, NULL, NULL,
_
- ("Timeout transmitting iteration request to `PEERINFO' service.\n"));
+ ("Timeout transmitting iteration request to `PEERINFO' service."));
ic->callback = NULL;
GNUNET_free_non_null (ic->tqe);
GNUNET_free (ic);
if (peer == NULL)
{
-#if DEBUG_PEERINFO
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Requesting list of peers from PEERINFO service\n");
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Requesting list of peers from PEERINFO service\n");
tqe =
GNUNET_malloc (sizeof (struct TransmissionQueueEntry) +
sizeof (struct GNUNET_MessageHeader));
}
else
{
-#if DEBUG_PEERINFO
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Requesting information on peer `%4s' from PEERINFO service\n",
- GNUNET_i2s (peer));
-#endif
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Requesting information on peer `%4s' from PEERINFO service\n",
+ GNUNET_i2s (peer));
tqe =
GNUNET_malloc (sizeof (struct TransmissionQueueEntry) +
sizeof (struct ListPeerMessage));
ic->timeout = GNUNET_TIME_relative_to_absolute (timeout);
ic->timeout_task =
GNUNET_SCHEDULER_add_delayed (timeout, &signal_timeout, ic);
- tqe->timeout = ic->timeout;
+ tqe->timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
tqe->cont = &iterator_start_receive;
tqe->cont_cls = ic;
- tqe->timeout = ic->timeout;
GNUNET_CONTAINER_DLL_insert_after (h->tq_head, h->tq_tail, h->tq_tail, tqe);
trigger_transmit (h);
return ic;