diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-10-08 07:49:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-10-08 07:49:55 +0000 |
commit | a1c355ddb246a875bf5f576d2c200e86351d3abe (patch) | |
tree | f77e30e4f0f8775b021f9f838ea1dac3e7708f08 /src/arm | |
parent | 76cc98f7b32077470b413b6efce1b219906bf758 (diff) | |
download | gnunet-a1c355ddb246a875bf5f576d2c200e86351d3abe.tar.gz gnunet-a1c355ddb246a875bf5f576d2c200e86351d3abe.zip |
-minor cleanup
Diffstat (limited to 'src/arm')
-rw-r--r-- | src/arm/test_gnunet_service_manager.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/src/arm/test_gnunet_service_manager.c b/src/arm/test_gnunet_service_manager.c index 2abcc9563..a126a6c94 100644 --- a/src/arm/test_gnunet_service_manager.c +++ b/src/arm/test_gnunet_service_manager.c | |||
@@ -37,18 +37,13 @@ | |||
37 | 37 | ||
38 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 38 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
39 | 39 | ||
40 | #define START_ARM GNUNET_YES | ||
41 | |||
42 | #define VERBOSE GNUNET_NO | ||
43 | |||
44 | static int ret = 1; | 40 | static int ret = 1; |
45 | 41 | ||
46 | 42 | ||
47 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 43 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
48 | 44 | ||
49 | #if START_ARM | ||
50 | static struct GNUNET_ARM_Handle *arm; | 45 | static struct GNUNET_ARM_Handle *arm; |
51 | #endif | 46 | |
52 | 47 | ||
53 | static void | 48 | static void |
54 | arm_stopped (void *cls, enum GNUNET_ARM_ProcessStatus success) | 49 | arm_stopped (void *cls, enum GNUNET_ARM_ProcessStatus success) |
@@ -62,12 +57,11 @@ arm_stopped (void *cls, enum GNUNET_ARM_ProcessStatus success) | |||
62 | { | 57 | { |
63 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM stopped\n"); | 58 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM stopped\n"); |
64 | } | 59 | } |
65 | #if START_ARM | ||
66 | GNUNET_ARM_disconnect (arm); | 60 | GNUNET_ARM_disconnect (arm); |
67 | arm = NULL; | 61 | arm = NULL; |
68 | #endif | ||
69 | } | 62 | } |
70 | 63 | ||
64 | |||
71 | static void | 65 | static void |
72 | hostNameResolveCB (void *cls, const struct sockaddr *addr, socklen_t addrlen) | 66 | hostNameResolveCB (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
73 | { | 67 | { |
@@ -76,18 +70,14 @@ hostNameResolveCB (void *cls, const struct sockaddr *addr, socklen_t addrlen) | |||
76 | if (NULL == addr) | 70 | if (NULL == addr) |
77 | { | 71 | { |
78 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Name not resolved!\n"); | 72 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Name not resolved!\n"); |
79 | #if START_ARM | ||
80 | GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); | 73 | GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); |
81 | #endif | ||
82 | ret = 3; | 74 | ret = 3; |
83 | return; | 75 | return; |
84 | } | 76 | } |
85 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 77 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
86 | "Resolved hostname, now stopping ARM\n"); | 78 | "Resolved hostname, now stopping ARM\n"); |
87 | ret = 0; | 79 | ret = 0; |
88 | #if START_ARM | ||
89 | GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); | 80 | GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); |
90 | #endif | ||
91 | } | 81 | } |
92 | 82 | ||
93 | 83 | ||
@@ -110,9 +100,7 @@ arm_notify (void *cls, enum GNUNET_ARM_ProcessStatus success) | |||
110 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 100 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
111 | "Unable initiate connection to resolver service\n"); | 101 | "Unable initiate connection to resolver service\n"); |
112 | ret = 2; | 102 | ret = 2; |
113 | #if START_ARM | ||
114 | GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); | 103 | GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); |
115 | #endif | ||
116 | } | 104 | } |
117 | } | 105 | } |
118 | 106 | ||
@@ -122,12 +110,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
122 | const struct GNUNET_CONFIGURATION_Handle *c) | 110 | const struct GNUNET_CONFIGURATION_Handle *c) |
123 | { | 111 | { |
124 | cfg = c; | 112 | cfg = c; |
125 | #if START_ARM | ||
126 | arm = GNUNET_ARM_connect (cfg, NULL); | 113 | arm = GNUNET_ARM_connect (cfg, NULL); |
127 | GNUNET_ARM_start_service (arm, "arm", GNUNET_OS_INHERIT_STD_OUT_AND_ERR, START_TIMEOUT, &arm_notify, NULL); | 114 | GNUNET_ARM_start_service (arm, "arm", |
128 | #else | 115 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, START_TIMEOUT, |
129 | arm_notify (NULL, GNUNET_YES); | 116 | &arm_notify, NULL); |
130 | #endif | ||
131 | } | 117 | } |
132 | 118 | ||
133 | 119 | ||
@@ -137,9 +123,6 @@ check () | |||
137 | char *const argv[] = { | 123 | char *const argv[] = { |
138 | "test-gnunet-service-manager", | 124 | "test-gnunet-service-manager", |
139 | "-c", "test_arm_api_data.conf", | 125 | "-c", "test_arm_api_data.conf", |
140 | #if VERBOSE | ||
141 | "-L", "DEBUG", | ||
142 | #endif | ||
143 | NULL | 126 | NULL |
144 | }; | 127 | }; |
145 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 128 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -172,13 +155,8 @@ main (int argc, char *argv[]) | |||
172 | hostname); | 155 | hostname); |
173 | return 0; | 156 | return 0; |
174 | } | 157 | } |
175 | |||
176 | GNUNET_log_setup ("test-gnunet-service-manager", | 158 | GNUNET_log_setup ("test-gnunet-service-manager", |
177 | #if VERBOSE | ||
178 | "DEBUG", | ||
179 | #else | ||
180 | "WARNING", | 159 | "WARNING", |
181 | #endif | ||
182 | NULL); | 160 | NULL); |
183 | check (); | 161 | check (); |
184 | return ret; | 162 | return ret; |