diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-08-29 13:09:25 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-08-29 13:09:25 +0000 |
commit | a4b74ef335873379d374d372bcce7c4228095bd5 (patch) | |
tree | 7948e9ea9d8f3fc9d2d767fd2490c8a1855d1129 /src/util | |
parent | 19a28dc192c59da09b2668c33fbbcce421f5a05d (diff) | |
download | gnunet-a4b74ef335873379d374d372bcce7c4228095bd5.tar.gz gnunet-a4b74ef335873379d374d372bcce7c4228095bd5.zip |
only use control pipe with helpers IF the helper actually supports it
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/common_allocation.c | 10 | ||||
-rw-r--r-- | src/util/helper.c | 19 |
2 files changed, 18 insertions, 11 deletions
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index a385450b9..90af6e091 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c | |||
@@ -23,9 +23,11 @@ | |||
23 | * @brief wrapper around malloc/free | 23 | * @brief wrapper around malloc/free |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | |||
27 | #include "platform.h" | 26 | #include "platform.h" |
28 | #include "gnunet_common.h" | 27 | #include "gnunet_common.h" |
28 | #if HAVE_MALLOC_H | ||
29 | #include <malloc.h> | ||
30 | #endif | ||
29 | 31 | ||
30 | #define LOG(kind,...) GNUNET_log_from (kind, "util",__VA_ARGS__) | 32 | #define LOG(kind,...) GNUNET_log_from (kind, "util",__VA_ARGS__) |
31 | 33 | ||
@@ -192,11 +194,7 @@ GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber) | |||
192 | #if WINDOWS | 194 | #if WINDOWS |
193 | #define MSIZE(p) _msize (p) | 195 | #define MSIZE(p) _msize (p) |
194 | #endif | 196 | #endif |
195 | #if LINUX | 197 | #if HAVE_MALLOC_USABLE_SIZE |
196 | /* FIXME: manpage claims that this function is a GNU extension, | ||
197 | * but googling shows that it is available on many platforms via | ||
198 | * inclusion of various headers. For now let's make it Linux-only. | ||
199 | */ | ||
200 | #define MSIZE(p) malloc_usable_size (p) | 198 | #define MSIZE(p) malloc_usable_size (p) |
201 | #endif | 199 | #endif |
202 | 200 | ||
diff --git a/src/util/helper.c b/src/util/helper.c index 64b014994..9faf2ee50 100644 --- a/src/util/helper.c +++ b/src/util/helper.c | |||
@@ -152,6 +152,12 @@ struct GNUNET_HELPER_Handle | |||
152 | * Restart task. | 152 | * Restart task. |
153 | */ | 153 | */ |
154 | GNUNET_SCHEDULER_TaskIdentifier restart_task; | 154 | GNUNET_SCHEDULER_TaskIdentifier restart_task; |
155 | |||
156 | /** | ||
157 | * Does the helper support the use of a control pipe for signalling? | ||
158 | */ | ||
159 | int with_control_pipe; | ||
160 | |||
155 | }; | 161 | }; |
156 | 162 | ||
157 | 163 | ||
@@ -341,10 +347,10 @@ start_helper (struct GNUNET_HELPER_Handle *h) | |||
341 | h->fh_to_helper = | 347 | h->fh_to_helper = |
342 | GNUNET_DISK_pipe_handle (h->helper_in, GNUNET_DISK_PIPE_END_WRITE); | 348 | GNUNET_DISK_pipe_handle (h->helper_in, GNUNET_DISK_PIPE_END_WRITE); |
343 | h->helper_proc = | 349 | h->helper_proc = |
344 | GNUNET_OS_start_process_vap (GNUNET_YES, GNUNET_OS_INHERIT_STD_ERR, | 350 | GNUNET_OS_start_process_vap (h->with_control_pipe, GNUNET_OS_INHERIT_STD_ERR, |
345 | h->helper_in, h->helper_out, | 351 | h->helper_in, h->helper_out, |
346 | h->binary_name, | 352 | h->binary_name, |
347 | h->binary_argv); | 353 | h->binary_argv); |
348 | if (NULL == h->helper_proc) | 354 | if (NULL == h->helper_proc) |
349 | { | 355 | { |
350 | /* failed to start process? try again later... */ | 356 | /* failed to start process? try again later... */ |
@@ -385,6 +391,7 @@ restart_task (void *cls, | |||
385 | * restarted when it dies except when it is stopped using GNUNET_HELPER_stop() | 391 | * restarted when it dies except when it is stopped using GNUNET_HELPER_stop() |
386 | * or when the exp_cb callback is not NULL. | 392 | * or when the exp_cb callback is not NULL. |
387 | * | 393 | * |
394 | * @param with_control_pipe does the helper support the use of a control pipe for signalling? | ||
388 | * @param binary_name name of the binary to run | 395 | * @param binary_name name of the binary to run |
389 | * @param binary_argv NULL-terminated list of arguments to give when starting the binary (this | 396 | * @param binary_argv NULL-terminated list of arguments to give when starting the binary (this |
390 | * argument must not be modified by the client for | 397 | * argument must not be modified by the client for |
@@ -396,7 +403,8 @@ restart_task (void *cls, | |||
396 | * @return the new Handle, NULL on error | 403 | * @return the new Handle, NULL on error |
397 | */ | 404 | */ |
398 | struct GNUNET_HELPER_Handle * | 405 | struct GNUNET_HELPER_Handle * |
399 | GNUNET_HELPER_start (const char *binary_name, | 406 | GNUNET_HELPER_start (int with_control_pipe, |
407 | const char *binary_name, | ||
400 | char *const binary_argv[], | 408 | char *const binary_argv[], |
401 | GNUNET_SERVER_MessageTokenizerCallback cb, | 409 | GNUNET_SERVER_MessageTokenizerCallback cb, |
402 | GNUNET_HELPER_ExceptionCallback exp_cb, | 410 | GNUNET_HELPER_ExceptionCallback exp_cb, |
@@ -405,6 +413,7 @@ GNUNET_HELPER_start (const char *binary_name, | |||
405 | struct GNUNET_HELPER_Handle*h; | 413 | struct GNUNET_HELPER_Handle*h; |
406 | 414 | ||
407 | h = GNUNET_malloc (sizeof (struct GNUNET_HELPER_Handle)); | 415 | h = GNUNET_malloc (sizeof (struct GNUNET_HELPER_Handle)); |
416 | h->with_control_pipe = with_control_pipe; | ||
408 | h->binary_name = binary_name; | 417 | h->binary_name = binary_name; |
409 | h->binary_argv = binary_argv; | 418 | h->binary_argv = binary_argv; |
410 | h->cb_cls = cb_cls; | 419 | h->cb_cls = cb_cls; |