/*
This file is part of GNUnet.
- Copyright (C) 2011-2015 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2011-2015 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
*/
static struct GNUNET_PeerIdentity pid;
-/**
- * Task scheduled for cleanup / termination of the process.
- */
-static struct GNUNET_SCHEDULER_Task * end;
-
/**
* Selected level of verbosity.
*/
* Stops monitoring activity.
*
* @param cls NULL
- * @param tc scheduler context
*/
static void
-shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
{
struct Iteration *icur;
struct Iteration *inext;
avg_duration += icur->dur.rel_value_us / (1000);
avg_rate += icur->rate;
- iterations ++;
+ iterations++;
}
-
+ if (0 == iterations)
+ iterations = 1; /* avoid division by zero */
/* Calculate average rate */
avg_rate /= iterations;
/* Calculate average duration */
stddev_duration = sqrtf(stddev_duration);
/* Output */
- FPRINTF (stdout, _("%u;%u;%llu;%llu;%.2f;%.2f"),benchmark_count, benchmark_size,
- avg_duration, (unsigned long long) stddev_duration, avg_rate, stddev_rate);
+ FPRINTF (stdout,
+ "%u;%u;%llu;%llu;%.2f;%.2f",
+ benchmark_count,
+ benchmark_size,
+ avg_duration,
+ (unsigned long long) stddev_duration,
+ avg_rate,
+ stddev_rate);
inext = ihead;
while (NULL != (icur = inext))
{
inext = icur->next;
- GNUNET_CONTAINER_DLL_remove (ihead, itail, icur);
+ GNUNET_CONTAINER_DLL_remove (ihead,
+ itail,
+ icur);
- FPRINTF (stdout, _(";%llu;%.2f"),
- (long long unsigned int) (icur->dur.rel_value_us / 1000), icur->rate);
+ FPRINTF (stdout,
+ ";%llu;%.2f",
+ (long long unsigned int) (icur->dur.rel_value_us / 1000),
+ icur->rate);
GNUNET_free (icur);
}
{
duration = GNUNET_TIME_absolute_get_duration (start_time);
FPRINTF (stdout,
- _("Received %llu bytes/s (%llu bytes in %s)\n"),
+ "Received %llu bytes/s (%llu bytes in %s)\n",
1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
traffic_received,
GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
}
#endif
- FPRINTF (stdout, _("\n"));
+ FPRINTF (stdout, "\n");
}
static void
}
if (verbosity > 0)
if (itail->msgs_sent % 10 == 0 )
- FPRINTF (stdout, _("."));
+ FPRINTF (stdout, ".");
return size;
}
if (verbosity > 0)
FPRINTF (stdout,
- _("\nStarting benchmark to `%s', starting to send %u messages in %u byte blocks\n"),
- GNUNET_i2s (&pid), benchmark_count, benchmark_size);
+ "\nStarting benchmark to `%s', starting to send %u messages in %u byte blocks\n",
+ GNUNET_i2s (&pid),
+ benchmark_count,
+ benchmark_size);
if (NULL == th)
th = GNUNET_TRANSPORT_notify_transmit_ready (handle, &pid, benchmark_size,
GNUNET_TIME_UNIT_FOREVER_REL, &transmit_data, NULL );
if (it_count == benchmark_iterations)
{
benchmark_running = GNUNET_NO;
- if (NULL != end)
- GNUNET_SCHEDULER_cancel (end);
- end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+ GNUNET_SCHEDULER_shutdown ();
return;
}
else
sizeof(struct GNUNET_PeerIdentity)))
{
FPRINTF (stdout,
- _("Connected to different peer `%s'\n"),
+ "Connected to different peer `%s'\n",
GNUNET_i2s (&pid));
return;
}
if (verbosity > 0)
FPRINTF (stdout,
- _("Successfully connected to `%s'\n"),
- GNUNET_i2s (&pid));
+ "Successfully connected to `%s'\n",
+ GNUNET_i2s (&pid));
iteration_start ();
}
return;
if (GNUNET_YES == benchmark_running)
{
- FPRINTF (stdout, _("Disconnected from peer `%s' while benchmarking\n"),
+ FPRINTF (stdout,
+ "Disconnected from peer `%s' while benchmarking\n",
GNUNET_i2s (&pid));
return;
}
return;
if (verbosity > 0)
FPRINTF (stdout,
- _("Received %u bytes from %s\n"),
+ "Received %u bytes from %s\n",
(unsigned int) ntohs (message->size),
GNUNET_i2s (peer));
return;
{
if (verbosity > 0)
FPRINTF (stdout,
- _("Denying connection to `%s'\n"),
+ "Denying connection to `%s'\n",
GNUNET_i2s (peer));
return GNUNET_SYSERR;
}
if (GNUNET_YES != result)
{
- FPRINTF (stderr, _("Service `%s' is not running\n"), "transport");
+ FPRINTF (stderr,
+ "TRANSPORT service is not running\n");
return;
}
if (GNUNET_SERVER_MAX_MESSAGE_SIZE <= benchmark_size)
{
- FPRINTF (stderr, _("Message size too big!\n"));
+ FPRINTF (stderr,
+ "Message size too big!\n");
return;
}
if (NULL == cpid)
{
- FPRINTF (stderr, _("No peer identity given\n"));
+ FPRINTF (stderr,
+ "No peer identity given\n");
return;
}
if ((GNUNET_OK !=
GNUNET_CRYPTO_eddsa_public_key_from_string (cpid, strlen (cpid),
&pid.public_key)))
{
- FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), cpid);
+ FPRINTF (stderr,
+ "Failed to parse peer identity `%s'\n",
+ cpid);
return;
}
{
if (verbosity > 0)
FPRINTF (stderr,
- _("Trying to send %u messages with size %u to peer `%s'\n"),
- benchmark_count, benchmark_size, GNUNET_i2s (&pid));
+ "Trying to send %u messages with size %u to peer `%s'\n",
+ benchmark_count, benchmark_size,
+ GNUNET_i2s (&pid));
}
else if (1 == benchmark_receive)
{
FPRINTF (stderr,
- _("Trying to receive messages from peer `%s'\n"),
- GNUNET_i2s (&pid));
+ "Trying to receive messages from peer `%s'\n",
+ GNUNET_i2s (&pid));
}
else
{
- FPRINTF (stderr, _("No operation given\n"));
+ FPRINTF (stderr,
+ "No operation given\n");
return;
}
ats = GNUNET_ATS_connectivity_init (cfg);
if (NULL == ats)
{
- FPRINTF (stderr, "%s", _("Failed to connect to ATS service\n"));
+ FPRINTF (stderr,
+ "Failed to connect to ATS service\n");
ret = 1;
return;
}
¬ify_disconnect);
if (NULL == handle)
{
- FPRINTF (stderr, "%s", _("Failed to connect to transport service\n"));
+ FPRINTF (stderr,
+ "Failed to connect to transport service\n");
GNUNET_ATS_connectivity_done (ats);
ats = NULL;
ret = 1;
ats_sh = GNUNET_ATS_connectivity_suggest (ats,
&pid,
1);
- end = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+ NULL);
}
const struct GNUNET_CONFIGURATION_Handle *mycfg)
{
cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
- GNUNET_CLIENT_service_test ("transport", cfg, GNUNET_TIME_UNIT_SECONDS,
- &testservice_task, (void *) cfg);
+ GNUNET_CLIENT_service_test ("transport",
+ cfg,
+ GNUNET_TIME_UNIT_SECONDS,
+ &testservice_task,
+ (void *) cfg);
}