GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
* @author Christian Grothoff
*/
#include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_configuration_lib.h"
-#include "gnunet_crypto_lib.h"
-#include "gnunet_directories.h"
-#include "gnunet_disk_lib.h"
-#include "gnunet_getopt_lib.h"
-#include "gnunet_os_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
+#include "gnunet_directories.h"
#include "gnunet_resolver_service.h"
-#include "gnunet_server_lib.h"
-#include "gnunet_service_lib.h"
+
+#if HAVE_MALLINFO
+#include <malloc.h>
+#include "gauger.h"
+#endif
+
#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
};
/**
+
* @brief network in CIDR notation for IPV6.
*/
struct IPv6NetworkSet
};
+/**
+ * Start task that may speed up our system clock artificially
+ *
+ * @param cfg configuration to use
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the speedup was not configured
+ */
+int
+GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg);
+
+/**
+ * Stop tasks that modify clock behavior.
+ */
+void
+GNUNET_SPEEDUP_stop_ (void);
+
+
/**
* Parse a network specification. The argument specifies
* a list of networks. The format is
* with a semicolon). The network must be given in dotted-decimal
* notation. The netmask can be given in CIDR notation (/16) or
* in dotted-decimal (/255.255.0.0).
- *
+ *
* @param routeList a string specifying the forbidden networks
* @return the converted list, NULL if the synatx is flawed
*/
* with a semicolon). The network must be given in colon-hex
* notation. The netmask must be given in CIDR notation (/16) or
* can be omitted to specify a single host.
- *
+ *
* @param routeListX a string specifying the forbidden networks
* @return the converted list, NULL if the synatx is flawed
*/
/**
* Name of our service.
*/
- const char *serviceName;
+ const char *service_name;
/**
* Main service-specific task to run.
*/
struct GNUNET_NETWORK_Handle **lsocks;
+ /**
+ * Task ID of the shutdown task.
+ */
+ GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
+
/**
* Idle timeout for server.
*/
#ifndef WINDOWS
case AF_UNIX:
ret = GNUNET_OK; /* always OK for now */
- if (GNUNET_YES == sctx->match_uid)
+ if (GNUNET_YES == sctx->match_uid)
{
/* UID match required */
- ret = (NULL != uc) && (uc->uid == geteuid ());
+ ret = (NULL != uc) && ( (0 == uc->uid) || (uc->uid == geteuid ()) );
}
else if ( (GNUNET_YES == sctx->match_gid) &&
- ( (NULL == uc) || (uc->uid != geteuid ()) ) )
+ ( (NULL == uc) ||
+ ( (0 != uc->uid) &&
+ (uc->uid != geteuid ()) ) ) )
{
/* group match required and UID does not match */
- if (NULL == uc)
+ if (NULL == uc)
{
/* no credentials, group match not possible */
ret = GNUNET_NO;
if (GNUNET_OK != ret)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Access from `%s' denied to service `%s'\n"),
+ _("Access from `%s' denied to service `%s'\n"),
GNUNET_a2s (addr, addrlen),
- sctx->serviceName);
+ sctx->service_name);
}
return ret;
}
char *pif;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->serviceName,
+ GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->service_name,
"PIDFILE", &pif))
return NULL;
return pif;
* Parse an IPv4 access control list.
*
* @param ret location where to write the ACL (set)
- * @param sctx service context to use to get the configuration
+ * @param sctx service context to use to get the configuration
* @param option name of the ACL option to parse
- * @return GNUNET_SYSERR on parse error, GNUNET_OK on success (including
+ * @return GNUNET_SYSERR on parse error, GNUNET_OK on success (including
* no ACL configured)
*/
static int
{
char *opt;
- if (!GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->serviceName, option))
+ if (!GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option))
{
- *ret = NULL;
+ *ret = NULL;
return GNUNET_OK;
}
GNUNET_break (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (sctx->cfg,
- sctx->serviceName,
+ sctx->service_name,
option, &opt));
if (NULL == (*ret = parse_ipv4_specification (opt)))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
_("Could not parse IPv4 network specification `%s' for `%s:%s'\n"),
- opt, sctx->serviceName, option);
+ opt, sctx->service_name, option);
GNUNET_free (opt);
return GNUNET_SYSERR;
}
* Parse an IPv6 access control list.
*
* @param ret location where to write the ACL (set)
- * @param sctx service context to use to get the configuration
+ * @param sctx service context to use to get the configuration
* @param option name of the ACL option to parse
- * @return GNUNET_SYSERR on parse error, GNUNET_OK on success (including
+ * @return GNUNET_SYSERR on parse error, GNUNET_OK on success (including
* no ACL configured)
*/
static int
{
char *opt;
- if (!GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->serviceName, option))
+ if (!GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option))
{
*ret = NULL;
return GNUNET_OK;
}
GNUNET_break (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (sctx->cfg,
- sctx->serviceName,
+ sctx->service_name,
option, &opt));
if (NULL == (*ret = parse_ipv6_specification (opt)))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
_("Could not parse IPv6 network specification `%s' for `%s:%s'\n"),
- opt, sctx->serviceName, option);
+ opt, sctx->service_name, option);
GNUNET_free (opt);
return GNUNET_SYSERR;
}
* Get the list of addresses that a server for the given service
* should bind to.
*
- * @param serviceName name of the service
+ * @param service_name name of the service
* @param cfg configuration (which specifies the addresses)
* @param addrs set (call by reference) to an array of pointers to the
* addresses the server should bind to and listen on; the
* set to NULL).
*/
int
-GNUNET_SERVICE_get_server_addresses (const char *serviceName,
+GNUNET_SERVICE_get_server_addresses (const char *service_name,
const struct GNUNET_CONFIGURATION_Handle
*cfg, struct sockaddr ***addrs,
socklen_t ** addr_lens)
*addrs = NULL;
*addr_lens = NULL;
desc = NULL;
- if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "DISABLEV6"))
+ if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6"))
{
if (GNUNET_SYSERR ==
(disablev6 =
- GNUNET_CONFIGURATION_get_value_yesno (cfg, serviceName, "DISABLEV6")))
+ GNUNET_CONFIGURATION_get_value_yesno (cfg, service_name, "DISABLEV6")))
return GNUNET_SYSERR;
}
else
LOG (GNUNET_ERROR_TYPE_INFO,
_
("Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
- serviceName, STRERROR (errno));
+ service_name, STRERROR (errno));
disablev6 = GNUNET_YES;
}
else
}
port = 0;
- if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "PORT"))
+ if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT"))
{
- GNUNET_break (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_number (cfg, serviceName,
- "PORT", &port));
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg, service_name,
+ "PORT", &port))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _("Require valid port number for service `%s' in configuration!\n"),
+ service_name);
+ }
if (port > 65535)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
_("Require valid port number for service `%s' in configuration!\n"),
- serviceName);
+ service_name);
return GNUNET_SYSERR;
}
}
- if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "BINDTO"))
+ if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO"))
{
GNUNET_break (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg, serviceName,
+ GNUNET_CONFIGURATION_get_value_string (cfg, service_name,
"BINDTO", &hostname));
}
else
unixpath = NULL;
#ifdef AF_UNIX
if ((GNUNET_YES ==
- GNUNET_CONFIGURATION_have_value (cfg, serviceName, "UNIXPATH")) &&
+ GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
(GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg, serviceName, "UNIXPATH",
+ GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH",
&unixpath)) &&
(0 < strlen (unixpath)))
{
{
LOG (GNUNET_ERROR_TYPE_WARNING,
_("UNIXPATH `%s' too long, maximum length is %llu\n"), unixpath,
- sizeof (s_un.sun_path));
- GNUNET_free_non_null (hostname);
- GNUNET_free (unixpath);
- return GNUNET_SYSERR;
+ (unsigned long long) sizeof (s_un.sun_path));
+ unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ _("Using `%s' instead\n"), unixpath);
}
-
+ }
+ if (NULL != unixpath)
+ {
desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0);
if (NULL == desc)
{
LOG (GNUNET_ERROR_TYPE_INFO,
_
("Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
- serviceName, STRERROR (errno));
+ service_name, STRERROR (errno));
GNUNET_free (unixpath);
unixpath = NULL;
}
LOG (GNUNET_ERROR_TYPE_ERROR,
_
("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
- serviceName);
+ service_name);
GNUNET_free_non_null (hostname);
return GNUNET_SYSERR;
}
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Resolving `%s' since that is where `%s' will bind to.\n", hostname,
- serviceName);
+ service_name);
memset (&hints, 0, sizeof (struct addrinfo));
if (disablev6)
hints.ai_family = AF_INET;
+ hints.ai_protocol = IPPROTO_TCP;
if ((0 != (ret = getaddrinfo (hostname, NULL, &hints, &res))) ||
(res == NULL))
{
if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype))
continue; /* huh? */
LOG (GNUNET_ERROR_TYPE_DEBUG, "Service `%s' will bind to `%s'\n",
- serviceName, GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
+ service_name, GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
if (AF_INET == pos->ai_family)
{
GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen);
*/
lsocks_pipe = (HANDLE) strtoul (env_buf, NULL, 10);
if ( (0 == lsocks_pipe) || (INVALID_HANDLE_VALUE == lsocks_pipe))
- return GNUNET_NO
+ return GNUNET_NO;
fail = 1;
do
{
int tolerant;
#ifndef MINGW
- const char *lpid;
- unsigned int pid;
const char *nfds;
unsigned int cnt;
int flags;
#endif
- if (GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->serviceName, "TIMEOUT"))
+ if (GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, "TIMEOUT"))
{
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_time (sctx->cfg, sctx->serviceName,
+ GNUNET_CONFIGURATION_get_value_time (sctx->cfg, sctx->service_name,
"TIMEOUT", &idleout))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
_("Specified value for `%s' of service `%s' is invalid\n"),
- "TIMEOUT", sctx->serviceName);
+ "TIMEOUT", sctx->service_name);
return GNUNET_SYSERR;
}
sctx->timeout = idleout;
sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
if (GNUNET_CONFIGURATION_have_value
- (sctx->cfg, sctx->serviceName, "TOLERANT"))
+ (sctx->cfg, sctx->service_name, "TOLERANT"))
{
if (GNUNET_SYSERR ==
(tolerant =
- GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName,
+ GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name,
"TOLERANT")))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
_("Specified value for `%s' of service `%s' is invalid\n"),
- "TOLERANT", sctx->serviceName);
+ "TOLERANT", sctx->service_name);
return GNUNET_SYSERR;
}
}
#ifndef MINGW
errno = 0;
- if ((NULL != (lpid = getenv ("LISTEN_PID"))) &&
- (1 == SSCANF (lpid, "%u", &pid)) && (getpid () == (pid_t) pid) &&
- (NULL != (nfds = getenv ("LISTEN_FDS"))) &&
+ if ((NULL != (nfds = getenv ("LISTEN_FDS"))) &&
(1 == SSCANF (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) &&
(cnt + 4 < FD_SETSIZE))
{
break;
}
}
- unsetenv ("LISTEN_PID");
unsetenv ("LISTEN_FDS");
}
#else
if ((NULL == sctx->lsocks) &&
(GNUNET_SYSERR ==
- GNUNET_SERVICE_get_server_addresses (sctx->serviceName, sctx->cfg,
+ GNUNET_SERVICE_get_server_addresses (sctx->service_name, sctx->cfg,
&sctx->addrs, &sctx->addrlens)))
return GNUNET_SYSERR;
sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES;
sctx->match_uid =
- GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName,
+ GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name,
"UNIX_MATCH_UID");
sctx->match_gid =
- GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName,
+ GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name,
"UNIX_MATCH_GID");
process_acl4 (&sctx->v4_denied, sctx, "REJECT_FROM");
process_acl4 (&sctx->v4_allowed, sctx, "ACCEPT_FROM");
char *un;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->serviceName,
+ GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->service_name,
"USERNAME", &un))
return NULL;
return un;
{
/* we get to create a directory -- and claim it
* as ours! */
- GNUNET_DISK_directory_create (rdir);
+ (void) GNUNET_DISK_directory_create (rdir);
if ((NULL != user) && (0 < strlen (user)))
GNUNET_DISK_file_change_owner (rdir, user);
}
/**
- * Task run during shutdown.
+ * Task run during shutdown. Stops the server/service.
*
- * @param cls unused
+ * @param cls the 'struct GNUNET_SERVICE_Context'
* @param tc unused
*/
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct GNUNET_SERVER_Handle *server = cls;
+ struct GNUNET_SERVICE_Context *service = cls;
+ struct GNUNET_SERVER_Handle *server = service->server;
- // FIXME: we should not unconditionally destroy the server
- // here (often only stopping 'listening' would be better)
- GNUNET_SERVER_destroy (server);
+ service->shutdown_task = GNUNET_SCHEDULER_NO_TASK;
+ if (0 != (service->options & GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN))
+ GNUNET_SERVER_stop_listening (server);
+ else
+ GNUNET_SERVER_destroy (server);
}
struct GNUNET_SERVICE_Context *sctx = cls;
unsigned int i;
+ if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
+ return;
+ (void) GNUNET_SPEEDUP_start_ (sctx->cfg);
GNUNET_RESOLVER_connect (sctx->cfg);
if (NULL != sctx->lsocks)
sctx->server =
while (NULL != sctx->addrs[i])
{
LOG (GNUNET_ERROR_TYPE_INFO, _("Failed to start `%s' at `%s'\n"),
- sctx->serviceName, GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
+ sctx->service_name, GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
i++;
}
}
{
/* install a task that will kill the server
* process if the scheduler ever gets a shutdown signal */
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
- sctx->server);
+ sctx->shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
+ sctx);
}
sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers));
memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers));
while (NULL != sctx->addrs[i])
{
LOG (GNUNET_ERROR_TYPE_INFO, _("Service `%s' runs at %s\n"),
- sctx->serviceName, GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
+ sctx->service_name, GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
i++;
}
}
* Detach from terminal.
*
* @param sctx service context
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
static int
detach_terminal (struct GNUNET_SERVICE_Context *sctx)
*
* @param argc number of command line arguments
* @param argv command line arguments
- * @param serviceName our service name
- * @param opt service options
+ * @param service_name our service name
+ * @param options service options
* @param task main task of the service
* @param task_cls closure for task
* @return GNUNET_SYSERR on error, GNUNET_OK
* if we shutdown nicely
*/
int
-GNUNET_SERVICE_run (int argc, char *const *argv, const char *serviceName,
- enum GNUNET_SERVICE_Options opt, GNUNET_SERVICE_Main task,
+GNUNET_SERVICE_run (int argc, char *const *argv, const char *service_name,
+ enum GNUNET_SERVICE_Options options, GNUNET_SERVICE_Main task,
void *task_cls)
{
#define HANDLE_ERROR do { GNUNET_break (0); goto shutdown; } while (0)
int err;
+ int ret;
char *cfg_fn;
char *loglev;
char *logfile;
GNUNET_GETOPT_OPTION_HELP (NULL),
GNUNET_GETOPT_OPTION_LOGLEVEL (&loglev),
GNUNET_GETOPT_OPTION_LOGFILE (&logfile),
- GNUNET_GETOPT_OPTION_VERSION (PACKAGE_VERSION),
+ GNUNET_GETOPT_OPTION_VERSION (PACKAGE_VERSION " " VCS_VERSION),
GNUNET_GETOPT_OPTION_END
};
err = 1;
loglev = NULL;
cfg_fn = GNUNET_strdup (GNUNET_DEFAULT_USER_CONFIG_FILE);
memset (&sctx, 0, sizeof (sctx));
- sctx.options = opt;
+ sctx.options = options;
sctx.ready_confirm_fd = -1;
sctx.ret = GNUNET_OK;
sctx.timeout = GNUNET_TIME_UNIT_FOREVER_REL;
sctx.task = task;
sctx.task_cls = task_cls;
- sctx.serviceName = serviceName;
+ sctx.service_name = service_name;
sctx.cfg = cfg = GNUNET_CONFIGURATION_create ();
+
/* setup subsystems */
- if (GNUNET_SYSERR ==
- GNUNET_GETOPT_run (serviceName, service_options, argc, argv))
+ ret = GNUNET_GETOPT_run (service_name, service_options, argc, argv);
+ if (GNUNET_SYSERR == ret)
goto shutdown;
- if (GNUNET_OK != GNUNET_log_setup (serviceName, loglev, logfile))
- HANDLE_ERROR;
- if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfg_fn))
+ if (GNUNET_NO == ret)
+ {
+ err = 0;
goto shutdown;
+ }
+ if (GNUNET_OK != GNUNET_log_setup (service_name, loglev, logfile))
+ HANDLE_ERROR;
+ if (GNUNET_YES ==
+ GNUNET_DISK_file_test (cfg_fn))
+ (void) GNUNET_CONFIGURATION_load (cfg, cfg_fn);
+ else
+ {
+ (void) GNUNET_CONFIGURATION_load (cfg, NULL);
+ if (0 != strcmp (cfg_fn, GNUNET_DEFAULT_USER_CONFIG_FILE))
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Could not access configuration file `%s'\n"),
+ cfg_fn);
+ }
if (GNUNET_OK != setup_service (&sctx))
goto shutdown;
if ((1 == do_daemonize) && (GNUNET_OK != detach_terminal (&sctx)))
if (GNUNET_OK != set_user_id (&sctx))
goto shutdown;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Service `%s' runs with configuration from `%s'\n", serviceName, cfg_fn);
+ "Service `%s' runs with configuration from `%s'\n", service_name, cfg_fn);
if ((GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_number (sctx.cfg, "TESTING",
"SKEW_OFFSET", &skew_offset)) &&
/* actually run service */
err = 0;
GNUNET_SCHEDULER_run (&service_task, &sctx);
-
/* shutdown */
if ((1 == do_daemonize) && (NULL != sctx.server))
pid_file_delete (&sctx);
LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "write");
GNUNET_break (0 == CLOSE (sctx.ready_confirm_fd));
}
+#if HAVE_MALLINFO
+ {
+ char *counter;
+
+ if ( (GNUNET_YES ==
+ GNUNET_CONFIGURATION_have_value (sctx.cfg, service_name,
+ "GAUGER_HEAP")) &&
+ (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (sctx.cfg, service_name,
+ "GAUGER_HEAP",
+ &counter)) )
+ {
+ struct mallinfo mi;
+ mi = mallinfo ();
+ GAUGER (service_name, counter, mi.usmblks, "blocks");
+ GNUNET_free (counter);
+ }
+ }
+#endif
+ GNUNET_SPEEDUP_stop_ ();
GNUNET_CONFIGURATION_destroy (cfg);
i = 0;
if (NULL != sctx.addrs)
* Run a service startup sequence within an existing
* initialized system.
*
- * @param serviceName our service name
+ * @param service_name our service name
* @param cfg configuration to use
+ * @param options service options
* @return NULL on error, service handle
*/
struct GNUNET_SERVICE_Context *
-GNUNET_SERVICE_start (const char *serviceName,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+GNUNET_SERVICE_start (const char *service_name,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ enum GNUNET_SERVICE_Options options)
{
int i;
struct GNUNET_SERVICE_Context *sctx;
sctx->ready_confirm_fd = -1; /* no daemonizing */
sctx->ret = GNUNET_OK;
sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
- sctx->serviceName = serviceName;
+ sctx->service_name = service_name;
sctx->cfg = cfg;
+ sctx->options = options;
/* setup subsystems */
if (GNUNET_OK != setup_service (sctx))
{
unsigned int i;
+#if HAVE_MALLINFO
+ {
+ char *counter;
+
+ if ( (GNUNET_YES ==
+ GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name,
+ "GAUGER_HEAP")) &&
+ (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_string (sctx->cfg, sctx->service_name,
+ "GAUGER_HEAP",
+ &counter)) )
+ {
+ struct mallinfo mi;
+
+ mi = mallinfo ();
+ GAUGER (sctx->service_name, counter, mi.usmblks, "blocks");
+ GNUNET_free (counter);
+ }
+ }
+#endif
+ if (GNUNET_SCHEDULER_NO_TASK != sctx->shutdown_task)
+ {
+ GNUNET_SCHEDULER_cancel (sctx->shutdown_task);
+ sctx->shutdown_task = GNUNET_SCHEDULER_NO_TASK;
+ }
if (NULL != sctx->server)
GNUNET_SERVER_destroy (sctx->server);
GNUNET_free_non_null (sctx->my_handlers);