[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20060 - in gnunet/src: arm ats chat core datastore dht fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20060 - in gnunet/src: arm ats chat core datastore dht fs hostlist include mesh namestore nat nse peerinfo statistics stream testing transport util vpn |
Date: |
Mon, 27 Feb 2012 12:00:10 +0100 |
Author: grothoff
Date: 2012-02-27 12:00:10 +0100 (Mon, 27 Feb 2012)
New Revision: 20060
Modified:
gnunet/src/arm/arm_api.c
gnunet/src/arm/do_start_process.c
gnunet/src/arm/gnunet-service-arm.c
gnunet/src/ats/test_ats_api_bandwidth_consumption.c
gnunet/src/ats/test_ats_api_scheduling.c
gnunet/src/chat/test_chat.c
gnunet/src/chat/test_chat_private.c
gnunet/src/core/test_core_api.c
gnunet/src/core/test_core_api_reliability.c
gnunet/src/core/test_core_api_send_to_self.c
gnunet/src/core/test_core_api_start_only.c
gnunet/src/core/test_core_defaults.conf
gnunet/src/core/test_core_quota_compliance.c
gnunet/src/datastore/perf_datastore_api.c
gnunet/src/datastore/test_datastore_api.c
gnunet/src/datastore/test_datastore_api_management.c
gnunet/src/datastore/test_defaults.conf
gnunet/src/dht/test_dht_api.c
gnunet/src/fs/test_fs_defaults.conf
gnunet/src/fs/test_fs_download.c
gnunet/src/fs/test_fs_download_indexed.c
gnunet/src/fs/test_fs_download_persistence.c
gnunet/src/fs/test_fs_list_indexed.c
gnunet/src/fs/test_fs_namespace.c
gnunet/src/fs/test_fs_namespace_list_updateable.c
gnunet/src/fs/test_fs_publish.c
gnunet/src/fs/test_fs_publish_persistence.c
gnunet/src/fs/test_fs_search.c
gnunet/src/fs/test_fs_search_persistence.c
gnunet/src/fs/test_fs_start_stop.c
gnunet/src/fs/test_fs_unindex.c
gnunet/src/fs/test_fs_unindex_persistence.c
gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c
gnunet/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
gnunet/src/hostlist/test_hostlist_defaults.conf
gnunet/src/include/gnunet_disk_lib.h
gnunet/src/include/gnunet_os_lib.h
gnunet/src/include/platform.h
gnunet/src/mesh/test_mesh_api.c
gnunet/src/mesh/test_mesh_local_1.c
gnunet/src/mesh/test_mesh_local_2.c
gnunet/src/namestore/test_namestore_api.c
gnunet/src/nat/nat.c
gnunet/src/nat/nat_mini.c
gnunet/src/nat/test_nat_test.c
gnunet/src/nse/test_nse_api.c
gnunet/src/peerinfo/test_peerinfo_api.c
gnunet/src/statistics/test_statistics_api.c
gnunet/src/statistics/test_statistics_api_loop.c
gnunet/src/statistics/test_statistics_api_watch.c
gnunet/src/stream/test_stream_local.c
gnunet/src/stream/test_stream_local_halfclose.c
gnunet/src/testing/test_testing_defaults.conf
gnunet/src/testing/testing.c
gnunet/src/testing/testing_group.c
gnunet/src/transport/gnunet-transport-certificate-creation.c
gnunet/src/transport/gnunet-transport-connect-running-peers.c
gnunet/src/transport/gnunet-transport.c
gnunet/src/transport/plugin_transport_http_server.c
gnunet/src/transport/plugin_transport_wlan.c
gnunet/src/transport/transport-testing.c
gnunet/src/util/crypto_random.c
gnunet/src/util/disk.c
gnunet/src/util/helper.c
gnunet/src/util/os_priority.c
gnunet/src/util/scheduler.c
gnunet/src/util/test_common_logging_runtime_loglevels.c
gnunet/src/util/test_os_start_process.c
gnunet/src/util/test_resolver_api.c
gnunet/src/util/test_strings.c
gnunet/src/vpn/test_gnunet_vpn.c
Log:
enabling use of pipes for signal communication also on UNIX to enable future
integration with Java services
Modified: gnunet/src/arm/arm_api.c
===================================================================
--- gnunet/src/arm/arm_api.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/arm/arm_api.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -410,7 +410,8 @@
{
/* Means we are ONLY running locally */
/* we're clearly running a test, don't daemonize */
- proc = do_start_process (NULL, loprefix, binary, "-c", config,
+ proc = do_start_process (GNUNET_NO,
+ NULL, loprefix, binary, "-c", config,
#if DEBUG_ARM
"-L", "DEBUG",
#endif
@@ -419,7 +420,8 @@
}
else
{
- proc = do_start_process (NULL, loprefix, binary, "-c", config,
+ proc = do_start_process (GNUNET_NO,
+ NULL, loprefix, binary, "-c", config,
#if DEBUG_ARM
"-L", "DEBUG",
#endif
Modified: gnunet/src/arm/do_start_process.c
===================================================================
--- gnunet/src/arm/do_start_process.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/arm/do_start_process.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -13,7 +13,8 @@
* @return handle of the started process, NULL on error
*/
static struct GNUNET_OS_Process *
-do_start_process (const SOCKTYPE * lsocks, const char *first_arg, ...)
+do_start_process (int pipe_control,
+ const SOCKTYPE * lsocks, const char *first_arg, ...)
{
va_list ap;
char **argv;
@@ -95,7 +96,7 @@
/* *INDENT-ON* */
va_end (ap);
argv[argv_size] = NULL;
- proc = GNUNET_OS_start_process_v (lsocks, argv[0], argv);
+ proc = GNUNET_OS_start_process_v (pipe_control, lsocks, argv[0], argv);
while (argv_size > 0)
GNUNET_free (argv[--argv_size]);
GNUNET_free (argv);
Modified: gnunet/src/arm/gnunet-service-arm.c
===================================================================
--- gnunet/src/arm/gnunet-service-arm.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/arm/gnunet-service-arm.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -152,6 +152,11 @@
*/
int is_default;
+ /**
+ * Should we use pipes to signal this process? (YES for Java binaries and if
we
+ * are on Windoze).
+ */
+ int pipe_control;
};
/**
@@ -311,11 +316,13 @@
GNUNET_assert (NULL == sl->proc);
if (GNUNET_YES == use_debug)
sl->proc =
- do_start_process (lsocks, loprefix, sl->binary, "-c", sl->config, "-L",
+ do_start_process (sl->pipe_control,
+ lsocks, loprefix, sl->binary, "-c", sl->config, "-L",
"DEBUG", options, NULL);
else
sl->proc =
- do_start_process (lsocks, loprefix, sl->binary, "-c", sl->config,
+ do_start_process (sl->pipe_control,
+ lsocks, loprefix, sl->binary, "-c", sl->config,
options, NULL);
if (sl->proc == NULL)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to start service `%s'\n"),
@@ -1070,6 +1077,12 @@
sl->config = config;
sl->backoff = GNUNET_TIME_UNIT_MILLISECONDS;
sl->restart_at = GNUNET_TIME_UNIT_FOREVER_ABS;
+#if WINDOWS
+ sl->pipe_control = GNUNET_YES;
+#else
+ if (GNUNET_CONFIGURATION_have_value (cfg, section, "PIPECONTROL"))
+ sl->pipe_control = GNUNET_CONFIGURATION_get_value_yesno (cfg, section,
"PIPECONTROL");
+#endif
GNUNET_CONTAINER_DLL_insert (running_head, running_tail, sl);
if (GNUNET_YES !=
GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "AUTOSTART"))
Modified: gnunet/src/ats/test_ats_api_bandwidth_consumption.c
===================================================================
--- gnunet/src/ats/test_ats_api_bandwidth_consumption.c 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/ats/test_ats_api_bandwidth_consumption.c 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -199,7 +199,7 @@
start_arm (const char *cfgname)
{
arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
"-L", "DEBUG",
Modified: gnunet/src/ats/test_ats_api_scheduling.c
===================================================================
--- gnunet/src/ats/test_ats_api_scheduling.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/ats/test_ats_api_scheduling.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -156,7 +156,7 @@
start_arm (const char *cfgname)
{
arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
"-L", "DEBUG",
Modified: gnunet/src/chat/test_chat.c
===================================================================
--- gnunet/src/chat/test_chat.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/chat/test_chat.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -119,7 +119,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/chat/test_chat_private.c
===================================================================
--- gnunet/src/chat/test_chat_private.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/chat/test_chat_private.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -133,7 +133,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/core/test_core_api.c
===================================================================
--- gnunet/src/core/test_core_api.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/core/test_core_api.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -319,7 +319,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/core/test_core_api_reliability.c
===================================================================
--- gnunet/src/core/test_core_api_reliability.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/core/test_core_api_reliability.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -442,7 +442,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/core/test_core_api_send_to_self.c
===================================================================
--- gnunet/src/core/test_core_api_send_to_self.c 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/core/test_core_api_send_to_self.c 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -170,7 +170,7 @@
core_cfg = GNUNET_CONFIGURATION_create ();
arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/core/test_core_api_start_only.c
===================================================================
--- gnunet/src/core/test_core_api_start_only.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/core/test_core_api_start_only.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -148,7 +148,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/core/test_core_defaults.conf
===================================================================
--- gnunet/src/core/test_core_defaults.conf 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/core/test_core_defaults.conf 2012-02-27 11:00:10 UTC (rev
20060)
@@ -47,4 +47,7 @@
AUTOSTART = NO
[dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
Modified: gnunet/src/core/test_core_quota_compliance.c
===================================================================
--- gnunet/src/core/test_core_quota_compliance.c 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/core/test_core_quota_compliance.c 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -569,7 +569,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/datastore/perf_datastore_api.c
===================================================================
--- gnunet/src/datastore/perf_datastore_api.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/datastore/perf_datastore_api.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -343,7 +343,7 @@
GNUNET_snprintf (cfg_name, sizeof (cfg_name),
"test_datastore_api_data_%s.conf", plugin_name);
proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/datastore/test_datastore_api.c
===================================================================
--- gnunet/src/datastore/test_datastore_api.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/datastore/test_datastore_api.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -526,7 +526,7 @@
"test_datastore_api_data_%s.conf", plugin_name);
#if START_DATASTORE
proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/datastore/test_datastore_api_management.c
===================================================================
--- gnunet/src/datastore/test_datastore_api_management.c 2012-02-27
10:54:36 UTC (rev 20059)
+++ gnunet/src/datastore/test_datastore_api_management.c 2012-02-27
11:00:10 UTC (rev 20060)
@@ -311,7 +311,7 @@
GNUNET_snprintf (cfg_name, sizeof (cfg_name),
"test_datastore_api_data_%s.conf", plugin_name);
proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/datastore/test_defaults.conf
===================================================================
--- gnunet/src/datastore/test_defaults.conf 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/datastore/test_defaults.conf 2012-02-27 11:00:10 UTC (rev
20060)
@@ -15,4 +15,7 @@
AUTOSTART = NO
[dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
Modified: gnunet/src/dht/test_dht_api.c
===================================================================
--- gnunet/src/dht/test_dht_api.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/dht/test_dht_api.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -263,7 +263,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_defaults.conf
===================================================================
--- gnunet/src/fs/test_fs_defaults.conf 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/fs/test_fs_defaults.conf 2012-02-27 11:00:10 UTC (rev 20060)
@@ -75,4 +75,7 @@
AUTOSTART = NO
[dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
Modified: gnunet/src/fs/test_fs_download.c
===================================================================
--- gnunet/src/fs/test_fs_download.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/fs/test_fs_download.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -245,7 +245,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_download_indexed.c
===================================================================
--- gnunet/src/fs/test_fs_download_indexed.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/fs/test_fs_download_indexed.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -246,7 +246,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_download_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_download_persistence.c 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/fs/test_fs_download_persistence.c 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -295,7 +295,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_list_indexed.c
===================================================================
--- gnunet/src/fs/test_fs_list_indexed.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/fs/test_fs_list_indexed.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -188,7 +188,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_namespace.c
===================================================================
--- gnunet/src/fs/test_fs_namespace.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/fs/test_fs_namespace.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -67,7 +67,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_namespace_list_updateable.c
===================================================================
--- gnunet/src/fs/test_fs_namespace_list_updateable.c 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/fs/test_fs_namespace_list_updateable.c 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -71,7 +71,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_publish.c
===================================================================
--- gnunet/src/fs/test_fs_publish.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/fs/test_fs_publish.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -173,7 +173,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_publish_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_publish_persistence.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/fs/test_fs_publish_persistence.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -236,7 +236,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_search.c
===================================================================
--- gnunet/src/fs/test_fs_search.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/fs/test_fs_search.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -174,7 +174,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_search_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_search_persistence.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/fs/test_fs_search_persistence.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -236,7 +236,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_start_stop.c
===================================================================
--- gnunet/src/fs/test_fs_start_stop.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/fs/test_fs_start_stop.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -57,7 +57,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_unindex.c
===================================================================
--- gnunet/src/fs/test_fs_unindex.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/fs/test_fs_unindex.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -187,7 +187,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/fs/test_fs_unindex_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_unindex_persistence.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/fs/test_fs_unindex_persistence.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -249,7 +249,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist.c 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist.c 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -140,7 +140,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c 2012-02-27
10:54:36 UTC (rev 20059)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c 2012-02-27
11:00:10 UTC (rev 20060)
@@ -370,7 +370,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
@@ -406,7 +406,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c 2012-02-27
10:54:36 UTC (rev 20059)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c 2012-02-27
11:00:10 UTC (rev 20060)
@@ -144,7 +144,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/hostlist/test_hostlist_defaults.conf
===================================================================
--- gnunet/src/hostlist/test_hostlist_defaults.conf 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/hostlist/test_hostlist_defaults.conf 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -50,4 +50,7 @@
AUTOSTART = NO
[dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
Modified: gnunet/src/include/gnunet_disk_lib.h
===================================================================
--- gnunet/src/include/gnunet_disk_lib.h 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/include/gnunet_disk_lib.h 2012-02-27 11:00:10 UTC (rev
20060)
@@ -32,11 +32,6 @@
#endif
/**
- * Opaque handle used to access files.
- */
-struct GNUNET_DISK_FileHandle;
-
-/**
* Handle used to manage a pipe.
*/
struct GNUNET_DISK_PipeHandle;
@@ -759,37 +754,7 @@
int
GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h);
-/**
- * Creates a named pipe/FIFO and opens it
- * @param fn pointer to the name of the named pipe or to NULL
- * @param flags open flags
- * @param perm access permissions
- * @return pipe handle on success, NULL on error
- */
-struct GNUNET_DISK_FileHandle *
-GNUNET_DISK_npipe_create (char **fn, enum GNUNET_DISK_OpenFlags flags,
- enum GNUNET_DISK_AccessPermissions perm);
-/**
- * Opens already existing named pipe/FIFO
- *
- * @param fn name of an existing named pipe
- * @param flags open flags
- * @param perm access permissions
- * @return pipe handle on success, NULL on error
- */
-struct GNUNET_DISK_FileHandle *
-GNUNET_DISK_npipe_open (const char *fn, enum GNUNET_DISK_OpenFlags flags,
- enum GNUNET_DISK_AccessPermissions perm);
-
-/**
- * Closes a named pipe/FIFO
- * @param pipe named pipe
- * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
- */
-int
-GNUNET_DISK_npipe_close (struct GNUNET_DISK_FileHandle *pipe);
-
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
Modified: gnunet/src/include/gnunet_os_lib.h
===================================================================
--- gnunet/src/include/gnunet_os_lib.h 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/include/gnunet_os_lib.h 2012-02-27 11:00:10 UTC (rev 20060)
@@ -27,6 +27,16 @@
* @author Ioana Patrascu
* @author Tzvetan Horozov
* @author Milan
+ *
+ * This code manages child processes. We can communicate with child
+ * processes using signals. Because signals are not supported on W32
+ * and Java (at least not nicely), we can alternatively use a pipe
+ * to send signals to the child processes (if the child process is
+ * a full-blown GNUnet process that supports reading signals from
+ * a pipe, of course). Naturally, this also only works for 'normal'
+ * termination via signals, and not as a replacement for SIGKILL.
+ * Thus using pipes to communicate signals should only be enabled if
+ * the child is a Java process OR if we are on Windoze.
*/
#ifndef GNUNET_OS_LIB_H
@@ -201,7 +211,7 @@
/**
- * Sends sig to the process
+ * Sends a signal to the process
*
* @param proc pointer to process structure
* @param sig signal
@@ -219,6 +229,7 @@
void
GNUNET_OS_process_close (struct GNUNET_OS_Process *proc);
+
/**
* Get the pid of the process in question
*
@@ -229,6 +240,7 @@
pid_t
GNUNET_OS_process_get_pid (struct GNUNET_OS_Process *proc);
+
/**
* Set process priority
*
@@ -241,10 +253,10 @@
enum GNUNET_SCHEDULER_Priority prio);
-
/**
* Start a process.
*
+ * @param pipe_control should a pipe be used to send signals to the child?
* @param pipe_stdin pipe to use to send input to child process (or NULL)
* @param pipe_stdout pipe to use to get output from child process (or NULL)
* @param filename name of the binary
@@ -252,7 +264,8 @@
* @return pointer to process structure of the new process, NULL on error
*/
struct GNUNET_OS_Process *
-GNUNET_OS_start_process_vap (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process_vap (int pipe_control,
+ struct GNUNET_DISK_PipeHandle *pipe_stdin,
struct GNUNET_DISK_PipeHandle *pipe_stdout,
const char *filename,
char *const argv[]);
@@ -261,6 +274,7 @@
/**
* Start a process.
*
+ * @param pipe_control should a pipe be used to send signals to the child?
* @param pipe_stdin pipe to use to send input to child process (or NULL)
* @param pipe_stdout pipe to use to get output from child process (or NULL)
* @param filename name of the binary
@@ -268,7 +282,8 @@
* @return pointer to process structure of the new process, NULL on error
*/
struct GNUNET_OS_Process *
-GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process (int pipe_control,
+ struct GNUNET_DISK_PipeHandle *pipe_stdin,
struct GNUNET_DISK_PipeHandle *pipe_stdout,
const char *filename, ...);
@@ -276,6 +291,7 @@
/**
* Start a process.
*
+ * @param pipe_control should a pipe be used to send signals to the child?
* @param pipe_stdin pipe to use to send input to child process (or NULL)
* @param pipe_stdout pipe to use to get output from child process (or NULL)
* @param filename name of the binary
@@ -283,13 +299,15 @@
* @return pointer to process structure of the new process, NULL on error
*/
struct GNUNET_OS_Process *
-GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process_va (int pipe_control,
+ struct GNUNET_DISK_PipeHandle *pipe_stdin,
struct GNUNET_DISK_PipeHandle *pipe_stdout,
const char *filename, va_list va);
/**
* Start a process.
*
+ * @param pipe_control should a pipe be used to send signals to the child?
* @param lsocks array of listen sockets to dup systemd-style (or NULL);
* must be NULL on platforms where dup is not supported
* @param filename name of the binary
@@ -298,7 +316,9 @@
* @return pointer to process structure of the new process, NULL on error
*/
struct GNUNET_OS_Process *
-GNUNET_OS_start_process_v (const SOCKTYPE *lsocks, const char *filename,
+GNUNET_OS_start_process_v (int pipe_control,
+ const SOCKTYPE *lsocks,
+ const char *filename,
char *const argv[]);
@@ -307,6 +327,7 @@
*/
struct GNUNET_OS_CommandHandle;
+
/**
* Type of a function to process a line of output.
*
@@ -315,6 +336,7 @@
*/
typedef void (*GNUNET_OS_LineProcessor) (void *cls, const char *line);
+
/**
* Stop/kill a command.
*
@@ -370,7 +392,13 @@
/**
- * Connects this process to its parent via pipe
+ * Connects this process to its parent via pipe;
+ * essentially, the parent control handler will read signal numbers
+ * from the 'GNUNET_OS_CONTROL_PIPE' (as given in an environment
+ * variable) and raise those signals.
+ *
+ * @param cls closure (unused)
+ * @param tc scheduler context (unused)
*/
void
GNUNET_OS_install_parent_control_handler (void *cls,
Modified: gnunet/src/include/platform.h
===================================================================
--- gnunet/src/include/platform.h 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/include/platform.h 2012-02-27 11:00:10 UTC (rev 20060)
@@ -107,6 +107,7 @@
#include <stdarg.h>
#include <errno.h>
#include <signal.h>
+#include <libgen.h>
#ifdef WINDOWS
#include <malloc.h> /* for alloca(), on other OSes it's in
stdlib.h */
#endif
Modified: gnunet/src/mesh/test_mesh_api.c
===================================================================
--- gnunet/src/mesh/test_mesh_api.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/mesh/test_mesh_api.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -139,7 +139,7 @@
#endif
NULL);
arm_pid =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
"-L", "DEBUG",
Modified: gnunet/src/mesh/test_mesh_local_1.c
===================================================================
--- gnunet/src/mesh/test_mesh_local_1.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/mesh/test_mesh_local_1.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -300,7 +300,7 @@
#endif
NULL);
arm_pid =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
"-L", "DEBUG",
Modified: gnunet/src/mesh/test_mesh_local_2.c
===================================================================
--- gnunet/src/mesh/test_mesh_local_2.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/mesh/test_mesh_local_2.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -293,7 +293,7 @@
#endif
NULL);
arm_pid =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
"-L", "DEBUG",
Modified: gnunet/src/namestore/test_namestore_api.c
===================================================================
--- gnunet/src/namestore/test_namestore_api.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/namestore/test_namestore_api.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -40,7 +40,7 @@
static void
start_arm (const char *cfgname)
{
- arm = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm", "-c", cfgname,
#if VERBOSE_PEERS
"-L", "DEBUG",
Modified: gnunet/src/nat/nat.c
===================================================================
--- gnunet/src/nat/nat.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/nat/nat.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -843,7 +843,7 @@
#endif
/* Start the server process */
h->server_proc =
- GNUNET_OS_start_process (NULL, h->server_stdout,
+ GNUNET_OS_start_process (GNUNET_NO, NULL, h->server_stdout,
"gnunet-helper-nat-server",
"gnunet-helper-nat-server",
h->internal_address, NULL);
@@ -1342,7 +1342,8 @@
inet4, (unsigned int) h->adv_port);
#endif
proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-helper-nat-client",
+ GNUNET_OS_start_process (GNUNET_NO,
+ NULL, NULL, "gnunet-helper-nat-client",
"gnunet-helper-nat-client", h->internal_address,
inet4, port_as_string, NULL);
if (NULL == proc)
Modified: gnunet/src/nat/nat_mini.c
===================================================================
--- gnunet/src/nat/nat_mini.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/nat/nat_mini.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -176,7 +176,7 @@
return NULL;
}
eh->eip =
- GNUNET_OS_start_process (NULL, eh->opipe, "external-ip", "external-ip",
+ GNUNET_OS_start_process (GNUNET_NO, NULL, eh->opipe, "external-ip",
"external-ip",
NULL);
if (NULL == eh->eip)
{
Modified: gnunet/src/nat/test_nat_test.c
===================================================================
--- gnunet/src/nat/test_nat_test.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/nat/test_nat_test.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -118,7 +118,7 @@
}
gns =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-nat-server",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-nat-server",
"gnunet-nat-server",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/nse/test_nse_api.c
===================================================================
--- gnunet/src/nse/test_nse_api.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/nse/test_nse_api.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -110,7 +110,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
"-L", "DEBUG",
Modified: gnunet/src/peerinfo/test_peerinfo_api.c
===================================================================
--- gnunet/src/peerinfo/test_peerinfo_api.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/peerinfo/test_peerinfo_api.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -179,7 +179,7 @@
GNUNET_GETOPT_OPTION_END
};
proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-peerinfo",
"gnunet-service-peerinfo",
#if DEBUG_PEERINFO
"-L", "DEBUG",
Modified: gnunet/src/statistics/test_statistics_api.c
===================================================================
--- gnunet/src/statistics/test_statistics_api.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/statistics/test_statistics_api.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -144,7 +144,7 @@
struct GNUNET_OS_Process *proc;
proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL,
"gnunet-service-statistics",
"gnunet-service-statistics",
#if DEBUG_STATISTICS
"-L", "DEBUG",
@@ -170,7 +170,7 @@
#if START_SERVICE
/* restart to check persistence! */
proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL,
"gnunet-service-statistics",
"gnunet-service-statistics",
#if DEBUG_STATISTICS
"-L", "DEBUG",
Modified: gnunet/src/statistics/test_statistics_api_loop.c
===================================================================
--- gnunet/src/statistics/test_statistics_api_loop.c 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/statistics/test_statistics_api_loop.c 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -97,7 +97,7 @@
struct GNUNET_OS_Process *proc;
proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL,
"gnunet-service-statistics",
"gnunet-service-statistics",
#if DEBUG_STATISTICS
"-L", "DEBUG",
Modified: gnunet/src/statistics/test_statistics_api_watch.c
===================================================================
--- gnunet/src/statistics/test_statistics_api_watch.c 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/statistics/test_statistics_api_watch.c 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -127,7 +127,7 @@
struct GNUNET_OS_Process *proc;
proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL,
"gnunet-service-statistics",
"gnunet-service-statistics",
#if VERBOSE
"-L", "DEBUG",
Modified: gnunet/src/stream/test_stream_local.c
===================================================================
--- gnunet/src/stream/test_stream_local.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/stream/test_stream_local.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -331,7 +331,7 @@
#endif
NULL);
arm_pid =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
"-L", "DEBUG",
Modified: gnunet/src/stream/test_stream_local_halfclose.c
===================================================================
--- gnunet/src/stream/test_stream_local_halfclose.c 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/stream/test_stream_local_halfclose.c 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -327,7 +327,7 @@
#endif
NULL);
arm_pid =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
"-L", "DEBUG",
Modified: gnunet/src/testing/test_testing_defaults.conf
===================================================================
--- gnunet/src/testing/test_testing_defaults.conf 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/testing/test_testing_defaults.conf 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -61,3 +61,6 @@
[dv]
AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/testing/testing.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -97,11 +97,9 @@
GNUNET_NO, &test_address, &empty);
if (GNUNET_YES == empty)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Skipping empty HELLO address of peer %s\n",
GNUNET_i2s (&daemon->id));
-#endif
return;
}
#endif
@@ -113,11 +111,9 @@
if (daemon->server != NULL)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' from transport service of `%4s', disconnecting
core!\n",
"HELLO", GNUNET_i2s (&daemon->id));
-#endif
GNUNET_CORE_disconnect (daemon->server);
daemon->server = NULL;
}
@@ -135,12 +131,9 @@
GNUNET_TRANSPORT_get_hello_cancel (daemon->ghh);
daemon->ghh = NULL;
}
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' from transport service of `%4s'\n", "HELLO",
GNUNET_i2s (&daemon->id));
-#endif
-
GNUNET_free_non_null (daemon->hello);
daemon->hello = GNUNET_malloc (msize);
memcpy (daemon->hello, message, msize);
@@ -192,11 +185,8 @@
char *dst;
int bytes_read;
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %s FSM is in phase %u.\n",
GNUNET_i2s (&d->id), d->phase);
-#endif
-
d->task = GNUNET_SCHEDULER_NO_TASK;
switch (d->phase)
{
@@ -229,10 +219,8 @@
return;
}
GNUNET_OS_process_close (d->proc);
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successfully copied configuration file.\n");
-#endif
d->phase = SP_COPIED;
/* fall-through */
case SP_COPIED:
@@ -254,14 +242,12 @@
}
if (NULL == d->hostname)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting `%s', with command `%s %s %s %s'.\n",
"gnunet-peerinfo", "gnunet-peerinfo", "-c", d->cfgfile,
"-sq");
-#endif
d->proc =
- GNUNET_OS_start_process (NULL, d->pipe_stdout, "gnunet-peerinfo",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, d->pipe_stdout,
"gnunet-peerinfo",
"gnunet-peerinfo", "-c", d->cfgfile,
"-sq",
NULL);
GNUNET_DISK_pipe_close_end (d->pipe_stdout,
GNUNET_DISK_PIPE_END_WRITE);
@@ -273,15 +259,13 @@
else
dst = GNUNET_strdup (d->hostname);
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting `%s', with command `%s %s %s %s %s %s'.\n",
"gnunet-peerinfo", "ssh", dst, "gnunet-peerinfo", "-c",
d->cfgfile, "-sq");
-#endif
if (d->ssh_port_str == NULL)
{
- d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh",
"ssh",
+ d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, d->pipe_stdout,
"ssh", "ssh",
#if !DEBUG_TESTING
"-q",
#endif
@@ -291,7 +275,7 @@
else
{
d->proc =
- GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", "ssh",
"-p",
+ GNUNET_OS_start_process (GNUNET_NO, NULL, d->pipe_stdout, "ssh",
"ssh", "-p",
d->ssh_port_str,
#if !DEBUG_TESTING
"-q",
@@ -317,10 +301,8 @@
GNUNET_DISK_pipe_close (d->pipe_stdout);
return;
}
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Started `%s', waiting for hostkey.\n", "gnunet-peerinfo");
-#endif
d->phase = SP_HOSTKEY_CREATE;
d->task =
GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining
@@ -410,9 +392,7 @@
{
d->phase = SP_TOPOLOGY_SETUP;
}
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully got hostkey!\n");
-#endif
/* Fall through */
case SP_HOSTKEY_CREATED:
/* wait for topology finished */
@@ -435,18 +415,14 @@
/* start GNUnet on remote host */
if (NULL == d->hostname)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting `%s', with command `%s %s %s %s %s %s'.\n",
"gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-L", "DEBUG",
"-s");
-#endif
d->proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm",
"-c",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm",
"gnunet-arm", "-c",
d->cfgfile,
-#if DEBUG_TESTING
"-L", "DEBUG",
-#endif
"-s", "-q", "-T",
GNUNET_TIME_relative_to_string
(GNUNET_TIME_absolute_get_remaining
@@ -459,15 +435,13 @@
else
dst = GNUNET_strdup (d->hostname);
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Starting `%s', with command `%s %s %s %s %s %s %s %s'.\n",
"gnunet-arm", "ssh", dst, "gnunet-arm", "-c", d->cfgfile,
"-L", "DEBUG", "-s", "-q");
-#endif
if (d->ssh_port_str == NULL)
{
- d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+ d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
#if !DEBUG_TESTING
"-q",
#endif
@@ -484,7 +458,7 @@
{
d->proc =
- GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-p",
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-p",
d->ssh_port_str,
#if !DEBUG_TESTING
"-q",
@@ -514,11 +488,9 @@
_("Failed to start `ssh' process.\n"));
return;
}
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Started `%s', waiting for `%s' to be up.\n", "gnunet-arm",
"gnunet-service-core");
-#endif
d->phase = SP_START_ARMING;
d->task =
GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
@@ -561,15 +533,11 @@
d);
return;
}
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully started `%s'.\n",
"gnunet-arm");
-#endif
GNUNET_free (d->proc);
d->phase = SP_START_CORE;
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling CORE_connect\n");
-#endif
/* Fall through */
case SP_START_CORE:
if (d->server != NULL)
@@ -588,12 +556,9 @@
_("Failed to connect to transport service!\n"));
return;
}
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connected to transport service `%s', getting HELLO\n",
GNUNET_i2s (&d->id));
-#endif
-
d->ghh = GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
/* FIXME: store task ID somewhere! */
GNUNET_SCHEDULER_add_now (¬ify_daemon_started, d);
@@ -669,9 +634,7 @@
return;
}
#endif
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service startup complete!\n");
-#endif
cb = d->cb;
d->cb = NULL;
d->phase = SP_START_DONE;
@@ -706,9 +669,7 @@
return;
}
#endif
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service shutdown complete.\n");
-#endif
if (NULL != d->dead_cb)
d->dead_cb (d->dead_cb_cls, NULL);
break;
@@ -784,9 +745,7 @@
GNUNET_free (d);
return;
}
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer shutdown complete.\n");
-#endif
if (d->server != NULL)
{
GNUNET_CORE_disconnect (d->server);
@@ -849,10 +808,8 @@
d->update_cb (d->update_cb_cls, _("`scp' did not complete
cleanly.\n"));
return;
}
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successfully copied configuration file.\n");
-#endif
if (NULL != d->update_cb)
d->update_cb (d->update_cb_cls, NULL);
d->phase = SP_START_DONE;
@@ -937,18 +894,15 @@
/* Check if this is a local or remote process */
if (NULL != d->hostname)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting gnunet-arm with config `%s' on host `%s'.\n",
d->cfgfile, d->hostname);
-#endif
-
if (d->username != NULL)
GNUNET_asprintf (&arg, "address@hidden", d->username, d->hostname);
else
arg = GNUNET_strdup (d->hostname);
- d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+ d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
#if !DEBUG_TESTING
"-q",
#endif
@@ -967,11 +921,9 @@
}
else
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting gnunet-arm with config `%s' locally.\n", d->cfgfile);
-#endif
- d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm",
+ d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm",
"gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
@@ -1010,29 +962,23 @@
GNUNET_assert (d->running == GNUNET_YES);
GNUNET_assert (d->phase == SP_START_DONE);
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Starting service %s for peer `%4s'\n"), service,
GNUNET_i2s (&d->id));
-#endif
-
d->phase = SP_SERVICE_START;
d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
/* Check if this is a local or remote process */
if (NULL != d->hostname)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting gnunet-arm with config `%s' on host `%s'.\n",
d->cfgfile, d->hostname);
-#endif
-
if (d->username != NULL)
GNUNET_asprintf (&arg, "address@hidden", d->username, d->hostname);
else
arg = GNUNET_strdup (d->hostname);
- d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+ d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
#if !DEBUG_TESTING
"-q",
#endif
@@ -1052,11 +998,9 @@
}
else
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting gnunet-arm with config `%s' locally.\n", d->cfgfile);
-#endif
- d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm",
+ d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm",
"gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
@@ -1169,10 +1113,8 @@
GNUNET_asprintf (&temp_file_name, "%s/gnunet-testing-config", servicehome);
ret->cfgfile = GNUNET_DISK_mktemp (temp_file_name);
GNUNET_free (temp_file_name);
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Setting up peer with configuration file `%s'.\n", ret->cfgfile);
-#endif
if (NULL == ret->cfgfile)
{
GNUNET_free_non_null (ret->ssh_port_str);
@@ -1249,10 +1191,8 @@
/* copy directory to remote host */
if (NULL != hostname)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Copying configuration directory to host `%s'.\n", hostname);
-#endif
baseservicehome = GNUNET_strdup (servicehome);
/* Remove trailing /'s */
while (baseservicehome[strlen (baseservicehome) - 1] == '/')
@@ -1270,21 +1210,19 @@
GNUNET_free (baseservicehome);
if (ret->ssh_port_str == NULL)
{
- ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", "-r",
+ ret->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp",
"scp", "-r",
#if !DEBUG_TESTING
"-q",
#endif
servicehome, arg, NULL);
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"copying directory with command scp -r %s %s\n",
servicehome, arg);
-#endif
}
else
{
ret->proc =
- GNUNET_OS_start_process (NULL, NULL, "scp", "scp", "-r", "-P",
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", "-r",
"-P",
ret->ssh_port_str,
#if !DEBUG_TESTING
"-q",
@@ -1322,10 +1260,8 @@
GNUNET_free (servicehome);
return ret;
}
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No need to copy configuration file since we are running
locally.\n");
-#endif
ret->phase = SP_COPIED;
/* FIXME: why add_cont? */
GNUNET_SCHEDULER_add_continuation (&start_fsm, ret,
@@ -1383,28 +1319,22 @@
/* state clean up and notifications */
GNUNET_free_non_null (d->hello);
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
GNUNET_i2s (&d->id));
-#endif
-
d->phase = SP_START_ARMING;
/* Check if this is a local or remote process */
if (NULL != d->hostname)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' on host `%s'.\n",
d->cfgfile, d->hostname);
-#endif
-
if (d->username != NULL)
GNUNET_asprintf (&arg, "address@hidden", d->username, d->hostname);
else
arg = GNUNET_strdup (d->hostname);
- d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+ d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
#if !DEBUG_TESTING
"-q",
#endif
@@ -1419,11 +1349,9 @@
}
else
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
-#endif
- d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm",
+ d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm",
"gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
@@ -1466,10 +1394,8 @@
d->phase = SP_START_DONE;
}
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
GNUNET_i2s (&d->id));
-#endif
if (d->churned_services != NULL)
{
d->dead_cb (d->dead_cb_cls, "A service has already been turned off!!");
@@ -1481,18 +1407,15 @@
/* Check if this is a local or remote process */
if (NULL != d->hostname)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' on host `%s'.\n",
d->cfgfile, d->hostname);
-#endif
-
if (d->username != NULL)
GNUNET_asprintf (&arg, "address@hidden", d->username, d->hostname);
else
arg = GNUNET_strdup (d->hostname);
- d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+ d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
#if !DEBUG_TESTING
"-q",
#endif
@@ -1511,11 +1434,9 @@
}
else
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
-#endif
- d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm",
+ d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm",
"gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
@@ -1556,10 +1477,8 @@
if (NULL != d->cb)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Setting d->dead on peer `%4s'\n"),
GNUNET_i2s (&d->id));
-#endif
d->dead = GNUNET_YES;
return;
}
@@ -1604,10 +1523,8 @@
}
*/
/* shutdown ARM process (will terminate others) */
-#if DEBUG_TESTING
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Terminating peer `%4s'\n" ,
GNUNET_i2s (&d->id));
-#endif
d->phase = SP_SHUTDOWN_START;
d->running = GNUNET_NO;
if (allow_restart == GNUNET_YES)
@@ -1622,18 +1539,15 @@
/* Check if this is a local or remote process */
if (NULL != d->hostname)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' on host `%s'.\n",
d->cfgfile, d->hostname);
-#endif
-
if (d->username != NULL)
GNUNET_asprintf (&arg, "address@hidden", d->username, d->hostname);
else
arg = GNUNET_strdup (d->hostname);
- d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+ d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
#if !DEBUG_TESTING
"-q",
#endif
@@ -1652,11 +1566,9 @@
}
else
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
-#endif
- d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm",
+ d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "gnunet-arm",
"gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
#endif
@@ -1715,17 +1627,15 @@
cb (cb_cls, NULL);
return;
}
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Copying updated configuration file to remote host `%s'.\n",
d->hostname);
-#endif
d->phase = SP_CONFIG_UPDATE;
if (NULL != d->username)
GNUNET_asprintf (&arg, "address@hidden:%s", d->username, d->hostname,
d->cfgfile);
else
GNUNET_asprintf (&arg, "%s:%s", d->hostname, d->cfgfile);
- d->proc = GNUNET_OS_start_process (NULL, NULL, "scp", "scp",
+ d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp",
#if !DEBUG_TESTING
"-q",
#endif
@@ -1915,11 +1825,8 @@
{
struct GNUNET_TESTING_ConnectContext *ctx = cls;
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peer %s to peer %s\n",
ctx->d1->shortname, GNUNET_i2s (peer));
-#endif
-
if (0 != memcmp (&ctx->d2->id, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
ctx->connected = GNUNET_YES;
@@ -1949,18 +1856,14 @@
{
hello = GNUNET_HELLO_get_header (ctx->d2->hello);
GNUNET_assert (hello != NULL);
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Offering hello of %s to %s\n",
ctx->d2->shortname, ctx->d1->shortname);
-#endif
GNUNET_TRANSPORT_offer_hello (ctx->d1th, hello, NULL, NULL);
GNUNET_assert (ctx->d1core != NULL);
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending connect request to TRANSPORT of %s for peer %s\n",
GNUNET_i2s (&ctx->d1->id),
GNUNET_h2s (&ctx->d2->id.hashPubKey));
-#endif
GNUNET_TRANSPORT_try_connect (ctx->d1th, &ctx->d2->id);
ctx->timeout_hello =
GNUNET_TIME_relative_add (ctx->timeout_hello,
@@ -1989,13 +1892,10 @@
if (connect_ctx->send_hello == GNUNET_NO)
{
GNUNET_TRANSPORT_try_connect (connect_ctx->d1th, &connect_ctx->d2->id);
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending connect request to TRANSPORT of %s for peer %s\n",
connect_ctx->d1->shortname, connect_ctx->d2->shortname);
-#endif
}
-
}
@@ -2015,11 +1915,9 @@
ctx->timeout_task = GNUNET_SCHEDULER_NO_TASK;
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return;
-#if DEBUG_TESTING_RECONNECT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"re-attempting connect of peer %s to peer %s\n",
ctx->d1->shortname, ctx->d2->shortname);
-#endif
ctx->connect_attempts--;
GNUNET_assert (ctx->d1core == NULL);
ctx->d1core_ready = GNUNET_NO;
@@ -2040,10 +1938,8 @@
/* Don't know reason for initial connect failure, update the HELLO for the
second peer */
if (NULL != ctx->d2->hello)
{
-#if DEBUG_TESTING_RECONNECT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "updating %s's HELLO\n",
ctx->d2->shortname);
-#endif
GNUNET_free (ctx->d2->hello);
ctx->d2->hello = NULL;
if (NULL != ctx->d2->th)
@@ -2059,21 +1955,17 @@
ctx->d2->ghh =
GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
}
-#if DEBUG_TESTING_RECONNECT
else
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "didn't have %s's HELLO\n",
ctx->d2->shortname);
}
-#endif
if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL))
{
-#if DEBUG_TESTING_RECONNECT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"didn't have %s's HELLO, trying to get it now\n",
ctx->d2->shortname);
-#endif
ctx->d2->th =
GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL,
NULL);
@@ -2090,7 +1982,6 @@
ctx->d2->ghh =
GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
}
-#if DEBUG_TESTING_RECONNECT
else
{
if (NULL == ctx->d2->hello)
@@ -2100,14 +1991,11 @@
ctx->d2->shortname);
}
}
-#endif
if (ctx->send_hello == GNUNET_YES)
{
-#if DEBUG_TESTING_RECONNECT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending %s's HELLO to %s\n",
ctx->d1->shortname, ctx->d2->shortname);
-#endif
ctx->d1th =
GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL,
NULL, NULL);
@@ -2126,10 +2014,8 @@
}
else
{
-#if DEBUG_TESTING_RECONNECT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to reconnect %s to %s\n",
ctx->d1->shortname, ctx->d2->shortname);
-#endif
GNUNET_TRANSPORT_try_connect (ctx->d1th, &ctx->d2->id);
}
ctx->timeout_task =
@@ -2177,10 +2063,8 @@
/* Peer not already connected, need to schedule connect request! */
if (ctx->d1core == NULL)
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peers are NOT connected, connecting to core!\n");
-#endif
ctx->d1core =
GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify,
&connect_notify, NULL, NULL, GNUNET_NO, NULL,
@@ -2195,10 +2079,8 @@
if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL)) /* Do not yet
have the second peer's hello, set up a task to get it */
{
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Don't have d2's HELLO, trying to get it!\n");
-#endif
ctx->d2->th =
GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL,
NULL);
@@ -2288,11 +2170,8 @@
ctx->connect_attempts = max_connect_attempts;
ctx->connected = GNUNET_NO;
ctx->send_hello = send_hello;
-#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to connect peer %s to peer %s\n",
d1->shortname, d2->shortname);
-#endif
-
/* Core is up! Iterate over all _known_ peers first to check if we are
already connected to the peer! */
GNUNET_assert (GNUNET_OK ==
GNUNET_CORE_is_peer_connected (ctx->d1->cfg, &ctx->d2->id,
Modified: gnunet/src/testing/testing_group.c
===================================================================
--- gnunet/src/testing/testing_group.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/testing/testing_group.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -2928,7 +2928,7 @@
{
GNUNET_asprintf (&arg, "%s/friends", temp_service_path);
procarr[pg_iter] =
- GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL);
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "mv", "mv", mytemp,
arg, NULL);
GNUNET_assert (procarr[pg_iter] != NULL);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2950,7 +2950,7 @@
pg->peers[pg_iter].daemon->hostname,
temp_service_path);
procarr[pg_iter] =
- GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg,
NULL);
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", mytemp,
arg, NULL);
GNUNET_assert (procarr[pg_iter] != NULL);
ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule
this, throttle! */
GNUNET_OS_process_close (procarr[pg_iter]);
@@ -3127,7 +3127,7 @@
{
GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path);
procarr[pg_iter] =
- GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL);
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "mv", "mv", mytemp,
arg, NULL);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Copying file with command cp %s %s\n"), mytemp, arg);
@@ -3147,7 +3147,7 @@
pg->peers[pg_iter].daemon->hostname,
temp_service_path);
procarr[pg_iter] =
- GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg,
NULL);
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", mytemp,
arg, NULL);
GNUNET_assert (procarr[pg_iter] != NULL);
GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: add
scheduled blacklist file copy that parallelizes file copying! */
@@ -5806,7 +5806,7 @@
/* FIXME: Doesn't support ssh_port option! */
helper->proc =
- GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg,
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", arg,
"peerStartHelper.pl", tempdir, NULL);
GNUNET_assert (helper->proc != NULL);
#if DEBUG_TESTING
@@ -6031,7 +6031,7 @@
{
GNUNET_asprintf (&ssh_port_str, "%d", pg->hosts[i].sshport);
proc =
- GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-P",
ssh_port_str,
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-P",
ssh_port_str,
#if !DEBUG_TESTING
"-q",
#endif
@@ -6039,7 +6039,7 @@
}
else
proc =
- GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, "mkdir -p",
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", arg,
"mkdir -p",
tmpdir, NULL);
GNUNET_assert (proc != NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -6262,7 +6262,7 @@
/* FIXME: Doesn't support ssh_port option! */
proc =
- GNUNET_OS_start_process (NULL, NULL, "rsync", "rsync", "-r",
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "rsync", "rsync", "-r",
newservicehome, arg, NULL);
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
Modified: gnunet/src/transport/gnunet-transport-certificate-creation.c
===================================================================
--- gnunet/src/transport/gnunet-transport-certificate-creation.c
2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/transport/gnunet-transport-certificate-creation.c
2012-02-27 11:00:10 UTC (rev 20060)
@@ -57,7 +57,7 @@
/* Create RSA Private Key */
/* openssl genrsa -out $1 1024 2> /dev/null */
openssl =
- GNUNET_OS_start_process (NULL, NULL, "openssl", "openssl", "genrsa",
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "openssl", "openssl",
"genrsa",
"-out", argv[1], "1024", NULL);
if (openssl == NULL)
return 2;
@@ -67,7 +67,7 @@
/* Create a self-signed certificate in batch mode using rsa key */
/* openssl req -batch -days 365 -out $2 -new -x509 -key $1 2> /dev/null */
openssl =
- GNUNET_OS_start_process (NULL, NULL, "openssl", "openssl", "req",
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "openssl", "openssl",
"req",
"-batch", "-days", "365", "-out", argv[2],
"-new", "-x509", "-key", argv[1], NULL);
if (openssl == NULL)
Modified: gnunet/src/transport/gnunet-transport-connect-running-peers.c
===================================================================
--- gnunet/src/transport/gnunet-transport-connect-running-peers.c
2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/transport/gnunet-transport-connect-running-peers.c
2012-02-27 11:00:10 UTC (rev 20060)
@@ -256,7 +256,7 @@
GNUNET_DISK_directory_remove (p->servicehome);
/*
* p->arm_proc =
- * GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ * GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
* "gnunet-service-arm", "-c", cfgname,
* #if VERBOSE_PEERS
* "-L", "DEBUG",
Modified: gnunet/src/transport/gnunet-transport.c
===================================================================
--- gnunet/src/transport/gnunet-transport.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/transport/gnunet-transport.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -275,7 +275,7 @@
adv_port = bnd_port;
if (NULL == resolver)
resolver =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-resolver",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL,
"gnunet-service-resolver",
"gnunet-service-resolver", NULL);
resolver_users++;
GNUNET_RESOLVER_connect (cfg);
Modified: gnunet/src/transport/plugin_transport_http_server.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_server.c 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/transport/plugin_transport_http_server.c 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -178,7 +178,7 @@
#endif
errno = 0;
cert_creation =
- GNUNET_OS_start_process (NULL, NULL,
+ GNUNET_OS_start_process (GNUNET_NO, NULL, NULL,
"gnunet-transport-certificate-creation",
"gnunet-transport-certificate-creation",
key_file, cert_file, NULL);
Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c 2012-02-27 10:54:36 UTC
(rev 20059)
+++ gnunet/src/transport/plugin_transport_wlan.c 2012-02-27 11:00:10 UTC
(rev 20060)
@@ -1487,7 +1487,7 @@
if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_YES)
{
plugin->server_proc =
- GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+ GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin,
plugin->server_stdout,
filenamehw, filenamehw, plugin->interface,
NULL);
}
@@ -1514,7 +1514,7 @@
absolute_filename, plugin->interface, plugin->testmode);
#endif
plugin->server_proc =
- GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+ GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin,
plugin->server_stdout,
absolute_filename, absolute_filename, "1",
NULL);
if (plugin->server_proc == NULL)
@@ -1534,7 +1534,7 @@
#endif
plugin->server_proc =
- GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+ GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin,
plugin->server_stdout,
absolute_filename, absolute_filename, "2",
NULL);
if (plugin->server_proc == NULL)
Modified: gnunet/src/transport/transport-testing.c
===================================================================
--- gnunet/src/transport/transport-testing.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/transport/transport-testing.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -304,7 +304,8 @@
}
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES,
+ NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm", "-c", cfgname,
#if VERBOSE_PEERS
"-L", "DEBUG",
@@ -420,7 +421,8 @@
goto fail;
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES,
+ NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm", "-c", cfgname,
#if VERBOSE_PEERS
"-L", "DEBUG",
Modified: gnunet/src/util/crypto_random.c
===================================================================
--- gnunet/src/util/crypto_random.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/util/crypto_random.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -280,9 +280,10 @@
LOG (GNUNET_ERROR_TYPE_INFO, _("Starting `%s' process to generate
entropy\n"),
"find");
genproc =
- GNUNET_OS_start_process (NULL, NULL, "sh", "sh", "-c",
- "exec find / -mount -type f -exec cp {}
/dev/null \\; 2>/dev/null",
- NULL);
+ GNUNET_OS_start_process (GNUNET_NO,
+ NULL, NULL, "sh", "sh", "-c",
+ "exec find / -mount -type f -exec cp {} /dev/null
\\; 2>/dev/null",
+ NULL);
}
Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/util/disk.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -1610,7 +1610,7 @@
mode = translate_unix_perms (perm);
}
- fd = open (expfn, oflags | O_LARGEFILE, mode);
+ fd = open (expfn, oflags | O_LARGEFILE | O_NONBLOCK, mode);
if (fd == -1)
{
if (0 == (flags & GNUNET_DISK_OPEN_FAILIFEXISTS))
@@ -2455,214 +2455,6 @@
/**
- * Creates a named pipe/FIFO and opens it
- * @param fn pointer to the name of the named pipe or to NULL
- * @param flags open flags
- * @param perm access permissions
- * @return pipe handle on success, NULL on error
- */
-struct GNUNET_DISK_FileHandle *
-GNUNET_DISK_npipe_create (char **fn, enum GNUNET_DISK_OpenFlags flags,
- enum GNUNET_DISK_AccessPermissions perm)
-{
-#ifdef MINGW
- struct GNUNET_DISK_FileHandle *ret;
- HANDLE h = NULL;
- DWORD openMode;
- char *name;
-
- openMode = 0;
- if (flags & GNUNET_DISK_OPEN_READWRITE)
- openMode = PIPE_ACCESS_DUPLEX;
- else if (flags & GNUNET_DISK_OPEN_READ)
- openMode = PIPE_ACCESS_INBOUND;
- else if (flags & GNUNET_DISK_OPEN_WRITE)
- openMode = PIPE_ACCESS_OUTBOUND;
-
- if (flags & GNUNET_DISK_OPEN_FAILIFEXISTS)
- openMode |= FILE_FLAG_FIRST_PIPE_INSTANCE;
-
- while (h == NULL)
- {
- DWORD error_code;
-
- name = NULL;
- if (*fn != NULL)
- {
- GNUNET_asprintf (&name, "\\\\.\\pipe\\%.246s", fn);
-#if DEBUG_NPIPE
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Trying to create an instance of named pipe `%s'\n", name);
-#endif
- /* 1) This might work just fine with UTF-8 strings as it is.
- * 2) This is only used by GNUnet itself, and only with latin names.
- */
- h = CreateNamedPipe (name, openMode | FILE_FLAG_OVERLAPPED,
- PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 2, 1, 1, 0,
- NULL);
- }
- else
- {
- GNUNET_asprintf (fn, "\\\\.\\pipe\\gnunet-%llu",
- GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT64_MAX));
-#if DEBUG_NPIPE
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to create unique named pipe
`%s'\n",
- *fn);
-#endif
- h = CreateNamedPipe (*fn,
- openMode | FILE_FLAG_OVERLAPPED |
- FILE_FLAG_FIRST_PIPE_INSTANCE,
- PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 2, 1, 1, 0,
- NULL);
- }
- error_code = GetLastError ();
- if (name)
- GNUNET_free (name);
- /* don't re-set name to NULL yet */
- if (h == INVALID_HANDLE_VALUE)
- {
- SetErrnoFromWinError (error_code);
-#if DEBUG_NPIPE
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Pipe creation have failed because of %d, errno is %d\n",
error_code,
- errno);
-#endif
- if (name == NULL)
- {
-#if DEBUG_NPIPE
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Pipe was to be unique, considering re-creation\n");
-#endif
- GNUNET_free (*fn);
- *fn = NULL;
- if (error_code != ERROR_ACCESS_DENIED && error_code != ERROR_PIPE_BUSY)
- {
- return NULL;
- }
-#if DEBUG_NPIPE
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Pipe name was not unique, trying again\n");
-#endif
- h = NULL;
- }
- else
- return NULL;
- }
- }
- errno = 0;
-
- ret = GNUNET_malloc (sizeof (*ret));
- ret->h = h;
- ret->type = GNUNET_PIPE;
-
- ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
- ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
-
- ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
- ret->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
-
- return ret;
-#else
- if (*fn == NULL)
- {
- char dir[] = "/tmp/gnunet-pipe-XXXXXX";
-
- if (mkdtemp (dir) == NULL)
- {
- LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "mkdtemp");
- return NULL;
- }
- GNUNET_asprintf (fn, "%s/child-control", dir);
- }
-
- if (mkfifo (*fn, translate_unix_perms (perm)) == -1)
- {
- if ((errno != EEXIST) || (0 != (flags & GNUNET_DISK_OPEN_FAILIFEXISTS)))
- return NULL;
- }
-
- flags = flags & (~GNUNET_DISK_OPEN_FAILIFEXISTS);
- return GNUNET_DISK_file_open (*fn, flags, perm);
-#endif
-}
-
-
-/**
- * Opens already existing named pipe/FIFO
- *
- * @param fn name of an existing named pipe
- * @param flags open flags
- * @param perm access permissions
- * @return pipe handle on success, NULL on error
- */
-struct GNUNET_DISK_FileHandle *
-GNUNET_DISK_npipe_open (const char *fn, enum GNUNET_DISK_OpenFlags flags,
- enum GNUNET_DISK_AccessPermissions perm)
-{
-#ifdef MINGW
- struct GNUNET_DISK_FileHandle *ret;
- HANDLE h;
- DWORD openMode;
-
- openMode = 0;
- if (flags & GNUNET_DISK_OPEN_READWRITE)
- openMode = GENERIC_WRITE | GENERIC_READ;
- else if (flags & GNUNET_DISK_OPEN_READ)
- openMode = GENERIC_READ;
- else if (flags & GNUNET_DISK_OPEN_WRITE)
- openMode = GENERIC_WRITE;
-
- h = CreateFile (fn, openMode, 0, NULL, OPEN_EXISTING,
- FILE_FLAG_OVERLAPPED | FILE_READ_ATTRIBUTES, NULL);
- if (h == INVALID_HANDLE_VALUE)
- {
- SetErrnoFromWinError (GetLastError ());
- return NULL;
- }
-
- ret = GNUNET_malloc (sizeof (*ret));
- ret->h = h;
- ret->type = GNUNET_PIPE;
- ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
- ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
- ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
- ret->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
-
- return ret;
-#else
- flags = flags & (~GNUNET_DISK_OPEN_FAILIFEXISTS);
- return GNUNET_DISK_file_open (fn, flags, perm);
-#endif
-}
-
-
-/**
- * Closes a named pipe/FIFO
- * @param pipe named pipe
- * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
- */
-int
-GNUNET_DISK_npipe_close (struct GNUNET_DISK_FileHandle *pipe)
-{
-#ifndef MINGW
- return close (pipe->fd) == 0 ? GNUNET_OK : GNUNET_SYSERR;
-#else
- BOOL ret;
-
- ret = CloseHandle (pipe->h);
- if (!ret)
- {
- SetErrnoFromWinError (GetLastError ());
- return GNUNET_SYSERR;
- }
- else
- return GNUNET_OK;
-#endif
-}
-
-
-/**
* Get the handle to a particular pipe end
*
* @param p pipe
Modified: gnunet/src/util/helper.c
===================================================================
--- gnunet/src/util/helper.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/util/helper.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -306,7 +306,8 @@
h->fh_to_helper =
GNUNET_DISK_pipe_handle (h->helper_in, GNUNET_DISK_PIPE_END_WRITE);
h->helper_proc =
- GNUNET_OS_start_process_vap (h->helper_in, h->helper_out,
+ GNUNET_OS_start_process_vap (GNUNET_NO,
+ h->helper_in, h->helper_out,
h->binary_name,
h->binary_argv);
if (NULL == h->helper_proc)
Modified: gnunet/src/util/os_priority.c
===================================================================
--- gnunet/src/util/os_priority.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/util/os_priority.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -39,22 +39,253 @@
#define GNUNET_OS_CONTROL_PIPE "GNUNET_OS_CONTROL_PIPE"
-#define DEBUG_OS GNUNET_EXTRA_LOGGING
-
struct GNUNET_OS_Process
{
+ /**
+ * PID of the process.
+ */
pid_t pid;
+
#if WINDOWS
+ /**
+ * Process handle.
+ */
HANDLE handle;
#endif
- int sig;
+
+ /**
+ * Pipe we use to signal the process (if used).
+ */
struct GNUNET_DISK_FileHandle *control_pipe;
+
+ /**
+ * Name of the pipe, NULL for none.
+ */
+ char *childpipename;
};
+
+/**
+ * Handle for 'this' process.
+ */
static struct GNUNET_OS_Process current_process;
+/* MinGW version of named pipe API */
+#ifdef MINGW
/**
+ * Creates a named pipe/FIFO and opens it
+ *
+ * @param fn pointer to the name of the named pipe or to NULL
+ * @param flags open flags
+ * @param perm access permissions
+ * @return pipe handle on success, NULL on error
+ */
+static struct GNUNET_DISK_FileHandle *
+npipe_create (char **fn, enum GNUNET_DISK_OpenFlags flags,
+ enum GNUNET_DISK_AccessPermissions perm)
+{
+ struct GNUNET_DISK_FileHandle *ret;
+ HANDLE h = NULL;
+ DWORD openMode;
+ char *name;
+
+ openMode = 0;
+ if (flags & GNUNET_DISK_OPEN_READWRITE)
+ openMode = PIPE_ACCESS_DUPLEX;
+ else if (flags & GNUNET_DISK_OPEN_READ)
+ openMode = PIPE_ACCESS_INBOUND;
+ else if (flags & GNUNET_DISK_OPEN_WRITE)
+ openMode = PIPE_ACCESS_OUTBOUND;
+ if (flags & GNUNET_DISK_OPEN_FAILIFEXISTS)
+ openMode |= FILE_FLAG_FIRST_PIPE_INSTANCE;
+
+ while (h == NULL)
+ {
+ DWORD error_code;
+
+ name = NULL;
+ if (*fn != NULL)
+ {
+ GNUNET_asprintf (&name, "\\\\.\\pipe\\%.246s", fn);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Trying to create an instance of named pipe `%s'\n", name);
+ /* 1) This might work just fine with UTF-8 strings as it is.
+ * 2) This is only used by GNUnet itself, and only with latin names.
+ */
+ h = CreateNamedPipe (name, openMode | FILE_FLAG_OVERLAPPED,
+ PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 2, 1, 1, 0,
+ NULL);
+ }
+ else
+ {
+ GNUNET_asprintf (fn, "\\\\.\\pipe\\gnunet-%llu",
+ GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ UINT64_MAX));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to create unique named pipe
`%s'\n",
+ *fn);
+ h = CreateNamedPipe (*fn,
+ openMode | FILE_FLAG_OVERLAPPED |
+ FILE_FLAG_FIRST_PIPE_INSTANCE,
+ PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 2, 1, 1, 0,
+ NULL);
+ }
+ error_code = GetLastError ();
+ if (name)
+ GNUNET_free (name);
+ /* don't re-set name to NULL yet */
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ SetErrnoFromWinError (error_code);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Pipe creation have failed because of %d, errno is %d\n",
error_code,
+ errno);
+ if (name == NULL)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Pipe was to be unique, considering re-creation\n");
+ GNUNET_free (*fn);
+ *fn = NULL;
+ if (error_code != ERROR_ACCESS_DENIED && error_code != ERROR_PIPE_BUSY)
+ {
+ return NULL;
+ }
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Pipe name was not unique, trying again\n");
+ h = NULL;
+ }
+ else
+ return NULL;
+ }
+ }
+ errno = 0;
+
+ ret = GNUNET_malloc (sizeof (*ret));
+ ret->h = h;
+ ret->type = GNUNET_PIPE;
+ ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
+ ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
+ ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+ ret->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+ return ret;
+}
+
+
+/**
+ * Opens already existing named pipe/FIFO
+ *
+ * @param fn name of an existing named pipe
+ * @param flags open flags
+ * @param perm access permissions
+ * @return pipe handle on success, NULL on error
+ */
+static struct GNUNET_DISK_FileHandle *
+npipe_open (const char *fn, enum GNUNET_DISK_OpenFlags flags,
+ enum GNUNET_DISK_AccessPermissions perm)
+{
+ struct GNUNET_DISK_FileHandle *ret;
+ HANDLE h;
+ DWORD openMode;
+
+ openMode = 0;
+ if (flags & GNUNET_DISK_OPEN_READWRITE)
+ openMode = GENERIC_WRITE | GENERIC_READ;
+ else if (flags & GNUNET_DISK_OPEN_READ)
+ openMode = GENERIC_READ;
+ else if (flags & GNUNET_DISK_OPEN_WRITE)
+ openMode = GENERIC_WRITE;
+
+ h = CreateFile (fn, openMode, 0, NULL, OPEN_EXISTING,
+ FILE_FLAG_OVERLAPPED | FILE_READ_ATTRIBUTES, NULL);
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ SetErrnoFromWinError (GetLastError ());
+ return NULL;
+ }
+
+ ret = GNUNET_malloc (sizeof (*ret));
+ ret->h = h;
+ ret->type = GNUNET_PIPE;
+ ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
+ ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
+ ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+ ret->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+
+ return ret;
+}
+
+#else
+/* UNIX version of named-pipe API */
+
+/**
+ * Clean up a named pipe and the directory it was placed in.
+ *
+ * @param fn name of the pipe
+ */
+static void
+cleanup_npipe (const char *fn)
+{
+ char *dn;
+ char *dp;
+
+ if (0 != unlink (fn))
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
+ dn = GNUNET_strdup (fn);
+ dp = dirname (dn);
+ if (0 != rmdir (dp))
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rmdir", dp);
+ GNUNET_free (dn);
+}
+
+
+/**
+ * Setup a named pipe.
+ *
+ * @param fn where to store the name of the new pipe,
+ * if *fn is non-null, the name of the pipe to setup
+ * @return GNUNET_OK on success
+ */
+static int
+npipe_setup (char **fn)
+{
+ if (NULL == *fn)
+ {
+ /* FIXME: hardwired '/tmp' path... is bad */
+ char dir[] = "/tmp/gnunet-pipe-XXXXXX";
+
+ if (NULL == mkdtemp (dir))
+ {
+ LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "mkdtemp");
+ return GNUNET_SYSERR;
+ }
+ GNUNET_asprintf (fn, "%s/child-control", dir);
+ }
+ if (-1 == mkfifo (*fn, S_IRUSR | S_IWUSR))
+ return GNUNET_SYSERR;
+ return GNUNET_OK;
+}
+
+
+/**
+ * Open an existing named pipe.
+ *
+ * @param fn name of the file
+ * @param flags flags to use
+ * @param perm permissions to use
+ * @return NULL on error
+ */
+static struct GNUNET_DISK_FileHandle *
+npipe_open (const char *fn,
+ enum GNUNET_DISK_OpenFlags flags,
+ enum GNUNET_DISK_AccessPermissions perm)
+{
+ flags = flags & (~GNUNET_DISK_OPEN_FAILIFEXISTS);
+ return GNUNET_DISK_file_open (fn, flags, perm);
+}
+#endif
+
+
+/**
* This handler is called when there are control data to be read on the pipe
*
* @param cls the 'struct GNUNET_DISK_FileHandle' of the control pipe
@@ -64,44 +295,41 @@
parent_control_handler (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct GNUNET_DISK_FileHandle *control_pipe =
- (struct GNUNET_DISK_FileHandle *) cls;
+ struct GNUNET_DISK_FileHandle *control_pipe = cls;
int sig;
-#if DEBUG_OS
LOG (GNUNET_ERROR_TYPE_DEBUG, "`%s' invoked because of %d\n", __FUNCTION__,
tc->reason);
-#endif
if (tc->reason &
(GNUNET_SCHEDULER_REASON_SHUTDOWN | GNUNET_SCHEDULER_REASON_TIMEOUT |
GNUNET_SCHEDULER_REASON_PREREQ_DONE))
{
- GNUNET_DISK_npipe_close (control_pipe);
+ GNUNET_DISK_file_close (control_pipe);
+ return;
}
- else
+ if (GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig)) !=
+ sizeof (sig))
{
- if (GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig)) !=
- sizeof (sig))
- {
- LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
- GNUNET_DISK_npipe_close (control_pipe);
- }
- else
- {
-#if DEBUG_OS
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Got control code %d from parent\n", sig);
-#endif
- GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
- control_pipe, &parent_control_handler,
- control_pipe);
- raise (sig);
- }
+ LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
+ GNUNET_DISK_file_close (control_pipe);
+ return;
}
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Got control code %d from parent\n", sig);
+ GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
+ control_pipe, &parent_control_handler,
+ control_pipe);
+ raise (sig);
}
/**
- * Task that connects this process to its parent via pipe
+ * Task that connects this process to its parent via pipe;
+ * essentially, the parent control handler will read signal numbers
+ * from the 'GNUNET_OS_CONTROL_PIPE' (as given in an environment
+ * variable) and raise those signals.
+ *
+ * @param cls closure (unused)
+ * @param tc scheduler context (unused)
*/
void
GNUNET_OS_install_parent_control_handler (void *cls,
@@ -112,27 +340,26 @@
struct GNUNET_DISK_FileHandle *control_pipe;
env_buf = getenv (GNUNET_OS_CONTROL_PIPE);
- if ((env_buf == NULL) || (strlen (env_buf) <= 0))
+ if ( (env_buf == NULL) || (strlen (env_buf) <= 0) )
{
- LOG (GNUNET_ERROR_TYPE_INFO, _("Not installing a handler because
$%s=%s\n"),
- GNUNET_OS_CONTROL_PIPE, env_buf);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Not installing a handler because $%s is empty\n",
+ GNUNET_OS_CONTROL_PIPE);
putenv ("GNUNET_OS_CONTROL_PIPE=");
return;
}
control_pipe =
- GNUNET_DISK_npipe_open (env_buf, GNUNET_DISK_OPEN_READ,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
- if (control_pipe == NULL)
+ npipe_open (env_buf, GNUNET_DISK_OPEN_READ,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
+ if (NULL == control_pipe)
{
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "open", env_buf);
putenv ("GNUNET_OS_CONTROL_PIPE=");
return;
}
-#if DEBUG_OS
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Adding parent control handler pipe `%s' to the scheduler\n", env_buf);
-#endif
GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, control_pipe,
&parent_control_handler, control_pipe);
putenv ("GNUNET_OS_CONTROL_PIPE=");
@@ -160,104 +387,64 @@
}
+/**
+ * Sends a signal to the process
+ *
+ * @param proc pointer to process structure
+ * @param sig signal
+ * @return 0 on success, -1 on error
+ */
int
GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig)
{
-#if ENABLE_WINDOWS_WORKAROUNDS
- int res = 0;
- int ret = 0;
+ int ret;
+#if !WINDOWS
+ if ( (NULL == proc->control_pipe) &&
+ (NULL != proc->childpipename) )
+ proc->control_pipe = npipe_open (proc->childpipename,
+ GNUNET_DISK_OPEN_WRITE,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
+#endif
+ if (NULL == proc->control_pipe)
+ {
+#if WINDOWS
+ /* no pipe and windows? can't do this */
+ errno = EINVAL;
+ return -1;
+#else
+ return kill (proc->pid, sig);
+#endif
+ }
ret = GNUNET_DISK_file_write (proc->control_pipe, &sig, sizeof (sig));
- if (ret != sizeof (sig))
+ if (ret == sizeof (sig))
+ return 0;
+ /* pipe failed, try other methods */
+ switch (sig)
{
- if (errno == ECOMM)
+ case SIGHUP:
+ case SIGINT:
+ case SIGKILL:
+ case SIGTERM:
+#if WINDOWS && !defined(__CYGWIN__)
+ if (0 == TerminateProcess (proc->handle, 0))
{
- /* Child process is not controllable via pipe */
-#if DEBUG_OS
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Child process is not controllable, will kill it directly\n");
-#endif
+ /* FIXME: set 'errno' */
+ return -1;
}
- else if (errno == EPIPE)
- {
-#if DEBUG_OS
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to write into control pipe, because pipe is invalid (the
child is most likely dead)\n");
-#endif
- }
- else
- LOG (GNUNET_ERROR_TYPE_WARNING,
- "Failed to write into control pipe , errno is %d\n", errno);
-#if WINDOWS && !defined(__CYGWIN__)
- TerminateProcess (proc->handle, 0);
+ return 0;
#else
- PLIBC_KILL (proc->pid, sig);
+ return PLIBC_KILL (proc->pid, sig);
#endif
- }
- else
- {
-#if DEBUG_OS
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Wrote control code into control pipe, now waiting\n");
-#endif
-
+ default:
#if WINDOWS
- /* Give it 3 seconds to die, then kill it in a nice Windows-specific way */
- if (WaitForSingleObject (proc->handle, 3000) != WAIT_OBJECT_0)
- TerminateProcess (proc->handle, 0);
- res = 0;
+ errno = EINVAL;
+ return -1;
#else
- struct GNUNET_NETWORK_FDSet *rfds;
- struct GNUNET_NETWORK_FDSet *efds;
-
- rfds = GNUNET_NETWORK_fdset_create ();
- efds = GNUNET_NETWORK_fdset_create ();
-
- GNUNET_NETWORK_fdset_handle_set (rfds, proc->control_pipe);
- GNUNET_NETWORK_fdset_handle_set (efds, proc->control_pipe);
-
- /* Ndurner thought this up, and i have no idea what it does.
- * There's have never been any code to answer the shutdown call
- * (write a single int into the pipe, so that this function can read it).
- * On *nix select() will probably tell that pipe is ready
- * for reading, once the other process shuts down,
- * but the read () call will fail, triggering a kill ()
- * on the pid that is already dead. This will probably result in non-0
- * return from kill(), and therefore from this function.
- */
- while (1)
- {
- ret =
- GNUNET_NETWORK_socket_select (rfds, NULL, efds,
- GNUNET_TIME_relative_multiply
- (GNUNET_TIME_relative_get_unit (),
- 5000));
-
- if (ret < 1 ||
- GNUNET_NETWORK_fdset_handle_isset (efds, proc->control_pipe))
- {
- /* Just to be sure */
- PLIBC_KILL (proc->pid, sig);
- res = 0;
- break;
- }
- else
- {
- if (GNUNET_DISK_file_read (proc->control_pipe, &ret, sizeof (ret)) !=
- GNUNET_OK)
- res = PLIBC_KILL (proc->pid, sig);
-
- /* Child signaled shutdown is in progress */
- continue;
- }
- }
-#endif
+ return kill (proc->pid, sig);
+#endif
}
-
- return res;
-#else
- return kill (proc->pid, sig);
-#endif
}
/**
@@ -279,13 +466,18 @@
{
#if ENABLE_WINDOWS_WORKAROUNDS
if (proc->control_pipe)
- GNUNET_DISK_npipe_close (proc->control_pipe);
+ GNUNET_DISK_file_close (proc->control_pipe);
#endif
// FIXME NILS
#ifdef WINDOWS
if (proc->handle != NULL)
CloseHandle (proc->handle);
#endif
+ if (NULL != proc->childpipename)
+ {
+ cleanup_npipe (proc->childpipename);
+ GNUNET_free (proc->childpipename);
+ }
GNUNET_free (proc);
}
@@ -417,11 +609,9 @@
}
}
#else
-#if DEBUG_OS
LOG (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"Priority management not availabe for this platform\n");
#endif
-#endif
return GNUNET_OK;
}
@@ -531,6 +721,7 @@
/**
* Start a process.
*
+ * @param pipe_control should a pipe be used to send signals to the child?
* @param pipe_stdin pipe to use to send input to child process (or NULL)
* @param pipe_stdout pipe to use to get output from child process (or NULL)
* @param filename name of the binary
@@ -538,32 +729,25 @@
* @return pointer to process structure of the new process, NULL on error
*/
struct GNUNET_OS_Process *
-GNUNET_OS_start_process_vap (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process_vap (int pipe_control,
+ struct GNUNET_DISK_PipeHandle *pipe_stdin,
struct GNUNET_DISK_PipeHandle *pipe_stdout,
const char *filename,
char *const argv[])
{
-#if ENABLE_WINDOWS_WORKAROUNDS
+#ifndef MINGW
char *childpipename = NULL;
- struct GNUNET_DISK_FileHandle *control_pipe = NULL;
-#endif
struct GNUNET_OS_Process *gnunet_proc = NULL;
-
-#ifndef MINGW
pid_t ret;
int fd_stdout_write;
int fd_stdout_read;
int fd_stdin_read;
int fd_stdin_write;
-#if ENABLE_WINDOWS_WORKAROUNDS
- control_pipe =
- GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
- if (control_pipe == NULL)
- return NULL;
-#endif
+ if ( (GNUNET_YES == pipe_control) &&
+ (GNUNET_OK !=
+ npipe_setup (&childpipename)) )
+ return NULL;
if (pipe_stdout != NULL)
{
GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle
@@ -585,34 +769,24 @@
}
ret = fork ();
- if (ret != 0)
+ if (-1 == ret)
{
- if (ret == -1)
- {
- LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "fork");
-#if ENABLE_WINDOWS_WORKAROUNDS
- GNUNET_DISK_npipe_close (control_pipe);
-#endif
- }
- else
- {
- gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
- gnunet_proc->pid = ret;
-#if ENABLE_WINDOWS_WORKAROUNDS
- gnunet_proc->control_pipe = control_pipe;
-#endif
- }
-#if ENABLE_WINDOWS_WORKAROUNDS
- GNUNET_free (childpipename);
-#endif
+ LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "fork");
+ GNUNET_free_non_null (childpipename);
+ return NULL;
+ }
+ if (0 != ret)
+ {
+ gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
+ gnunet_proc->pid = ret;
+ gnunet_proc->childpipename = childpipename;
return gnunet_proc;
}
-
-#if ENABLE_WINDOWS_WORKAROUNDS
- setenv (GNUNET_OS_CONTROL_PIPE, childpipename, 1);
- GNUNET_free (childpipename);
-#endif
-
+ if (NULL != childpipename)
+ {
+ setenv (GNUNET_OS_CONTROL_PIPE, childpipename, 1);
+ GNUNET_free (childpipename);
+ }
if (pipe_stdout != NULL)
{
GNUNET_break (0 == close (fd_stdout_read));
@@ -633,6 +807,8 @@
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "execvp", filename);
_exit (1);
#else
+ char *childpipename = NULL;
+ struct GNUNET_OS_Process *gnunet_proc = NULL;
char *arg;
unsigned int cmdlen;
char *cmd, *idx;
@@ -749,26 +925,31 @@
&stdout_handle, sizeof (HANDLE));
start.hStdOutput = stdout_handle;
}
-
- control_pipe =
- GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
- if (control_pipe == NULL)
+ if (GNUNET_YES == pipe_control)
{
- GNUNET_free (cmd);
- GNUNET_free (path);
- return NULL;
+ control_pipe =
+ npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
+ if (control_pipe == NULL)
+ {
+ GNUNET_free (cmd);
+ GNUNET_free (path);
+ return NULL;
+ }
}
-
-#if DEBUG_OS
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n",
- childpipename);
-#endif
-
- GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE);
- GNUNET_asprintf (&our_env[1], "%s", childpipename);
- our_env[2] = NULL;
+ if (NULL != childpipename)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n",
+ childpipename);
+ GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE);
+ GNUNET_asprintf (&our_env[1], "%s", childpipename);
+ our_env[2] = NULL;
+ }
+ else
+ {
+ our_env[0] = NULL;
+ }
env_block = CreateCustomEnvTable (our_env);
GNUNET_free (our_env[0]);
GNUNET_free (our_env[1]);
@@ -808,6 +989,7 @@
/**
* Start a process.
*
+ * @param pipe_control should a pipe be used to send signals to the child?
* @param pipe_stdin pipe to use to send input to child process (or NULL)
* @param pipe_stdout pipe to use to get output from child process (or NULL)
* @param filename name of the binary
@@ -815,7 +997,8 @@
* @return pointer to process structure of the new process, NULL on error
*/
struct GNUNET_OS_Process *
-GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process_va (int pipe_control,
+ struct GNUNET_DISK_PipeHandle *pipe_stdin,
struct GNUNET_DISK_PipeHandle *pipe_stdout,
const char *filename, va_list va)
{
@@ -835,7 +1018,8 @@
while (NULL != (argv[argc] = va_arg (ap, char *)))
argc++;
va_end (ap);
- ret = GNUNET_OS_start_process_vap (pipe_stdin,
+ ret = GNUNET_OS_start_process_vap (pipe_control,
+ pipe_stdin,
pipe_stdout,
filename,
argv);
@@ -848,6 +1032,7 @@
/**
* Start a process.
*
+ * @param pipe_control should a pipe be used to send signals to the child?
* @param pipe_stdin pipe to use to send input to child process (or NULL)
* @param pipe_stdout pipe to use to get output from child process (or NULL)
* @param filename name of the binary
@@ -857,7 +1042,8 @@
*
*/
struct GNUNET_OS_Process *
-GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process (int pipe_control,
+ struct GNUNET_DISK_PipeHandle *pipe_stdin,
struct GNUNET_DISK_PipeHandle *pipe_stdout,
const char *filename, ...)
{
@@ -865,7 +1051,7 @@
va_list ap;
va_start (ap, filename);
- ret = GNUNET_OS_start_process_va (pipe_stdin, pipe_stdout, filename, ap);
+ ret = GNUNET_OS_start_process_va (pipe_control, pipe_stdin, pipe_stdout,
filename, ap);
va_end (ap);
return ret;
}
@@ -874,6 +1060,7 @@
/**
* Start a process.
*
+ * @param pipe_control should a pipe be used to send signals to the child?
* @param lsocks array of listen sockets to dup systemd-style (or NULL);
* must be NULL on platforms where dup is not supported
* @param filename name of the binary
@@ -881,20 +1068,17 @@
* @return process ID of the new process, -1 on error
*/
struct GNUNET_OS_Process *
-GNUNET_OS_start_process_v (const SOCKTYPE *lsocks,
+GNUNET_OS_start_process_v (int pipe_control,
+ const SOCKTYPE *lsocks,
const char *filename,
char *const argv[])
{
-#if ENABLE_WINDOWS_WORKAROUNDS
- struct GNUNET_DISK_FileHandle *control_pipe = NULL;
- char *childpipename = NULL;
-#endif
-
#ifndef MINGW
pid_t ret;
char lpid[16];
char fds[16];
struct GNUNET_OS_Process *gnunet_proc = NULL;
+ char *childpipename = NULL;
int i;
int j;
int k;
@@ -903,15 +1087,9 @@
int *lscp;
unsigned int ls;
-#if ENABLE_WINDOWS_WORKAROUNDS
- control_pipe =
- GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
- if (control_pipe == NULL)
- return NULL;
-#endif
-
+ if ( (GNUNET_YES == pipe_control) &&
+ (GNUNET_OK != npipe_setup (&childpipename)) )
+ return NULL;
lscp = NULL;
ls = 0;
if (lsocks != NULL)
@@ -922,36 +1100,26 @@
GNUNET_array_append (lscp, ls, -1);
}
ret = fork ();
- if (ret != 0)
+ if (-1 == ret)
{
- if (ret == -1)
- {
- LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "fork");
-#if ENABLE_WINDOWS_WORKAROUNDS
- GNUNET_DISK_npipe_close (control_pipe);
-#endif
- }
- else
- {
- gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
- gnunet_proc->pid = ret;
-#if ENABLE_WINDOWS_WORKAROUNDS
- gnunet_proc->control_pipe = control_pipe;
-
-#endif
- }
+ LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "fork");
+ GNUNET_free_non_null (childpipename);
GNUNET_array_grow (lscp, ls, 0);
-#if ENABLE_WINDOWS_WORKAROUNDS
- GNUNET_free (childpipename);
-#endif
+ return NULL;
+ }
+ if (0 != ret)
+ {
+ gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
+ gnunet_proc->pid = ret;
+ gnunet_proc->childpipename = childpipename;
+ GNUNET_array_grow (lscp, ls, 0);
return gnunet_proc;
}
-
-#if ENABLE_WINDOWS_WORKAROUNDS
- setenv (GNUNET_OS_CONTROL_PIPE, childpipename, 1);
- GNUNET_free (childpipename);
-#endif
-
+ if (NULL != childpipename)
+ {
+ setenv (GNUNET_OS_CONTROL_PIPE, childpipename, 1);
+ GNUNET_free (childpipename);
+ }
if (lscp != NULL)
{
/* read systemd documentation... */
@@ -999,6 +1167,8 @@
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "execvp", filename);
_exit (1);
#else
+ struct GNUNET_DISK_FileHandle *control_pipe = NULL;
+ char *childpipename = NULL;
char **arg, **non_const_argv;
unsigned int cmdlen;
char *cmd, *idx;
@@ -1006,9 +1176,7 @@
PROCESS_INFORMATION proc;
int argcount = 0;
struct GNUNET_OS_Process *gnunet_proc = NULL;
-
char path[MAX_PATH + 1];
-
char *our_env[5] = { NULL, NULL, NULL, NULL, NULL };
char *env_block = NULL;
char *pathbuf;
@@ -1023,7 +1191,7 @@
HANDLE lsocks_read;
HANDLE lsocks_write;
wchar_t wpath[MAX_PATH + 1], wcmd[32768];
-
+ int env_off;
int fail;
/* Search in prefix dir (hopefully - the directory from which
@@ -1130,15 +1298,18 @@
memset (&start, 0, sizeof (start));
start.cb = sizeof (start);
- control_pipe =
- GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE);
- if (control_pipe == NULL)
+ if (GNUNET_YES == pipe_control)
{
- GNUNET_free (cmd);
- GNUNET_free (path);
- return NULL;
+ control_pipe =
+ npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
+ if (control_pipe == NULL)
+ {
+ GNUNET_free (cmd);
+ GNUNET_free (path);
+ return NULL;
+ }
}
if (lsocks != NULL && lsocks[0] != INVALID_SOCKET)
{
@@ -1160,29 +1331,25 @@
&lsocks_read, sizeof (HANDLE));
}
-#if DEBUG_OS
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n",
- childpipename);
-#endif
-
- GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE);
- GNUNET_asprintf (&our_env[1], "%s", childpipename);
- GNUNET_free (childpipename);
- if (lsocks == NULL || lsocks[0] == INVALID_SOCKET)
- our_env[2] = NULL;
- else
+ env_off = 0;
+ if (NULL != childpipename)
{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n",
+ childpipename);
+ GNUNET_asprintf (&our_env[env_off++], "%s=", GNUNET_OS_CONTROL_PIPE);
+ GNUNET_asprintf (&our_env[env_off++], "%s", childpipename);
+ GNUNET_free (childpipename);
+ }
+ if ( (lsocks != NULL) && (lsocks[0] != INVALID_SOCKET))
+ {
/*This will tell the child that we're going to send lsocks over the pipe*/
- GNUNET_asprintf (&our_env[2], "%s=", "GNUNET_OS_READ_LSOCKS");
- GNUNET_asprintf (&our_env[3], "%lu", lsocks_read);
- our_env[4] = NULL;
+ GNUNET_asprintf (&our_env[env_off++], "%s=", "GNUNET_OS_READ_LSOCKS");
+ GNUNET_asprintf (&our_env[env_off++], "%lu", lsocks_read);
}
+ our_env[env_off++] = NULL;
env_block = CreateCustomEnvTable (our_env);
- GNUNET_free_non_null (our_env[0]);
- GNUNET_free_non_null (our_env[1]);
- GNUNET_free_non_null (our_env[2]);
- GNUNET_free_non_null (our_env[3]);
-
+ while (0 > env_off)
+ GNUNET_free_non_null (our_env[--env_off]);
if (ERROR_SUCCESS != plibc_conv_to_win_pathwconv(path, wpath)
|| ERROR_SUCCESS != plibc_conv_to_win_pathwconv(cmd, wcmd)
|| !CreateProcessW
@@ -1191,8 +1358,9 @@
{
SetErrnoFromWinError (GetLastError ());
LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "CreateProcess");
- GNUNET_DISK_npipe_close (control_pipe);
- if (lsocks != NULL)
+ if (NULL != control_pipe)
+ GNUNET_DISK_file_close (control_pipe);
+ if (NULL != lsocks)
GNUNET_DISK_pipe_close (lsocks_pipe);
GNUNET_free (env_block);
GNUNET_free (cmd);
@@ -1286,11 +1454,11 @@
*/
TerminateProcess (gnunet_proc->handle, 0);
CloseHandle (gnunet_proc->handle);
- GNUNET_DISK_npipe_close (gnunet_proc->control_pipe);
+ if (NULL != gnunet_proc->control_pipe)
+ GNUNET_DISK_file_close (gnunet_proc->control_pipe);
GNUNET_free (gnunet_proc);
return NULL;
}
-
return gnunet_proc;
#endif
}
@@ -1599,7 +1767,7 @@
if (NULL == opipe)
return NULL;
va_start (ap, binary);
- eip = GNUNET_OS_start_process_va (NULL, opipe, binary, ap);
+ eip = GNUNET_OS_start_process_va (GNUNET_NO, NULL, opipe, binary, ap);
va_end (ap);
if (NULL == eip)
{
Modified: gnunet/src/util/scheduler.c
===================================================================
--- gnunet/src/util/scheduler.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/util/scheduler.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -818,13 +818,11 @@
current_lifeness = GNUNET_YES;
GNUNET_SCHEDULER_add_continuation (task, task_cls,
GNUNET_SCHEDULER_REASON_STARTUP);
-#if ENABLE_WINDOWS_WORKAROUNDS
active_task = (void *) (long) -1; /* force passing of sanity check */
GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO,
&GNUNET_OS_install_parent_control_handler,
NULL);
active_task = NULL;
-#endif
last_tr = 0;
busy_wait_warning = 0;
while (GNUNET_OK == check_lifeness ())
Modified: gnunet/src/util/test_common_logging_runtime_loglevels.c
===================================================================
--- gnunet/src/util/test_common_logging_runtime_loglevels.c 2012-02-27
10:54:36 UTC (rev 20059)
+++ gnunet/src/util/test_common_logging_runtime_loglevels.c 2012-02-27
11:00:10 UTC (rev 20060)
@@ -314,7 +314,7 @@
break;
}
- proc = GNUNET_OS_start_process (NULL, pipe_stdout,
+ proc = GNUNET_OS_start_process (GNUNET_NO, NULL, pipe_stdout,
#if MINGW
"test_common_logging_dummy",
#else
Modified: gnunet/src/util/test_os_start_process.c
===================================================================
--- gnunet/src/util/test_os_start_process.c 2012-02-27 10:54:36 UTC (rev
20059)
+++ gnunet/src/util/test_os_start_process.c 2012-02-27 11:00:10 UTC (rev
20060)
@@ -126,7 +126,7 @@
}
proc =
- GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn,
+ GNUNET_OS_start_process (GNUNET_NO, hello_pipe_stdin, hello_pipe_stdout,
fn,
"test_gnunet_echo_hello", "-", NULL);
GNUNET_free (fn);
Modified: gnunet/src/util/test_resolver_api.c
===================================================================
--- gnunet/src/util/test_resolver_api.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/util/test_resolver_api.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -393,7 +393,7 @@
pfx = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR);
GNUNET_asprintf (&fn, "%s%cgnunet-service-resolver", pfx, DIR_SEPARATOR);
GNUNET_free (pfx);
- proc = GNUNET_OS_start_process (NULL, NULL, fn, "gnunet-service-resolver",
+ proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, fn,
"gnunet-service-resolver",
#if VERBOSE
"-L", "DEBUG",
#endif
Modified: gnunet/src/util/test_strings.c
===================================================================
--- gnunet/src/util/test_strings.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/util/test_strings.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -97,7 +97,9 @@
GNUNET_free (r);
b = GNUNET_STRINGS_to_utf8 ("TEST", 4, "ASCII");
WANT ("TEST", b);
+ GNUNET_log_skip (2, GNUNET_NO);
b = GNUNET_STRINGS_to_utf8 ("TEST", 4, "unknown");
+ GNUNET_log_skip (0, GNUNET_YES);
WANT ("TEST", b);
return 0;
}
Modified: gnunet/src/vpn/test_gnunet_vpn.c
===================================================================
--- gnunet/src/vpn/test_gnunet_vpn.c 2012-02-27 10:54:36 UTC (rev 20059)
+++ gnunet/src/vpn/test_gnunet_vpn.c 2012-02-27 11:00:10 UTC (rev 20060)
@@ -441,7 +441,7 @@
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_proc =
- GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20060 - in gnunet/src: arm ats chat core datastore dht fs hostlist include mesh namestore nat nse peerinfo statistics stream testing transport util vpn,
gnunet <=