* - handle messages for future round (one into the future, see FIXME)
*/
#include "platform.h"
-#include "gnunet_client_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
-#include "gnunet_container_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_signatures.h"
-#include "gnunet_service_lib.h"
-#include "gnunet_server_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_core_service.h"
-#include "gnunet_time_lib.h"
#include "gnunet_nse_service.h"
#include "nse.h"
GNUNET_SCHEDULER_cancel (flood_task);
flood_task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_SERVER_notification_context_destroy (nc);
- nc = NULL;
+ if (nc != NULL)
+ {
+ GNUNET_SERVER_notification_context_destroy (nc);
+ nc = NULL;
+ }
if (coreAPI != NULL)
{
GNUNET_CORE_disconnect (coreAPI);
GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
stats = NULL;
}
+ if (peers != NULL)
+ {
+ GNUNET_CONTAINER_multihashmap_destroy (peers);
+ peers = NULL;
+ }
}
* @param publicKey the public key of this peer
*/
void
-core_init(void *cls, struct GNUNET_CORE_Handle *server,
- const struct GNUNET_PeerIdentity *identity,
- const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
+core_init (void *cls, struct GNUNET_CORE_Handle *server,
+ const struct GNUNET_PeerIdentity *identity,
+ const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
{
struct GNUNET_TIME_Absolute now;
struct GNUNET_TIME_Absolute prev_time;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connection to core FAILED!\n");
#endif
- GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+ GNUNET_SCHEDULER_shutdown ();
return;
}
my_identity = *identity;
GNUNET_SCHEDULER_shutdown ();
return;
}
+ peers = GNUNET_CONTAINER_multihashmap_create (128);
GNUNET_SERVER_add_handlers (server, handlers);
nc = GNUNET_SERVER_notification_context_create (server, 1);
/* Connect to core service and register core handlers */
NULL, /* Don't want notified about all outbound messages */
GNUNET_NO, /* For header only outbound notification */
core_handlers); /* Register these handlers */
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+ &shutdown_task, NULL);
if (coreAPI == NULL)
{
- GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+ GNUNET_SCHEDULER_shutdown ();
return;
}
stats = GNUNET_STATISTICS_create ("NSE", cfg);
static struct PeerContext p1;
+
+static void
+stop_arm (struct PeerContext *p)
+{
+#if START_ARM
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+ GNUNET_OS_process_wait (p->arm_proc);
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
+#endif
+ GNUNET_CONFIGURATION_destroy (p->cfg);
+}
+
/**
* Signature of the main function of a task.
*
* @param cls closure
* @param tc context information (why was this task triggered now)
*/
-static void end_test (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext * tc)
+static void
+end_test (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext * tc)
{
if (h != NULL)
{
{
int *ok = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received NSE message, estimate %f, standard deviation %f.\n");
+ fprintf (stderr,
+ "Received NSE message, estimate %f, standard deviation %f.\n");
/* Fantastic check below. Expect NaN, the only thing not equal to itself. */
- if ((estimate != estimate) && (std_dev != std_dev))
- (*ok) = 0;
+ (*ok) = 0;
if (die_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel(die_task);
die_task = GNUNET_SCHEDULER_add_now(&end_test, NULL);
}
-static void
-stop_arm (struct PeerContext *p)
-{
-#if START_ARM
- if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (p->arm_proc);
- GNUNET_OS_process_close (p->arm_proc);
- p->arm_proc = NULL;
-#endif
- GNUNET_CONFIGURATION_destroy (p->cfg);
-}
static void