aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-03-21 19:34:21 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-03-21 19:34:21 +0000
commite33dc73c8b45562f218055b9628234ac50ff350d (patch)
tree9d1b80a2923574e3318fa80c76467025d4a97b4e /src/core
parent3b94efac795b446012cf2b7bc3aa1fd29ccf0908 (diff)
downloadgnunet-e33dc73c8b45562f218055b9628234ac50ff350d.tar.gz
gnunet-e33dc73c8b45562f218055b9628234ac50ff350d.zip
print message if service is not running
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gnunet-core.c58
1 files changed, 45 insertions, 13 deletions
diff --git a/src/core/gnunet-core.c b/src/core/gnunet-core.c
index 4dbe49c50..6309b39e0 100644
--- a/src/core/gnunet-core.c
+++ b/src/core/gnunet-core.c
@@ -143,29 +143,35 @@ monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
143 } 143 }
144} 144}
145 145
146
147/** 146/**
148 * Main function that will be run by the scheduler. 147 * Function called with the result of the check if the 'transport'
148 * service is running.
149 * 149 *
150 * @param cls closure 150 * @param cls closure with our configuration
151 * @param args remaining command-line arguments 151 * @param result #GNUNET_YES if transport is running
152 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
153 * @param cfg configuration
154 */ 152 */
155static void 153static void
156run (void *cls, char *const *args, const char *cfgfile, 154testservice_task (void *cls, int result)
157 const struct GNUNET_CONFIGURATION_Handle *cfg)
158{ 155{
156 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
159 static const struct GNUNET_CORE_MessageHandler handlers[] = { 157 static const struct GNUNET_CORE_MessageHandler handlers[] = {
160 {NULL, 0, 0} 158 {NULL, 0, 0}
161 }; 159 };
162 if (args[0] != NULL) 160
161 if (result != GNUNET_OK)
162 {
163 FPRINTF (stderr, _("Service `%s' is not running\n"), "core");
164 return;
165 }
166
167 if (GNUNET_NO == monitor_connections)
163 { 168 {
164 FPRINTF (stderr, _("Invalid command line argument `%s'\n"), args[0]); 169 if (GNUNET_OK != GNUNET_CORE_iterate_peers (cfg, &connected_peer_callback, NULL))
165 return; 170 {
171 fprintf (stderr, ("Failed to connect to CORE service to iterate peers!\n"));
172 return;
173 }
166 } 174 }
167 if (GNUNET_NO == monitor_connections)
168 GNUNET_CORE_iterate_peers (cfg, &connected_peer_callback, NULL);
169 else 175 else
170 { 176 {
171 memset(&my_id, '\0', sizeof (my_id)); 177 memset(&my_id, '\0', sizeof (my_id));
@@ -178,12 +184,38 @@ run (void *cls, char *const *args, const char *cfgfile,
178 handlers); 184 handlers);
179 185
180 if (NULL == ch) 186 if (NULL == ch)
187 {
181 GNUNET_SCHEDULER_add_now (shutdown_task, NULL); 188 GNUNET_SCHEDULER_add_now (shutdown_task, NULL);
189 fprintf (stderr, ("Failed to connect to CORE service!\n"));
190 return;
191 }
182 else 192 else
183 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, shutdown_task, NULL); 193 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, shutdown_task, NULL);
184 } 194 }
185} 195}
186 196
197/**
198 * Main function that will be run by the scheduler.
199 *
200 * @param cls closure
201 * @param args remaining command-line arguments
202 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
203 * @param cfg configuration
204 */
205static void
206run (void *cls, char *const *args, const char *cfgfile,
207 const struct GNUNET_CONFIGURATION_Handle *cfg)
208{
209 if (args[0] != NULL)
210 {
211 FPRINTF (stderr, _("Invalid command line argument `%s'\n"), args[0]);
212 return;
213 }
214
215 GNUNET_CLIENT_service_test ("core", cfg, GNUNET_TIME_UNIT_SECONDS,
216 &testservice_task, (void *) cfg);
217}
218
187 219
188/** 220/**
189 * The main function to obtain peer information. 221 * The main function to obtain peer information.