* 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise
* messages may be dropped even for a reliable transport.
*/
-#define TOTAL_MSGS (10000 * 2)
+#define TOTAL_MSGS (1024 * 2)
/**
* How long until we give up on transmitting the message?
static int connected;
+static int test_failed;
+
static unsigned long long total_bytes;
static struct GNUNET_TIME_Absolute start_time;
static GNUNET_SCHEDULER_TaskIdentifier tct;
+struct GNUNET_TRANSPORT_TransmitHandle * th_p2;
+
static char * key_file_p1;
static char * cert_file_p1;
static int msg_recv_expected;
static int msg_recv;
+static int p1_hello_canceled;
+static int p2_hello_canceled;
+
#if VERBOSE
#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
#else
unsigned long long delta;
char *value_name;
- GNUNET_SCHEDULER_cancel (die_task);
+ if (die_task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_NO_TASK;
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
#endif
+
+ if (th_p2 != NULL)
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2);
+ th_p2 = NULL;
+
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_TRANSPORT_disconnect (p2.th);
#if VERBOSE
static void
end_badly (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n",
- msg_sent,
- msg_scheduled,
- msg_recv,
- msg_recv_expected);
+ if (test_failed == GNUNET_NO)
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Testcase timeout\n");
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n",
+ msg_sent,
+ msg_scheduled,
+ msg_recv,
+ msg_recv_expected);
+ if (th_p2 != NULL)
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2);
+ th_p2 = NULL;
+
GNUNET_break (0);
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_TRANSPORT_disconnect (p2.th);
}
+
struct TestMessage
{
struct GNUNET_MessageHeader header;
{
unsigned int ret;
- if (iter < 60000)
- return iter + sizeof (struct TestMessage);
ret = (iter * iter * iter);
return sizeof (struct TestMessage) + (ret % 60000);
}
n, s,
ntohs (message->size),
ntohl (hdr->num));
- GNUNET_SCHEDULER_cancel (die_task);
+ if (die_task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (die_task);
+ test_failed = GNUNET_YES;
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
return;
}
n, s,
ntohs (message->size),
ntohl (hdr->num));
- GNUNET_SCHEDULER_cancel (die_task);
+ if (die_task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (die_task);
+ test_failed = GNUNET_YES;
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Expected message %u with bits %u, but body did not match\n",
n, (unsigned char) n);
- GNUNET_SCHEDULER_cancel (die_task);
+ if (die_task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (die_task);
+ test_failed = GNUNET_YES;
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
return;
}
if (0 == (n % (TOTAL_MSGS/100)))
{
fprintf (stderr, ".");
- GNUNET_SCHEDULER_cancel (die_task);
+ if (die_task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
&end_badly,
NULL);
ok = 42;
return 0;
}
+ th_p2 = NULL;
ret = 0;
s = get_size (n);
GNUNET_assert (size >= s);
while (size - ret >= s);
if (n < TOTAL_MSGS)
{
- GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
+ if (th_p2 == NULL)
+ th_p2 = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
&p1.id,
s, 0, TIMEOUT,
¬ify_ready,
"Peer `%4s' disconnected (%p)!\n",
GNUNET_i2s (peer), cls);
#endif
+ if (th_p2 != NULL)
+ {
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel(th_p2);
+ th_p2 = NULL;
+ }
}
{
struct PeerContext *me = cls;
+ GNUNET_assert (message != NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Exchanging HELLO of size %d with peer (%s)!\n",
(int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
GNUNET_i2s (&me->id));
- GNUNET_assert (message != NULL);
GNUNET_assert (GNUNET_OK ==
GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
message, &me->id));
}
if (2 == connected)
{
- GNUNET_SCHEDULER_cancel (die_task);
- GNUNET_SCHEDULER_cancel (tct);
+ if (die_task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (die_task);
+ if (tct != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (tct);
tct = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ if (p2_hello_canceled == GNUNET_NO)
+ {
+ GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
+ p2_hello_canceled = GNUNET_YES;
+ }
+ if (p1_hello_canceled == GNUNET_NO)
+ {
+ GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ p1_hello_canceled = GNUNET_YES;
+ }
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
&end_badly, NULL);
- GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
+ th_p2 = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
&p1.id,
get_size (0), 0, TIMEOUT,
¬ify_ready,
p->cfg = GNUNET_CONFIGURATION_create ();
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
if (GNUNET_CONFIGURATION_have_value (p->cfg,"PATHS", "SERVICEHOME"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome);
- GNUNET_DISK_directory_remove (p->servicehome);
+ {
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (p->cfg,
+ "PATHS", "SERVICEHOME",
+ &p->servicehome));
+ GNUNET_DISK_directory_remove (p->servicehome);
+ }
#if START_ARM
p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
GNUNET_assert(p1.th != NULL);
GNUNET_assert(p2.th != NULL);
GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
+ p1_hello_canceled = GNUNET_NO;
GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
+ p2_hello_canceled = GNUNET_NO;
tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
}
GNUNET_free(key_file_p2);
GNUNET_free(cert_file_p1);
GNUNET_free(cert_file_p2);
- GNUNET_free(p1.servicehome);
- GNUNET_free(p2.servicehome);
}
return ok;
main (int argc, char *argv[])
{
int ret;
-#ifdef MINGW
- return GNUNET_SYSERR;
-#endif
+
+ test_failed = GNUNET_NO;
if (strstr(argv[0], "tcp_nat") != NULL)
{
#endif
NULL);
ret = check ();
- GNUNET_DISK_directory_remove (p1.servicehome);
- GNUNET_DISK_directory_remove (p2.servicehome);
+ if (p1.servicehome != NULL)
+ {
+ GNUNET_DISK_directory_remove (p1.servicehome);
+ GNUNET_free (p1.servicehome);
+ }
+ if (p2.servicehome != NULL)
+ {
+ GNUNET_DISK_directory_remove (p2.servicehome);
+ GNUNET_free (p2.servicehome);
+ }
return ret;
}