#include "transport.h"
#include "transport-testing.h"
-#define VERBOSE GNUNET_EXTRA_LOGGING
-#define VERBOSE_ARM GNUNET_EXTRA_LOGGING
+#define VERBOSE GNUNET_NO
+#define VERBOSE_ARM GNUNET_NO
#define START_ARM GNUNET_YES
static int restarted;
#if VERBOSE
-#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
+#define OKPP do { ok++; FPRINTF (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
#else
#define OKPP do { ok++; } while (0)
#endif
reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct PeerContext *p = cls;
+
reconnect_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_TRANSPORT_try_connect (p1->th, &p2->id);
- reconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, &reconnect, p);
+ reconnect_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, p);
}
static void
restart_cb (struct PeerContext *p, void *cls)
{
static int c;
+
c++;
if (c != 2)
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Restarted peer %u (`%4s'), issuing reconnect\n",
- p->no,
+ "Restarted peer %u (`%4s'), issuing reconnect\n", p->no,
GNUNET_i2s (&p->id));
- reconnect_task = GNUNET_SCHEDULER_add_now(&reconnect, p);
+ reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, p);
}
-static
-void restart (struct PeerContext *p , char * cfg_file)
+static void
+restart (struct PeerContext *p, char *cfg_file)
{
GNUNET_assert (p != NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Restarting peer %u (`%4s')\n",
- p->no,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Restarting peer %u (`%4s')\n", p->no,
GNUNET_i2s (&p->id));
GNUNET_TRANSPORT_TESTING_restart_peer (tth, p, cfg_file, &restart_cb, p);
return;
t = p2;
GNUNET_assert (t != NULL);
- char *ps = strdup (GNUNET_i2s (&p->id));
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n",
p->no, ps, ntohs (message->type), ntohs (message->size), t->no,
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Restarted peers connected, stopping test...\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Restarted peers connected, stopping test...\n");
ok = 0;
end ();
}
hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
hdr->type = htons (MTYPE);
}
- char *ps = strdup (GNUNET_i2s (&p2->id));
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return;
- char *receiver_s = strdup (GNUNET_i2s (&p1->id));
+ char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending message from peer %u (`%4s') -> peer %u (`%s') !\n",
t = p2;
GNUNET_assert (t != NULL);
- char *ps = strdup (GNUNET_i2s (&p->id));
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps,
struct PeerContext *p = cls;
- char *ps = strdup (GNUNET_i2s (&p->id));
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps,
GNUNET_i2s (peer));
testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
{
cc = NULL;
- char *p1_c = strdup (GNUNET_i2s (&p1->id));
+ char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n",
p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
if (started != 2)
return;
- char *sender_c = strdup (GNUNET_i2s (&p1->id));
+ char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
tth = GNUNET_TRANSPORT_TESTING_init ();
-
- GNUNET_asprintf(&cfg_file_p1,"test_transport_api_tcp_peer1.conf");
- GNUNET_asprintf(&cfg_file_p2,"test_transport_api_tcp_peer2.conf");
-
+ GNUNET_asprintf (&cfg_file_p1, "test_transport_api_tcp_peer1.conf");
+ GNUNET_asprintf (&cfg_file_p2, "test_transport_api_tcp_peer2.conf");
ret = check ();
return ret;
}
+
/* end of test_transport_api_restart_2peers.c */