fin_options = GNUNET_strdup (final_option);
/* replace '{}' with service name */
while (NULL != (optpos = strstr (fin_options, "{}")))
- {
- /* terminate string at opening parenthesis */
- *optpos = 0;
- GNUNET_asprintf (&new_options,
- "%s%s%s",
- fin_options,
- sl->name,
- optpos + 2);
- GNUNET_free (fin_options);
- fin_options = new_options;
- }
+ {
+ /* terminate string at opening parenthesis */
+ *optpos = 0;
+ GNUNET_asprintf (&new_options,
+ "%s%s%s",
+ fin_options,
+ sl->name,
+ optpos + 2);
+ GNUNET_free (fin_options);
+ fin_options = new_options;
+ }
if (NULL != options)
{
/* combine "fin_options" with "options" */
else
{
mlt->total_throughput_send = mult * mlt->total_bytes_sent;
- mlt->total_throughput_send = mult * mlt->total_bytes_received;
+ mlt->total_throughput_recv = mult * mlt->total_bytes_received;
}
if (GNUNET_YES == l->verbose)
*/
static int opt_verbose;
-struct GNUNET_SCHEDULER_Task * timeout_task;
+static struct GNUNET_SCHEDULER_Task *timeout_task;
+
+static struct Experiment *e;
+
+static struct LoggingHandle *l;
-struct Experiment *e;
-struct LoggingHandle *l;
static void
evaluate (struct GNUNET_TIME_Relative duration_total)
}
}
+
static void
-do_shutdown ()
+do_shutdown (void *cls)
{
fprintf (stderr, "Shutdown\n");
- /* timeout */
+ if (NULL != timeout_task)
+ {
+ GNUNET_SCHEDULER_cancel (timeout_task);
+ timeout_task = NULL;
+ }
if (NULL != l)
{
GNUNET_ATS_TEST_logging_stop (l);
}
+static void
+do_timeout (void *cls)
+{
+ timeout_task = NULL;
+ GNUNET_SCHEDULER_shutdown ();
+}
+
+
static void
transport_recv_cb (void *cls,
- const struct GNUNET_PeerIdentity * peer,
- const struct GNUNET_MessageHeader * message)
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *message)
{
}
}
+
static void
-experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative duration,int success)
+experiment_done_cb (struct Experiment *e,
+ struct GNUNET_TIME_Relative duration,int success)
{
if (GNUNET_OK == success)
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment done successful in %s\n",
- GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Experiment done successful in %s\n",
+ GNUNET_STRINGS_relative_time_to_string (duration,
+ GNUNET_YES));
else
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n");
- if (NULL != timeout_task)
- {
- GNUNET_SCHEDULER_cancel (timeout_task);
- timeout_task = NULL;
- }
+
/* Stop logging */
GNUNET_ATS_TEST_logging_stop (l);
evaluate (duration);
if (opt_log)
GNUNET_ATS_TEST_logging_write_to_file(l, opt_exp_file, opt_plot);
-
- if (NULL != l)
- {
- GNUNET_ATS_TEST_logging_stop (l);
- GNUNET_ATS_TEST_logging_clean_up (l);
- l = NULL;
- }
-
- /* Clean up experiment */
- GNUNET_ATS_TEST_experimentation_stop (e);
- e = NULL;
-
- /* Shutdown topology */
- GNUNET_ATS_TEST_shutdown_topology ();
+ GNUNET_SCHEDULER_shutdown ();
}
+
static void
episode_done_cb (struct Episode *ep)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Episode %u done\n", ep->id);
}
+
static void topology_setup_done (void *cls,
- struct BenchmarkPeer *masters,
- struct BenchmarkPeer *slaves)
+ struct BenchmarkPeer *masters,
+ struct BenchmarkPeer *slaves)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Topology setup complete!\n");
}
#endif
- timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_UNIT_MINUTES,
- e->max_duration), &do_shutdown, NULL);
+ timeout_task
+ = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_UNIT_MINUTES,
+ e->max_duration),
+ &do_timeout,
+ NULL);
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
}
+
static void
parse_args (int argc, char *argv[])
{
{
if ((c < (argc - 1)) && (0 == strcmp (argv[c], "-e")))
{
+ GNUNET_free_non_null (opt_exp_file);
opt_exp_file = GNUNET_strdup ( argv[c + 1]);
}
if (0 == strcmp (argv[c], "-l"))
}
}
+
int
main (int argc, char *argv[])
{
double kb_recv_percent;
unsigned int rtt;
- duration = (perf_duration.rel_value_us / (1000 * 1000));
+ duration = 1 + (perf_duration.rel_value_us / (1000 * 1000));
for (c_m = 0; c_m < num_masters; c_m++)
{
mp = &mps[c_m];
- if (NULL == mp)
- continue;
fprintf (stderr,
- _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"),
+ "Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n",
mp->no, mp->total_bytes_sent / 1024, duration,
(mp->total_bytes_sent / 1024) / duration,
mp->total_bytes_received / 1024, duration,
for (c_s = 0; c_s < num_slaves; c_s++)
{
p = &mp->partners[c_s];
- if (NULL == p)
- continue;
kb_sent_sec = 0;
kb_recv_sec = 0;
kb_sent_percent = 0.0;
static uint32_t off;
uint32_t i;
+ GNUNET_assert (0 != sh->session_array_size);
i = 0;
while ( ( (NOT_FOUND == off) ||
(NULL != sh->session_array[off % sh->session_array_size]) ) &&
#define MAX_TRANSMIT_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+/**
+ * Highest bit in a 32-bit unsigned integer,
+ * bit set if we are making an outgoing call,
+ * bit unset for local lines.
+ */
+#define HIGH_BIT ((uint32_t) (1LL << 31))
+
+
/**
* Message to transmit the audio (between client and helpers).
*/
"LINE");
return NULL;
}
- if (line >= (1 << 31))
+ if (line >= HIGH_BIT)
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"CONVERSATION",
GNUNET_CONTAINER_DLL_insert (lines_head,
lines_tail,
line);
- line->local_line = ntohl (msg->line) & (~ (1 << 31));
+ line->local_line = ntohl (msg->line) & (~ HIGH_BIT);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
}
line = GNUNET_new (struct Line);
line->client = client;
- line->local_line = (local_line_cnt++) | (1 << 31);
+ line->local_line = (local_line_cnt++) | HIGH_BIT;
GNUNET_SERVER_client_set_user_context (client, line);
GNUNET_SERVER_notification_context_add (nc, client);
GNUNET_CONTAINER_DLL_insert (lines_head,
*/
#define MAX_PENDING 1024
+/**
+ * Limit size of bloom filter to 2 GB.
+ */
+#define MAX_BF_SIZE ((uint32_t) (1LL << 31))
+
/**
* How long are we at most keeping "expired" content
* past the expiration date in the database?
* Identity of the task that is used to delete
* expired content.
*/
-static struct GNUNET_SCHEDULER_Task * expired_kill_task;
+static struct GNUNET_SCHEDULER_Task *expired_kill_task;
/**
* Minimum time that content should have to not be discarded instantly
* @param msg message to transmit, will be freed!
*/
static void
-transmit (struct GNUNET_SERVER_Client *client, struct GNUNET_MessageHeader *msg)
+transmit (struct GNUNET_SERVER_Client *client,
+ struct GNUNET_MessageHeader *msg)
{
struct TransmitCallbackContext *tcc;
* @param expiration expiration time for the content
* @param uid unique identifier for the datum;
* maybe 0 if no unique identifier is available
- *
- * @return GNUNET_SYSERR to abort the iteration, GNUNET_OK to continue,
- * GNUNET_NO to delete the item and continue (if supported)
+ * @return #GNUNET_SYSERR to abort the iteration, #GNUNET_OK to continue,
+ * #GNUNET_NO to delete the item and continue (if supported)
*/
static int
-transmit_item (void *cls, const struct GNUNET_HashCode * key, uint32_t size,
- const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority,
- uint32_t anonymity, struct GNUNET_TIME_Absolute expiration,
+transmit_item (void *cls,
+ const struct GNUNET_HashCode *key,
+ uint32_t size,
+ const void *data,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t priority,
+ uint32_t anonymity,
+ struct GNUNET_TIME_Absolute expiration,
uint64_t uid)
{
struct GNUNET_SERVER_Client *client = cls;
return;
}
stats = GNUNET_STATISTICS_create ("datastore", cfg);
- GNUNET_STATISTICS_set (stats, gettext_noop ("# quota"), quota, GNUNET_NO);
+ GNUNET_STATISTICS_set (stats,
+ gettext_noop ("# quota"),
+ quota,
+ GNUNET_NO);
cache_size = quota / 8; /* Or should we make this an option? */
- GNUNET_STATISTICS_set (stats, gettext_noop ("# cache size"), cache_size,
+ GNUNET_STATISTICS_set (stats,
+ gettext_noop ("# cache size"),
+ cache_size,
GNUNET_NO);
- if (quota / (32 * 1024LL) > (1 << 31))
- bf_size = (1 << 31); /* absolute limit: ~2 GB, beyond that BF just won't help anyway */
+ if (quota / (32 * 1024LL) > MAX_BF_SIZE)
+ bf_size = MAX_BF_SIZE;
else
bf_size = quota / (32 * 1024LL); /* 8 bit per entry, 1 bit per 32 kb in DB */
fn = NULL;
proc (proc_cls, NULL, 0);
return;
}
+ memset (&last, 0, sizeof (last)); /* make static analysis happy */
ret = GNUNET_YES;
cnt = 0;
while (ret == GNUNET_YES)
* @return the value, 0 if not found
*/
static unsigned int
-rfc4394_mnemonic_to_value (const char *mnemonic)
+rfc4398_mnemonic_to_value (const char *mnemonic)
{
static struct {
const char *mnemonic;
sdup = GNUNET_strdup (s);
typep = strtok (sdup, " ");
if ( (NULL == typep) ||
- ( (0 == (type = rfc4394_mnemonic_to_value (typep))) &&
+ ( (0 == (type = rfc4398_mnemonic_to_value (typep))) &&
( (1 != SSCANF (typep,
"%u",
&type)) ||
GNUNET_free (sdup);
return GNUNET_SYSERR;
}
+ alg = 0;
algp = strtok (NULL, " ");
if ( (NULL == algp) ||
( (0 == (type = rfc4034_mnemonic_to_value (typep))) &&
GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
GNUNET_YES));
GAUGER ("NSE", "Proof-of-work hashing",
- 1024LL / (1LL +
+ 1024.0 / (1.0 +
GNUNET_TIME_absolute_get_duration
- (start).rel_value_us / 1000LL), "hashes/ms");
+ (start).rel_value_us / 1000.0), "hashes/ms");
return 0;
}
if ( (s1->accepting && !s2->accepting) ||
(!s1->accepting && s2->accepting) )
{
- idx = s1->marked * state_cnt + s2->marked;
+ idx = (unsigned long long) s1->marked * state_cnt + s2->marked;
table[idx / 32] |= (1 << (idx % 32));
}
{
for (s2 = a->states_head; NULL != s2 && s1 != s2; s2 = s2->next)
{
- idx = s1->marked * state_cnt + s2->marked;
+ idx = (unsigned long long) s1->marked * state_cnt + s2->marked;
if (0 != (table[idx / 32] & (1 << (idx % 32))))
continue;
num_equal_edges = 0;
static void
salt_key (const struct IBF_Key *k_in,
- uint32_t salt,
+ uint32_t salt,
struct IBF_Key *k_out)
{
int s = salt % 64;
static void
unsalt_key (const struct IBF_Key *k_in,
- uint32_t salt,
+ uint32_t salt,
struct IBF_Key *k_out)
{
int s = salt % 64;
{
/* decompression failed */
fail_union_operation (op);
+ strata_estimator_destroy (remote_se);
return GNUNET_SYSERR;
}
GNUNET_assert (NULL != op->state->se);
h->cb = cb;
h->cb_cls = cb_cls;
if ( (NULL == h->mq) ||
- (NULL == h->buf) )
+ (0 == h->buse) )
{
trigger_flush_notification (h);
return;
GNUNET_asprintf (&fname,
"%s/blacklist",
shome);
- GNUNET_free (fname);
if (GNUNET_YES == GNUNET_DISK_file_test (fname))
{
mode = ACCESS_DENY;
setup_ac (shome, c);
}
GNUNET_free (shome);
- return;
+ GNUNET_free (fname);
}
#include "platform.h"
#include "gnunet_util_lib.h"
-#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); if (m != NULL) GNUNET_CONTAINER_multihashmap_destroy(m); return 1; }
+#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); if (m != NULL) GNUNET_CONTAINER_multihashmap_destroy(m); if (NULL != iter) GNUNET_CONTAINER_multihashmap_iterator_destroy (iter); return 1; }
#define CHECK(c) { if (! (c)) ABORT(); }
static int
struct GNUNET_CONTAINER_MultiHashMap *m;
struct GNUNET_HashCode k1;
struct GNUNET_HashCode k2;
- struct GNUNET_CONTAINER_MultiHashMapIterator *iter;
+ struct GNUNET_CONTAINER_MultiHashMapIterator *iter = NULL;
struct GNUNET_HashCode key_ret;
const char *ret;
int j;
for (j = 0; j < GNUNET_CONTAINER_multihashmap_size (m); j++)
CHECK (GNUNET_YES == GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, NULL));
CHECK (GNUNET_NO == GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, NULL));
- GNUNET_free (iter);
+ GNUNET_CONTAINER_multihashmap_iterator_destroy (iter);
GNUNET_CONTAINER_multihashmap_destroy (m);
return 0;
#include "platform.h"
#include "gnunet_util_lib.h"
-#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); if (NULL != m) GNUNET_CONTAINER_multipeermap_destroy(m); return 1; }
+#define ABORT() { fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); if (NULL != m) GNUNET_CONTAINER_multipeermap_destroy(m); if (NULL != iter) GNUNET_CONTAINER_multipeermap_iterator_destroy (iter); return 1; }
#define CHECK(c) { if (! (c)) ABORT(); }
static int
struct GNUNET_CONTAINER_MultiPeerMap *m;
struct GNUNET_PeerIdentity k1;
struct GNUNET_PeerIdentity k2;
- struct GNUNET_CONTAINER_MultiPeerMapIterator *iter;
+ struct GNUNET_CONTAINER_MultiPeerMapIterator *iter = NULL;
struct GNUNET_PeerIdentity key_ret;
const char *ret;
int j;
for (j = 0; j < GNUNET_CONTAINER_multipeermap_size (m); j++)
CHECK (GNUNET_YES == GNUNET_CONTAINER_multipeermap_iterator_next (iter, NULL, NULL));
CHECK (GNUNET_NO == GNUNET_CONTAINER_multipeermap_iterator_next (iter, NULL, NULL));
- GNUNET_free (iter);
+ GNUNET_CONTAINER_multipeermap_iterator_destroy (iter);
GNUNET_CONTAINER_multipeermap_destroy (m);
return 0;