}
+/**
+ * Install server (service) handlers and start listening to clients.
+ */
+static void
+server_init (void)
+{
+ GNUNET_SERVER_add_handlers (server_handle, client_handlers);
+ GNUNET_SERVER_disconnect_notify (server_handle,
+ &handle_local_client_disconnect, NULL);
+ nc = GNUNET_SERVER_notification_context_create (server_handle, 1);
+
+ clients_head = NULL;
+ clients_tail = NULL;
+ next_client_id = 0;
+ GNUNET_SERVER_resume (server_handle);
+}
+
+
/**
* To be called on core init/fail.
*
static int i = 0;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core init\n");
- core_handle = server;
+ GNUNET_break (core_handle == server);
if (0 != memcmp (identity, &my_full_id, sizeof (my_full_id)) ||
NULL == server)
{
if (10 < i++)
GNUNET_abort();
}
- return;
+ server_init ();
+ return;
}
struct MeshPeerInfo *peer;
struct MeshPeerPath *p;
- keygen = NULL;
+ keygen = NULL;
if (NULL == pk)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
next_tid = 0;
next_local_tid = GNUNET_MESH_LOCAL_TUNNEL_ID_SERV;
-
- GNUNET_SERVER_add_handlers (server_handle, client_handlers);
- nc = GNUNET_SERVER_notification_context_create (server_handle, 1);
- GNUNET_SERVER_disconnect_notify (server_handle,
- &handle_local_client_disconnect, NULL);
-
-
- clients_head = NULL;
- clients_tail = NULL;
- next_client_id = 0;
-
announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, cls);
/* Create a peer_info for the local peer */
p->peers[0] = myid;
GNUNET_PEER_change_rc (myid, 1);
peer_info_add_path (peer, p, GNUNET_YES);
- GNUNET_SERVER_resume (server_handle);
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Mesh service running\n");
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting to run\n");
server_handle = server;
+ GNUNET_SERVER_suspend (server_handle);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (c, "PEER", "PRIVATE_KEY",
}
stats = GNUNET_STATISTICS_create ("mesh", c);
- GNUNET_SERVER_suspend (server_handle);
/* Scheduled the task to clean up when shutdown is called */
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
NULL);