/*
This file is part of GNUnet.
- (C) 2009, 2010, 2011, 2012, 2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009, 2010, 2011, 2012, 2013 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
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
/**
* Task scheduled to send message to this peer.
*/
- GNUNET_SCHEDULER_TaskIdentifier transmit_task;
+ struct GNUNET_SCHEDULER_Task * transmit_task;
/**
* Did we receive or send a message about the previous round
/**
* Task scheduled to update our flood message for the next round.
*/
-static GNUNET_SCHEDULER_TaskIdentifier flood_task;
+static struct GNUNET_SCHEDULER_Task * flood_task;
/**
* Task scheduled to compute our proof.
*/
-static GNUNET_SCHEDULER_TaskIdentifier proof_task;
+static struct GNUNET_SCHEDULER_Task * proof_task;
/**
* Notification context, simplifies client broadcasts.
em->std_deviation = GNUNET_hton_double (std_dev);
GNUNET_STATISTICS_set (stats,
"# nodes in the network (estimate)",
- (uint64_t) pow (2, em->size_estimate),
+ (uint64_t) pow (2, GNUNET_MAX (se,
+ nsize)),
GNUNET_NO);
}
* Task that triggers a NSE P2P transmission.
*
* @param cls the `struct NSEPeerEntry *`
- * @param tc scheduler context
*/
static void
-transmit_task_cb (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc);
+transmit_task_cb (void *cls);
/**
peer_entry);
}
if ((0 == ntohl (size_estimate_messages[idx].hop_count)) &&
- (GNUNET_SCHEDULER_NO_TASK != proof_task))
+ (NULL != proof_task))
{
GNUNET_STATISTICS_update (stats,
"# flood messages not generated (no proof yet)",
return 0;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "In round s, sending to `%s' estimate with %u bits\n",
+ "In round %s, sending to `%s' estimate with %u bits\n",
GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (size_estimate_messages[idx].timestamp)),
GNUNET_i2s (&peer_entry->id),
(unsigned int) ntohl (size_estimate_messages[idx].matching_bits));
* Task that triggers a NSE P2P transmission.
*
* @param cls the `struct NSEPeerEntry *`
- * @param tc scheduler context
*/
static void
-transmit_task_cb (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+transmit_task_cb (void *cls)
{
struct NSEPeerEntry *peer_entry = cls;
- peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK;
+ peer_entry->transmit_task = NULL;
GNUNET_assert (NULL == peer_entry->th);
peer_entry->th =
peer_entry->previous_round = GNUNET_NO;
return GNUNET_OK;
}
- if (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task)
+ if (NULL != peer_entry->transmit_task)
{
GNUNET_SCHEDULER_cancel (peer_entry->transmit_task);
peer_entry->previous_round = GNUNET_NO;
delay =
get_transmit_delay ((peer_entry->previous_round == GNUNET_NO) ? -1 : 0);
peer_entry->transmit_task =
- GNUNET_SCHEDULER_add_delayed (delay, &transmit_task_cb, peer_entry);
+ GNUNET_SCHEDULER_add_delayed (delay,
+ &transmit_task_cb,
+ peer_entry);
return GNUNET_OK;
}
* Update our flood message to be sent (and our timestamps).
*
* @param cls unused
- * @param tc context for this message
*/
static void
-update_flood_message (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+update_flood_message (void *cls)
{
struct GNUNET_TIME_Relative offset;
unsigned int i;
- flood_task = GNUNET_SCHEDULER_NO_TASK;
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- return;
+ flood_task = NULL;
offset = GNUNET_TIME_absolute_get_remaining (next_timestamp);
if (0 != offset.rel_value_us)
{
/* somehow run early, delay more */
flood_task =
- GNUNET_SCHEDULER_add_delayed (offset, &update_flood_message, NULL);
+ GNUNET_SCHEDULER_add_delayed (offset,
+ &update_flood_message, NULL);
return;
}
estimate_index = (estimate_index + 1) % HISTORY_SIZE;
NULL);
flood_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
- (next_timestamp), &update_flood_message,
+ (next_timestamp),
+ &update_flood_message,
NULL);
}
* Find our proof of work.
*
* @param cls closure (unused)
- * @param tc task context
*/
static void
-find_proof (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+find_proof (void *cls)
{
#define ROUND_SIZE 10
uint64_t counter;
struct GNUNET_HashCode result;
unsigned int i;
- proof_task = GNUNET_SCHEDULER_NO_TASK;
+ proof_task = NULL;
memcpy (&buf[sizeof (uint64_t)], &my_identity,
sizeof (struct GNUNET_PeerIdentity));
i = 0;
}
if (my_proof / (100 * ROUND_SIZE) < counter / (100 * ROUND_SIZE))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing proofs currently at %llu\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing proofs currently at %llu\n",
(unsigned long long) counter);
/* remember progress every 100 rounds */
my_proof = counter;
{
/* still stuck in previous round, no point to update, check that
* we are active here though... */
- if ( (GNUNET_SCHEDULER_NO_TASK == peer_entry->transmit_task) &&
+ if ( (NULL == peer_entry->transmit_task) &&
(NULL == peer_entry->th) )
{
GNUNET_break (0);
}
return GNUNET_OK;
}
- if (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task)
+ if (NULL != peer_entry->transmit_task)
{
GNUNET_SCHEDULER_cancel (peer_entry->transmit_task);
- peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK;
+ peer_entry->transmit_task = NULL;
}
delay = get_transmit_delay (0);
peer_entry->transmit_task =
- GNUNET_SCHEDULER_add_delayed (delay, &transmit_task_cb, peer_entry);
+ GNUNET_SCHEDULER_add_delayed (delay,
+ &transmit_task_cb, peer_entry);
return GNUNET_OK;
}
return GNUNET_OK; /* ignore, simply too early/late */
if (GNUNET_YES != verify_message_crypto (incoming_flood))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Peer %s is likely ill-configured!\n",
+ GNUNET_i2s (peer));
GNUNET_break_op (0);
return GNUNET_OK;
}
}
/* got up-to-date information for current round, cancel transmission to
* this peer altogether */
- if (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task)
+ if (NULL != peer_entry->transmit_task)
{
GNUNET_SCHEDULER_cancel (peer_entry->transmit_task);
- peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK;
+ peer_entry->transmit_task = NULL;
}
if (NULL != peer_entry->th)
{
/* push back our result now, that peer is spreading bad information... */
if (NULL == peer_entry->th)
{
- if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK)
+ if (peer_entry->transmit_task != NULL)
GNUNET_SCHEDULER_cancel (peer_entry->transmit_task);
peer_entry->transmit_task =
GNUNET_SCHEDULER_add_now (&transmit_task_cb, peer_entry);
if (idx == estimate_index)
{
/* cancel any activity for current round */
- if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK)
+ if (peer_entry->transmit_task != NULL)
{
GNUNET_SCHEDULER_cancel (peer_entry->transmit_task);
- peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK;
+ peer_entry->transmit_task = NULL;
}
if (peer_entry->th != NULL)
{
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_remove (peers, peer,
pos));
- if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) {
+ if (pos->transmit_task != NULL) {
GNUNET_SCHEDULER_cancel (pos->transmit_task);
- pos->transmit_task = GNUNET_SCHEDULER_NO_TASK;
+ pos->transmit_task = NULL;
}
if (NULL != pos->th)
{
* Task run during shutdown.
*
* @param cls unused
- * @param tc unused
*/
static void
-shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
{
- if (GNUNET_SCHEDULER_NO_TASK != flood_task)
+ if (NULL != flood_task)
{
GNUNET_SCHEDULER_cancel (flood_task);
- flood_task = GNUNET_SCHEDULER_NO_TASK;
+ flood_task = NULL;
}
- if (GNUNET_SCHEDULER_NO_TASK != proof_task)
+ if (NULL != proof_task)
{
GNUNET_SCHEDULER_cancel (proof_task);
- proof_task = GNUNET_SCHEDULER_NO_TASK;
+ proof_task = NULL;
write_proof (); /* remember progress */
}
if (NULL != nc)
}
if (NULL != lh)
{
- struct GNUNET_TIME_Relative timeout;
- timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30);
- GNUNET_TESTBED_LOGGER_flush (lh, timeout, &flush_comp_cb, NULL);
+ GNUNET_TESTBED_LOGGER_flush (lh,
+ &flush_comp_cb,
+ NULL);
}
if (NULL != histogram)
{
}
flood_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
- (next_timestamp), &update_flood_message,
+ (next_timestamp),
+ &update_flood_message,
NULL);
}
}
#endif
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+ NULL);
pk = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg);
GNUNET_assert (NULL != pk);
my_private_key = pk;
}
-#ifdef LINUX
+#if defined(LINUX) && defined(__GLIBC__)
#include <malloc.h>
/**