{
/* 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
}
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
* @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;
/* *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);
*/
int is_default;
+ /**
+ * Should we use pipes to signal this process? (YES for Java binaries and if we
+ * are on Windoze).
+ */
+ int pipe_control;
};
/**
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"),
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"))
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",
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",
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",
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",
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",
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",
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",
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",
AUTOSTART = NO
[dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
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",
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",
"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",
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",
AUTOSTART = NO
[dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
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",
AUTOSTART = NO
[dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
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",
AUTOSTART = NO
[dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
#define OFF_T off_t
#endif
-/**
- * Opaque handle used to access files.
- */
-struct GNUNET_DISK_FileHandle;
-
/**
* Handle used to manage a pipe.
*/
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 */
{
* @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
/**
- * Sends sig to the process
+ * Sends a signal to the process
*
* @param proc pointer to process structure
* @param sig signal
void
GNUNET_OS_process_close (struct GNUNET_OS_Process *proc);
+
/**
* Get the pid of the process in question
*
pid_t
GNUNET_OS_process_get_pid (struct GNUNET_OS_Process *proc);
+
/**
* Set process priority
*
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
* @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[]);
/**
* 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
* @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, ...);
/**
* 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
* @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
* @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[]);
*/
struct GNUNET_OS_CommandHandle;
+
/**
* Type of a function to process a line of output.
*
*/
typedef void (*GNUNET_OS_LineProcessor) (void *cls, const char *line);
+
/**
* Stop/kill a command.
*
/**
- * 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,
#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
#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",
#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",
#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",
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",
#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);
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)
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)
{
}
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",
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",
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",
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",
#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",
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",
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",
#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",
#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",
[dv]
AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
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
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;
}
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);
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)
{
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:
}
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);
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
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",
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
{
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 */
/* 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
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
{
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",
_("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,
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)
_("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);
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;
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;
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);
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;
/* 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, "%s@%s", 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
}
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
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, "%s@%s", 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
}
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
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);
/* 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] == '/')
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",
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,
/* 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, "%s@%s", 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
}
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
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!!");
/* 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, "%s@%s", 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
}
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
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;
}
}
*/
/* 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)
/* 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, "%s@%s", 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
}
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
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, "%s@%s:%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
{
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;
{
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,
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
}
-
}
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;
/* 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)
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);
ctx->d2->ghh =
GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
}
-#if DEBUG_TESTING_RECONNECT
else
{
if (NULL == ctx->d2->hello)
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);
}
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 =
/* 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,
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);
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,
{
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,
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]);
{
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);
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! */
/* 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
{
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
}
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,
/* 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,
/* 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;
/* 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)
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",
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);
#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);
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);
}
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)
#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)
}
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",
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",
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);
}
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))
}
-/**
- * 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
*
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)
#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
*
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,
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=");
}
+/**
+ * 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)
- {
- /* 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
- }
- else if (errno == EPIPE)
+ case SIGHUP:
+ case SIGINT:
+ case SIGKILL:
+ case SIGTERM:
+#if WINDOWS && !defined(__CYGWIN__)
+ if (0 == TerminateProcess (proc->handle, 0))
{
-#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
+ /* FIXME: set 'errno' */
+ return -1;
}
- 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);
-#endif
- }
- else
- {
-#if DEBUG_OS
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Wrote control code into control pipe, now waiting\n");
+ return PLIBC_KILL (proc->pid, sig);
#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
}
/**
{
#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);
}
}
}
#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;
}
/**
* 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
* @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
}
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));
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;
&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 (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;
}
-
-#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;
env_block = CreateCustomEnvTable (our_env);
GNUNET_free (our_env[0]);
GNUNET_free (our_env[1]);
/**
* 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
* @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)
{
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);
/**
* 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
*
*/
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, ...)
{
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;
}
/**
* 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
* @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;
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)
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);
+ 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);
-#if ENABLE_WINDOWS_WORKAROUNDS
- GNUNET_free (childpipename);
-#endif
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... */
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;
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;
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
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)
{
&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
{
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);
*/
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
}
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)
{
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 ())
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
}
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);
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
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;
}
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",