From d8abe51562c11473ebcb823ad67c529be2c9dc92 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 3 Nov 2010 21:38:45 +0000 Subject: [PATCH] style improvments wrt Mantis 1614 patch --- src/arm/arm_api.c | 2 +- src/arm/do_start_process.c | 4 +- src/arm/gnunet-service-arm.c | 13 +- src/core/test_core_api.c | 2 +- src/core/test_core_api_reliability.c | 2 +- src/core/test_core_api_start_only.c | 2 +- src/datastore/perf_datastore_api.c | 2 +- src/datastore/test_datastore_api.c | 2 +- src/datastore/test_datastore_api_management.c | 2 +- src/dht/test_dht_api.c | 2 +- src/fs/test_fs.c | 2 +- src/fs/test_fs_download.c | 2 +- src/fs/test_fs_download_indexed.c | 2 +- src/fs/test_fs_download_persistence.c | 2 +- src/fs/test_fs_download_recursive.c | 2 +- src/fs/test_fs_list_indexed.c | 2 +- src/fs/test_fs_namespace.c | 2 +- src/fs/test_fs_namespace_list_updateable.c | 2 +- src/fs/test_fs_publish.c | 2 +- src/fs/test_fs_publish_persistence.c | 2 +- src/fs/test_fs_search.c | 2 +- src/fs/test_fs_search_persistence.c | 2 +- src/fs/test_fs_search_ranking.c | 2 +- src/fs/test_fs_start_stop.c | 2 +- src/fs/test_fs_unindex.c | 2 +- src/fs/test_fs_unindex_persistence.c | 2 +- src/hostlist/test_gnunet_daemon_hostlist.c | 2 +- .../test_gnunet_daemon_hostlist_learning.c | 2 +- src/include/gnunet_os_lib.h | 71 ++-------- src/include/gnunet_testing_lib.h | 2 +- src/peerinfo/perf_peerinfo_api.c | 2 +- src/peerinfo/test_peerinfo_api.c | 2 +- src/statistics/test_statistics_api.c | 2 +- src/statistics/test_statistics_api_loop.c | 2 +- src/testing/test_testing_topology.c | 2 +- src/testing/testing_group.c | 8 +- src/transport/plugin_transport_tcp.c | 4 +- src/transport/plugin_transport_udp.c | 4 +- src/transport/plugin_transport_wlan.c | 2 +- src/transport/test_quota_compliance.c | 2 +- src/transport/test_transport_api.c | 2 +- .../test_transport_api_reliability.c | 2 +- src/util/crypto_random.c | 2 +- src/util/os_priority.c | 128 ++++++++---------- src/util/test_os_start_process.c | 2 +- src/util/test_resolver_api.c | 2 +- src/vpn/gnunet-daemon-vpn.c | 2 +- 47 files changed, 120 insertions(+), 192 deletions(-) diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 81f1c2d5c..e404f8d27 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c @@ -375,7 +375,7 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct RequestContext *pos = cls; - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; char *binary; char *config; char *loprefix; diff --git a/src/arm/do_start_process.c b/src/arm/do_start_process.c index 7d691ce60..139d0c429 100644 --- a/src/arm/do_start_process.c +++ b/src/arm/do_start_process.c @@ -12,7 +12,7 @@ * @param ... more arguments, NULL terminated * @return PID of the started process, -1 on error */ -static GNUNET_OS_Process * +static struct GNUNET_OS_Process * do_start_process (const int *lsocks, const char *first_arg, ...) { @@ -24,7 +24,7 @@ do_start_process (const int *lsocks, char *pos; char *cp; const char *last; - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; argv_size = 1; va_start (ap, first_arg); diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index 543e65557..ab4db97c7 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -93,7 +93,7 @@ struct ServiceList /** * Process structure pointer of the child. */ - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; /** * Last time the config of this service was @@ -434,12 +434,10 @@ start_process (struct ServiceList *sl, sl->name); else GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Starting service `%s' (PID: %d)\n"), - sl->name, - (int) GNUNET_OS_process_get_pid (sl->proc)); + _("Starting service `%s'\n"), + sl->name); GNUNET_free (loprefix); GNUNET_free (options); - /* FIXME: should check sl->proc */ } @@ -735,9 +733,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (pos->proc != NULL) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Stopping service `%s' (PID: %d)\n", - pos->name, - GNUNET_OS_process_get_pid (pos->proc)); + "Stopping service `%s'\n", + pos->name); if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); } diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index a4c3b0a78..eb7bc60f6 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -54,7 +54,7 @@ struct PeerContext struct GNUNET_MessageHeader *hello; int connect_status; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index 0b3be2f82..49fe8f9de 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c @@ -74,7 +74,7 @@ struct PeerContext struct GNUNET_MessageHeader *hello; int connect_status; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index e82f12ed3..958defbf9 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c @@ -49,7 +49,7 @@ struct PeerContext struct GNUNET_CORE_Handle *ch; struct GNUNET_PeerIdentity id; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index 07bb16016..8dd7e6680 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c @@ -372,7 +372,7 @@ run (void *cls, static int check () { - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; char cfg_name[128]; char *const argv[] = { "perf-datastore-api", diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index feba0b7ac..3b7202005 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -641,7 +641,7 @@ check () { char cfg_name[128]; #if START_DATASTORE - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; #endif char *const argv[] = { "test-datastore-api", diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index fbb8795a6..81450d12a 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c @@ -350,7 +350,7 @@ run (void *cls, static int check () { - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; char cfg_name[128]; char *const argv[] = { "test-datastore-api-management", diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c index 5ef70407c..5eeb44d13 100644 --- a/src/dht/test_dht_api.c +++ b/src/dht/test_dht_api.c @@ -85,7 +85,7 @@ struct PeerContext struct GNUNET_DHT_FindPeerHandle *find_peer_handle; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs.c b/src/fs/test_fs.c index a97faf94f..41a155407 100644 --- a/src/fs/test_fs.c +++ b/src/fs/test_fs.c @@ -104,7 +104,7 @@ int main (int argc, char *argv[]) { #if START_DAEMON - GNUNET_OS_Process *daemon; + struct GNUNET_OS_Process *daemon; #endif int ok; struct GNUNET_ECRS_URI *uri; diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 305dee07e..4bcedcb4d 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c @@ -52,7 +52,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_download_indexed.c b/src/fs/test_fs_download_indexed.c index b55f2221b..21d95d584 100644 --- a/src/fs/test_fs_download_indexed.c +++ b/src/fs/test_fs_download_indexed.c @@ -52,7 +52,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c index 6bb4ab865..966d52412 100644 --- a/src/fs/test_fs_download_persistence.c +++ b/src/fs/test_fs_download_persistence.c @@ -52,7 +52,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_download_recursive.c b/src/fs/test_fs_download_recursive.c index a60a2da9a..ee320640c 100644 --- a/src/fs/test_fs_download_recursive.c +++ b/src/fs/test_fs_download_recursive.c @@ -256,7 +256,7 @@ int main (int argc, char *argv[]) { #if START_DAEMON - GNUNET_OS_Process *daemon; + struct GNUNET_OS_Process *daemon; #endif int ok; char *fn = NULL; diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c index 1221ff6c4..0e46336df 100644 --- a/src/fs/test_fs_list_indexed.c +++ b/src/fs/test_fs_list_indexed.c @@ -56,7 +56,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c index efe44af0b..b7641ab3b 100644 --- a/src/fs/test_fs_namespace.c +++ b/src/fs/test_fs_namespace.c @@ -59,7 +59,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c index 1cf8653bb..2637b1665 100644 --- a/src/fs/test_fs_namespace_list_updateable.c +++ b/src/fs/test_fs_namespace_list_updateable.c @@ -55,7 +55,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c index 4e65e7590..b5472ca93 100644 --- a/src/fs/test_fs_publish.c +++ b/src/fs/test_fs_publish.c @@ -53,7 +53,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c index afbee2ec8..b1260456b 100644 --- a/src/fs/test_fs_publish_persistence.c +++ b/src/fs/test_fs_publish_persistence.c @@ -52,7 +52,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c index 515730689..1609cd8e3 100644 --- a/src/fs/test_fs_search.c +++ b/src/fs/test_fs_search.c @@ -53,7 +53,7 @@ struct PeerContext struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_PeerIdentity id; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c index c2af22de4..d755a9582 100644 --- a/src/fs/test_fs_search_persistence.c +++ b/src/fs/test_fs_search_persistence.c @@ -53,7 +53,7 @@ struct PeerContext struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_PeerIdentity id; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_search_ranking.c b/src/fs/test_fs_search_ranking.c index 06a069a32..06c37dfc2 100644 --- a/src/fs/test_fs_search_ranking.c +++ b/src/fs/test_fs_search_ranking.c @@ -126,7 +126,7 @@ int main (int argc, char *argv[]) { #if START_DAEMON - GNUNET_OS_Process *daemon; + struct GNUNET_OS_Process *daemon; #endif int ok; char *fn = NULL; diff --git a/src/fs/test_fs_start_stop.c b/src/fs/test_fs_start_stop.c index 22fb64ae7..f64596061 100644 --- a/src/fs/test_fs_start_stop.c +++ b/src/fs/test_fs_start_stop.c @@ -41,7 +41,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c index 0afed8f06..7adc4d229 100644 --- a/src/fs/test_fs_unindex.c +++ b/src/fs/test_fs_unindex.c @@ -52,7 +52,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c index d33ecb5fc..42f047b70 100644 --- a/src/fs/test_fs_unindex_persistence.c +++ b/src/fs/test_fs_unindex_persistence.c @@ -51,7 +51,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c index a13f58a65..63ba53b69 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.c +++ b/src/hostlist/test_gnunet_daemon_hostlist.c @@ -49,7 +49,7 @@ struct PeerContext struct GNUNET_TRANSPORT_Handle *th; struct GNUNET_MessageHeader *hello; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index b5e6ca0bf..aa4e6b9ab 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c @@ -71,7 +71,7 @@ struct PeerContext struct GNUNET_CORE_Handle *core; struct GNUNET_STATISTICS_Handle *stats; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h index 2152b279c..bb29e89df 100644 --- a/src/include/gnunet_os_lib.h +++ b/src/include/gnunet_os_lib.h @@ -47,7 +47,7 @@ extern "C" /** * Process information (OS-dependent) */ -typedef struct _GNUNET_OS_Process GNUNET_OS_Process; +struct GNUNET_OS_Process; /** @@ -175,15 +175,6 @@ void GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor #define GNUNET_OS_get_hostname_max_length() 255 #endif -/** - * Allocates new process structure - * - * Should be made internal? - * - * @return pointer to allocated structure - */ -GNUNET_OS_Process *GNUNET_OS_process_alloc (); - /** * Get process structure for current process @@ -193,7 +184,7 @@ GNUNET_OS_Process *GNUNET_OS_process_alloc (); * * @return pointer to the process sturcutre for this process */ -GNUNET_OS_Process *GNUNET_OS_process_current (); +struct GNUNET_OS_Process *GNUNET_OS_process_current (void); /** @@ -203,56 +194,16 @@ GNUNET_OS_Process *GNUNET_OS_process_current (); * @param sig signal * @return 0 on success, -1 on error */ -int GNUNET_OS_process_kill (GNUNET_OS_Process *proc, int sig); - -/** - * Get process ID - * - * Should be made internal? - * - * @param proc pointer to process structure - * @return process ID - */ -pid_t GNUNET_OS_process_get_pid (GNUNET_OS_Process *proc); - -/** - * Set process ID - * - * Should be made internal? - * - * @param proc pointer to process structure - * @param pid process ID - */ -void GNUNET_OS_process_set_pid (GNUNET_OS_Process *proc, pid_t pid); +int GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig); -#if WINDOWS -/** - * Get process handle - * - * Should be made internal? - * - * @param proc pointer to process structure - * @return process handle - */ -HANDLE GNUNET_OS_process_get_handle (GNUNET_OS_Process *proc); - -/** - * Set process handle - * - * Should be made internal? - * - * @param proc pointer to process structure - * @param handle process handle - */ -void GNUNET_OS_process_set_handle(GNUNET_OS_Process *proc, HANDLE handle); -#endif /** * Cleans up process structure contents (OS-dependent) and deallocates it * * @param proc pointer to process structure */ -void GNUNET_OS_process_close (GNUNET_OS_Process *proc); +void GNUNET_OS_process_close (struct GNUNET_OS_Process *proc); + /** * Set process priority @@ -261,7 +212,7 @@ void GNUNET_OS_process_close (GNUNET_OS_Process *proc); * @param prio priority value * @return GNUNET_OK on success, GNUNET_SYSERR on error */ -int GNUNET_OS_set_process_priority (GNUNET_OS_Process *proc, +int GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc, enum GNUNET_SCHEDULER_Priority prio); @@ -274,7 +225,7 @@ int GNUNET_OS_set_process_priority (GNUNET_OS_Process *proc, * @param ... NULL-terminated list of arguments to the process * @return pointer to process structure of the new process, NULL on error */ -GNUNET_OS_Process * +struct GNUNET_OS_Process * GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, const char *filename, ...); @@ -290,7 +241,7 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, * including the process name as the first argument * @return pointer to process structure of the new process, NULL on error */ -GNUNET_OS_Process * +struct GNUNET_OS_Process * GNUNET_OS_start_process_v (const int *lsocks, const char *filename, char *const argv[]); @@ -302,8 +253,8 @@ GNUNET_OS_start_process_v (const int *lsocks, const char *filename, * @param code return code/signal number * @return GNUNET_OK on success, GNUNET_NO if the process is still running, GNUNET_SYSERR otherwise */ -int GNUNET_OS_process_status (GNUNET_OS_Process *proc, - enum GNUNET_OS_ProcessStatusType *type, unsigned long *code); +int GNUNET_OS_process_status (struct GNUNET_OS_Process *proc, + enum GNUNET_OS_ProcessStatusType *type, unsigned long *code); /** @@ -311,7 +262,7 @@ int GNUNET_OS_process_status (GNUNET_OS_Process *proc, * @param proc pointer to process structure of the process to wait for * @return GNUNET_OK on success, GNUNET_SYSERR otherwise */ -int GNUNET_OS_process_wait (GNUNET_OS_Process *proc); +int GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc); #if 0 /* keep Emacsens' auto-indent happy */ diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index 3fee527b8..a00e59976 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h @@ -301,7 +301,7 @@ struct GNUNET_TESTING_Daemon /** * PID of the process that we started last. */ - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; /** * In which phase are we during the start of diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c index eea2eb973..2c3d54109 100755 --- a/src/peerinfo/perf_peerinfo_api.c +++ b/src/peerinfo/perf_peerinfo_api.c @@ -166,7 +166,7 @@ check () NULL }; #if START_SERVICE - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c index b2e95d767..eae448bbf 100644 --- a/src/peerinfo/test_peerinfo_api.c +++ b/src/peerinfo/test_peerinfo_api.c @@ -165,7 +165,7 @@ static int check () { int ok = 3; - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; char *const argv[] = { "test-peerinfo-api", "-c", "test_peerinfo_api_data.conf", diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c index 6a45e3b10..cce90146c 100644 --- a/src/statistics/test_statistics_api.c +++ b/src/statistics/test_statistics_api.c @@ -157,7 +157,7 @@ check () GNUNET_GETOPT_OPTION_END }; #if START_SERVICE - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", "gnunet-service-statistics", #if DEBUG_STATISTICS diff --git a/src/statistics/test_statistics_api_loop.c b/src/statistics/test_statistics_api_loop.c index b4e7ae7ab..7eaa9d27b 100644 --- a/src/statistics/test_statistics_api_loop.c +++ b/src/statistics/test_statistics_api_loop.c @@ -96,7 +96,7 @@ check () GNUNET_GETOPT_OPTION_END }; #if START_SERVICE - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", "gnunet-service-statistics", #if DEBUG_STATISTICS diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index ed1f2d591..7ca58faf1 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c @@ -179,7 +179,7 @@ static void gather_log_data () { char *peer_number; char *connect_number; - GNUNET_OS_Process *mem_process; + struct GNUNET_OS_Process *mem_process; GNUNET_asprintf(&peer_number, "%llu", num_peers); GNUNET_asprintf(&connect_number, "%llu", expected_connections); mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 4b34a21de..7322fc44a 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -1937,7 +1937,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) FILE *temp_friend_handle; unsigned int pg_iter; char *temp_service_path; - GNUNET_OS_Process **procarr; + struct GNUNET_OS_Process **procarr; char *arg; char * mytemp; enum GNUNET_OS_ProcessStatusType type; @@ -1946,7 +1946,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) int ret; int max_wait = 10; - procarr = GNUNET_malloc(sizeof(GNUNET_OS_Process *) * pg->total); + procarr = GNUNET_malloc(sizeof(struct GNUNET_OS_Process *) * pg->total); for (pg_iter = 0; pg_iter < pg->total; pg_iter++) { mytemp = GNUNET_DISK_mktemp("friends"); @@ -2064,7 +2064,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, const char static struct BlacklistContext blacklist_ctx; unsigned int pg_iter; char *temp_service_path; - GNUNET_OS_Process **procarr; + struct GNUNET_OS_Process **procarr; char *arg; char *mytemp; enum GNUNET_OS_ProcessStatusType type; @@ -2077,7 +2077,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, const char char *pos; char *temp_transports; - procarr = GNUNET_malloc(sizeof(GNUNET_OS_Process *) * pg->total); + procarr = GNUNET_malloc(sizeof(struct GNUNET_OS_Process *) * pg->total); for (pg_iter = 0; pg_iter < pg->total; pg_iter++) { mytemp = GNUNET_DISK_mktemp("blacklist"); diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index d39787900..1073b24b7 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -345,7 +345,7 @@ struct Plugin /** * The process id of the server process (if behind NAT) */ - GNUNET_OS_Process *server_proc; + struct GNUNET_OS_Process *server_proc; /** * List of open TCP sessions. @@ -958,7 +958,7 @@ run_gnunet_nat_client (struct Plugin *plugin, const char *addr, size_t addrlen) char inet4[INET_ADDRSTRLEN]; char *address_as_string; char *port_as_string; - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; const struct sockaddr *sa = (const struct sockaddr *)addr; #if DEBUG_TCP_NAT diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 0f53719fe..4bd8c36d3 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -471,7 +471,7 @@ struct Plugin /** * The process id of the server process (if behind NAT) */ - GNUNET_OS_Process *server_proc; + struct GNUNET_OS_Process *server_proc; }; @@ -702,7 +702,7 @@ run_gnunet_nat_client (struct Plugin *plugin, const char *addr, size_t addrlen) char addr_buf[INET_ADDRSTRLEN]; char *address_as_string; char *port_as_string; - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; const struct IPv4UdpAddress *t4; GNUNET_assert(addrlen == sizeof(struct IPv4UdpAddress)); diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index e53e4f3b4..0f95f48c7 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -135,7 +135,7 @@ struct Plugin /** * The process id of the server process (if behind NAT) */ - GNUNET_OS_Process *server_proc; + struct GNUNET_OS_Process *server_proc; /** * The interface of the wlan card given to us by the user. diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 39319f8d7..77279897d 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c @@ -65,7 +65,7 @@ struct PeerContext struct GNUNET_TRANSPORT_Handle *th; struct GNUNET_PeerIdentity id; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index 7a45ea0f0..cee1da25b 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c @@ -60,7 +60,7 @@ struct PeerContext struct GNUNET_TRANSPORT_Handle *th; struct GNUNET_PeerIdentity id; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index d9e88fe49..a8633e089 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c @@ -62,7 +62,7 @@ struct PeerContext struct GNUNET_TRANSPORT_Handle *th; struct GNUNET_PeerIdentity id; #if START_ARM - GNUNET_OS_Process *arm_proc; + struct GNUNET_OS_Process *arm_proc; #endif }; diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c index 75435a5e6..622817492 100644 --- a/src/util/crypto_random.c +++ b/src/util/crypto_random.c @@ -188,7 +188,7 @@ GNUNET_CRYPTO_random_disable_entropy_gathering () * Process ID of the "find" process that we use for * entropy gathering. */ -static GNUNET_OS_Process *genproc; +static struct GNUNET_OS_Process *genproc; /** * Function called by libgcrypt whenever we are diff --git a/src/util/os_priority.c b/src/util/os_priority.c index b9e5f010b..5f78e2179 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -29,7 +29,7 @@ #include "gnunet_os_lib.h" #include "disk.h" -struct _GNUNET_OS_Process +struct GNUNET_OS_Process { pid_t pid; #if WINDOWS @@ -37,18 +37,19 @@ struct _GNUNET_OS_Process #endif }; -static GNUNET_OS_Process current_process; +static struct GNUNET_OS_Process current_process; + -GNUNET_OS_Process * -GNUNET_OS_process_alloc () -{ - GNUNET_OS_Process *ret = GNUNET_malloc (sizeof (GNUNET_OS_Process)); - ret->pid = 0; #if WINDOWS - ret->handle = NULL; -#endif - return ret; +void +GNUNET_OS_process_set_handle(struct GNUNET_OS_Process *proc, HANDLE handle) +{ + if (proc->handle != NULL) + CloseHandle (proc->handle); + proc->handle = handle; } +#endif + /** * Get process structure for current process @@ -58,7 +59,7 @@ GNUNET_OS_process_alloc () * * @return pointer to the process sturcutre for this process */ -GNUNET_OS_Process * +struct GNUNET_OS_Process * GNUNET_OS_process_current () { #if WINDOWS @@ -71,7 +72,7 @@ GNUNET_OS_process_current () } int -GNUNET_OS_process_kill (GNUNET_OS_Process *proc, int sig) +GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) { #if WINDOWS if (sig == SIGKILL || sig == SIGTERM) @@ -79,7 +80,10 @@ GNUNET_OS_process_kill (GNUNET_OS_Process *proc, int sig) HANDLE h = GNUNET_OS_process_get_handle (proc); if (NULL == h) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid process information {%d, %08X}\n", GNUNET_OS_process_get_pid (proc), h); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + _("Invalid process information {%d, %08X}\n"), + proc->pid, + h); return -1; } if (!TerminateProcess (h, 0)) @@ -93,40 +97,13 @@ GNUNET_OS_process_kill (GNUNET_OS_Process *proc, int sig) errno = EINVAL; return -1; #else - return kill (GNUNET_OS_process_get_pid (proc), sig); + return kill (proc->pid, sig); #endif } -pid_t -GNUNET_OS_process_get_pid (GNUNET_OS_Process *proc) -{ - return proc->pid; -} - -void -GNUNET_OS_process_set_pid (GNUNET_OS_Process *proc, pid_t pid) -{ - proc->pid = pid; -} - -#if WINDOWS -HANDLE -GNUNET_OS_process_get_handle (GNUNET_OS_Process *proc) -{ - return proc->handle; -} - -void -GNUNET_OS_process_set_handle(GNUNET_OS_Process *proc, HANDLE handle) -{ - if (proc->handle != NULL) - CloseHandle (proc->handle); - proc->handle = handle; -} -#endif void -GNUNET_OS_process_close (GNUNET_OS_Process *proc) +GNUNET_OS_process_close (struct GNUNET_OS_Process *proc) { #if WINDOWS if (proc->handle != NULL) @@ -147,7 +124,7 @@ extern GNUNET_SIGNAL_Handler w32_sigchld_handler; static DWORD WINAPI ChildWaitThread (void *arg) { - GNUNET_OS_Process *proc = (GNUNET_OS_Process *) arg; + struct GNUNET_OS_Process *proc = (struct GNUNET_OS_Process *) arg; WaitForSingleObject (proc->handle, INFINITE); if (w32_sigchld_handler) @@ -165,11 +142,10 @@ ChildWaitThread (void *arg) * @return GNUNET_OK on success, GNUNET_SYSERR on error */ int -GNUNET_OS_set_process_priority (GNUNET_OS_Process *proc, +GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc, enum GNUNET_SCHEDULER_Priority prio) { int rprio; - pid_t pid; GNUNET_assert (prio < GNUNET_SCHEDULER_PRIORITY_COUNT); if (prio == GNUNET_SCHEDULER_PRIORITY_KEEP) @@ -223,16 +199,17 @@ GNUNET_OS_set_process_priority (GNUNET_OS_Process *proc, return GNUNET_SYSERR; } - pid = GNUNET_OS_process_get_pid (proc); - /* Set process priority */ #ifdef MINGW { - HANDLE h = GNUNET_OS_process_get_handle (proc); + HANDLE h = proc->handle; GNUNET_assert (h != NULL); SetPriorityClass (h, rprio); } #elif LINUX + pid_t pid; + + pid = proc->pid; if ( (0 == pid) || (pid == getpid () ) ) { @@ -251,7 +228,6 @@ GNUNET_OS_set_process_priority (GNUNET_OS_Process *proc, else { if (0 != setpriority (PRIO_PROCESS, pid, rprio)) - { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, "setpriority"); @@ -274,7 +250,7 @@ GNUNET_OS_set_process_priority (GNUNET_OS_Process *proc, * @param ... NULL-terminated list of arguments to the process * @return pointer to process structure of the new process, NULL on error */ -GNUNET_OS_Process * +struct GNUNET_OS_Process * GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, const char *filename, ...) @@ -283,7 +259,7 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, #ifndef MINGW pid_t ret; - GNUNET_OS_Process *gnunet_proc = NULL; + struct GNUNET_OS_Process *gnunet_proc = NULL; char **argv; int argc; int fd_stdout_write; @@ -342,8 +318,8 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, GNUNET_DISK_pipe_close_end(pipe_stdin, GNUNET_DISK_PIPE_END_READ); sleep (1); #endif - gnunet_proc = GNUNET_OS_process_alloc (); - GNUNET_OS_process_set_pid (gnunet_proc, ret); + gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process)); + gnunet_proc->pid = ret; } GNUNET_free (argv); return gnunet_proc; @@ -375,7 +351,7 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, int findresult; STARTUPINFO start; PROCESS_INFORMATION proc; - GNUNET_OS_Process *gnunet_proc = NULL; + struct GNUNET_OS_Process *gnunet_proc = NULL; HANDLE stdin_handle; HANDLE stdout_handle; @@ -429,9 +405,9 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, return NULL; } - gnunet_proc = GNUNET_OS_process_alloc (); - GNUNET_OS_process_set_pid (gnunet_proc, proc.dwProcessId); - GNUNET_OS_process_set_handle (gnunet_proc, proc.hProcess); + gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process)); + gnunet_proc->pid = proc.dwProcessId; + gnunet_proc->handle = proc.hProcess; CreateThread (NULL, 64000, ChildWaitThread, (void *) gnunet_proc, 0, NULL); @@ -455,7 +431,7 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, * @param argv NULL-terminated list of arguments to the process * @return process ID of the new process, -1 on error */ -GNUNET_OS_Process * +struct GNUNET_OS_Process * GNUNET_OS_start_process_v (const int *lsocks, const char *filename, char *const argv[]) { @@ -463,7 +439,7 @@ GNUNET_OS_start_process_v (const int *lsocks, pid_t ret; char lpid[16]; char fds[16]; - GNUNET_OS_Process *gnunet_proc = NULL; + struct GNUNET_OS_Process *gnunet_proc = NULL; int i; int j; int k; @@ -505,8 +481,8 @@ GNUNET_OS_start_process_v (const int *lsocks, be plenty in practice */ sleep (1); #endif - gnunet_proc = GNUNET_OS_process_alloc (); - GNUNET_OS_process_set_pid (gnunet_proc, ret); + gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process)); + gnunet_proc->pid = ret; } GNUNET_array_grow (lscp, ls, 0); return gnunet_proc; @@ -566,7 +542,7 @@ GNUNET_OS_start_process_v (const int *lsocks, int argcount = 0; char *non_const_filename = NULL; int filenamelen = 0; - GNUNET_OS_Process *gnunet_proc = NULL; + struct GNUNET_OS_Process *gnunet_proc = NULL; GNUNET_assert (lsocks == NULL); /* Count the number of arguments */ @@ -634,9 +610,9 @@ GNUNET_OS_start_process_v (const int *lsocks, return NULL; } - gnunet_proc = GNUNET_OS_process_alloc (); - GNUNET_OS_process_set_pid (gnunet_proc, proc.dwProcessId); - GNUNET_OS_process_set_handle (gnunet_proc, proc.hProcess); + gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process)); + gnunet_proc->pid = proc.dwProcessId; + gnunet_proc->handle = proc.hProcess; CreateThread (NULL, 64000, ChildWaitThread, (void *) gnunet_proc, 0, NULL); @@ -659,7 +635,8 @@ GNUNET_OS_start_process_v (const int *lsocks, * @return GNUNET_OK on success, GNUNET_NO if the process is still running, GNUNET_SYSERR otherwise */ int -GNUNET_OS_process_status (GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusType *type, +GNUNET_OS_process_status (struct GNUNET_OS_Process *proc, + enum GNUNET_OS_ProcessStatusType *type, unsigned long *code) { #ifndef MINGW @@ -667,7 +644,7 @@ GNUNET_OS_process_status (GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusT int ret; GNUNET_assert (0 != proc); - ret = waitpid (GNUNET_OS_process_get_pid (proc), &status, WNOHANG); + ret = waitpid (proc->pid, &status, WNOHANG); if (ret < 0) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); @@ -679,7 +656,7 @@ GNUNET_OS_process_status (GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusT *code = 0; return GNUNET_NO; } - if (GNUNET_OS_process_get_pid (proc) != ret) + if (proc->pid != ret) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); return GNUNET_SYSERR; @@ -716,7 +693,7 @@ GNUNET_OS_process_status (GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusT DWORD c, error_code, ret; h = GNUNET_OS_process_get_handle (proc); - ret = GNUNET_OS_process_get_pid (proc); + ret = proc->pid; if (h == NULL || ret == 0) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid process information {%d, %08X}\n", ret, h); @@ -753,22 +730,25 @@ GNUNET_OS_process_status (GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusT * @return GNUNET_OK on success, GNUNET_SYSERR otherwise */ int -GNUNET_OS_process_wait (GNUNET_OS_Process *proc) +GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc) { - pid_t pid = GNUNET_OS_process_get_pid (proc); + #ifndef MINGW + pid_t pid = proc->pid; if (pid != waitpid (pid, NULL, 0)) return GNUNET_SYSERR; - return GNUNET_OK; #else HANDLE h; int ret; - h = GNUNET_OS_process_get_handle (proc); + h = proc->handle; if (NULL == h) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid process information {%d, %08X}\n", pid, h); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Invalid process information {%d, %08X}\n", + proc->pid, + h); return GNUNET_SYSERR; } if (h == NULL) diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c index bd2eb2b09..bce1c7151 100644 --- a/src/util/test_os_start_process.c +++ b/src/util/test_os_start_process.c @@ -38,7 +38,7 @@ static char *test_phrase = "HELLO WORLD"; static int ok; -static GNUNET_OS_Process *proc; +static struct GNUNET_OS_Process *proc; /* Pipe to write to started processes stdin (on write end) */ static struct GNUNET_DISK_PipeHandle *hello_pipe_stdin; /* Pipe to read from started processes stdout (on read end) */ diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c index 7321ed587..734420e84 100644 --- a/src/util/test_resolver_api.c +++ b/src/util/test_resolver_api.c @@ -360,7 +360,7 @@ check() int ok = 1 + 2 + 4 + 8; char *fn; char *pfx; - GNUNET_OS_Process *proc; + struct GNUNET_OS_Process *proc; char * const argv[] = { "test-resolver-api", "-c", "test_resolver_api_data.conf", #if VERBOSE diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index a6f78d707..7edd3c52f 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c @@ -94,7 +94,7 @@ static unsigned char restart_hijack; /** * The process id of the helper */ -static GNUNET_OS_Process *helper_proc; +static struct GNUNET_OS_Process *helper_proc; /** * a list of outgoing dns-query-packets -- 2.25.1