diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-04-01 17:54:06 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-04-01 17:54:06 +0000 |
commit | 4e3864ec2681a43fb13f5d6af6093ebed5a68196 (patch) | |
tree | 62fe35f676784c78e7f7db8bbe3f1506611d11fe /src/include/gnunet_testing_lib.h | |
parent | e1de3162b194d2c72ad66aafcf803477caa41730 (diff) | |
download | gnunet-4e3864ec2681a43fb13f5d6af6093ebed5a68196.tar.gz gnunet-4e3864ec2681a43fb13f5d6af6093ebed5a68196.zip |
- only have asynchronous peer stop
Diffstat (limited to 'src/include/gnunet_testing_lib.h')
-rw-r--r-- | src/include/gnunet_testing_lib.h | 115 |
1 files changed, 16 insertions, 99 deletions
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index 6b3333188..7181b9ca1 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h | |||
@@ -242,7 +242,9 @@ GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer); | |||
242 | 242 | ||
243 | 243 | ||
244 | /** | 244 | /** |
245 | * Stop the peer. | 245 | * Stop the peer. This call is blocking as it kills the peer's main ARM process |
246 | * by sending a SIGTERM and waits on it. For asynchronous shutdown of peer, see | ||
247 | * GNUNET_TESTING_peer_stop_async(). | ||
246 | * | 248 | * |
247 | * @param peer peer to stop | 249 | * @param peer peer to stop |
248 | * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer not running) | 250 | * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer not running) |
@@ -287,117 +289,32 @@ GNUNET_TESTING_peer_wait (struct GNUNET_TESTING_Peer *peer); | |||
287 | /** | 289 | /** |
288 | * Callback to inform whether the peer is running or stopped. | 290 | * Callback to inform whether the peer is running or stopped. |
289 | * | 291 | * |
290 | * @param cls the closure from GNUNET_TESTING_peer_configure2() | 292 | * @param cls the closure given to GNUNET_TESTING_peer_stop_async() |
291 | * @param peer the respective peer whose status is being reported | 293 | * @param peer the respective peer whose status is being reported |
292 | * @param success GNUNET_YES if the peer is running; GNUNET_NO if the peer is | 294 | * @param success GNUNET_YES if the peer is stopped; GNUNET_SYSERR upon any |
293 | * not running; GNUNET_SYSERR upon error communicating with the peer's | 295 | * error |
294 | * ARM service | ||
295 | */ | 296 | */ |
296 | typedef void (*GNUNET_TESTING_PeerStatusCallback) (void *cls, | 297 | typedef void (*GNUNET_TESTING_PeerStopCallback) (void *cls, |
297 | struct GNUNET_TESTING_Peer * | 298 | struct GNUNET_TESTING_Peer * |
298 | peer, | 299 | peer, |
299 | int success); | 300 | int success); |
300 | |||
301 | |||
302 | /** | ||
303 | * Wrapper over GNUNET_TESTING_peer_configure() to set the | ||
304 | * GNUNET_TESTING_PeerStatusCallback() for using functions | ||
305 | * GNUNET_TESTING_peer_start2() and GNUNET_TESTING_peer_stop2() | ||
306 | * | ||
307 | * @param system system to use to coordinate resource usage | ||
308 | * @param cfg configuration to use; will be UPDATED (to reflect needed | ||
309 | * changes in port numbers and paths) | ||
310 | * @param key_number number of the hostkey to use for the peer | ||
311 | * @param id identifier for the daemon, will be set, can be NULL | ||
312 | * @param emsg set to freshly allocated error message (set to NULL on success), | ||
313 | * can be NULL | ||
314 | * @param status_cb the status callback to call upon peer start and stop | ||
315 | * @return handle to the peer, NULL on error | ||
316 | */ | ||
317 | struct GNUNET_TESTING_Peer * | ||
318 | GNUNET_TESTING_peer_configure2 (struct GNUNET_TESTING_System *system, | ||
319 | struct GNUNET_CONFIGURATION_Handle *cfg, | ||
320 | uint32_t key_number, | ||
321 | struct GNUNET_PeerIdentity *id, | ||
322 | char **emsg, | ||
323 | GNUNET_TESTING_PeerStatusCallback status_cb, | ||
324 | void *cls); | ||
325 | |||
326 | |||
327 | /** | ||
328 | * Start a peer asynchronously using ARM API. Peer's startup is signaled | ||
329 | * through the GNUNET_TESTING_PeerStatusCallback() given to | ||
330 | * GNUNET_TESTING_peer_configure2(). To use this function the peer must be | ||
331 | * configured earlier using GNUNET_TESTING_peer_configure2(); | ||
332 | * | ||
333 | * @param peer the peer to start | ||
334 | * @param timeout how long to wait before giving up to start the peer | ||
335 | * @return GNUNET_OK upon successfully giving the request to the ARM API (this | ||
336 | * does not mean that the peer is successfully started); GNUNET_SYSERR | ||
337 | * upon any error. | ||
338 | */ | ||
339 | int | ||
340 | GNUNET_TESTING_peer_start2 (struct GNUNET_TESTING_Peer *peer, | ||
341 | struct GNUNET_TIME_Relative timeout); | ||
342 | 301 | ||
343 | 302 | ||
344 | /** | 303 | /** |
345 | * Stop a peer asynchronously using ARM API. Peer's shutdown is signaled | 304 | * Stop a peer asynchronously using ARM API. Peer's shutdown is signaled |
346 | * through the GNUNET_TESTING_PeerStatusCallback() given to | 305 | * through the GNUNET_TESTING_PeerStopCallback(). |
347 | * GNUNET_TESTING_peer_configure2(). To use this function the peer must be | ||
348 | * configured earlier using GNUNET_TESTING_peer_configure2(); | ||
349 | * | 306 | * |
350 | * @param peer the peer to stop | 307 | * @param peer the peer to stop |
351 | * @param timeout how long to wait before giving up to stop the peer | 308 | * @param cb the callback to signal peer shutdown |
309 | * @param cb_cls closure for the above callback | ||
352 | * @return GNUNET_OK upon successfully giving the request to the ARM API (this | 310 | * @return GNUNET_OK upon successfully giving the request to the ARM API (this |
353 | * does not mean that the peer is successfully stopped); GNUNET_SYSERR | 311 | * does not mean that the peer is successfully stopped); GNUNET_SYSERR |
354 | * upon any error. | 312 | * upon any error. |
355 | */ | 313 | */ |
356 | int | 314 | int |
357 | GNUNET_TESTING_peer_stop2 (struct GNUNET_TESTING_Peer *peer, | 315 | GNUNET_TESTING_peer_stop_async (struct GNUNET_TESTING_Peer *peer, |
358 | struct GNUNET_TIME_Relative timeout); | 316 | GNUNET_TESTING_PeerStopCallback cb, |
359 | 317 | void *cb_cls); | |
360 | |||
361 | /** | ||
362 | * Start a service at a peer using its ARM service. To use this function the | ||
363 | * peer must be configured earlier using GNUNET_TESTING_peer_configure2(); | ||
364 | * | ||
365 | * @param peer the peer whose service has to be started | ||
366 | * @param service_name name of the service to start | ||
367 | * @param timeout how long should the ARM API try to send the request to start | ||
368 | * the service | ||
369 | * @param cont the callback to call with result and status from ARM API | ||
370 | * @param cont_cls the closure for the above callback | ||
371 | * @return GNUNET_OK upon successfully queuing the service start request; | ||
372 | * GNUNET_SYSERR upon error | ||
373 | */ | ||
374 | int | ||
375 | GNUNET_TESTING_peer_service_start (struct GNUNET_TESTING_Peer *peer, | ||
376 | const char *service_name, | ||
377 | struct GNUNET_TIME_Relative timeout, | ||
378 | GNUNET_ARM_ResultCallback cont, | ||
379 | void *cont_cls); | ||
380 | |||
381 | |||
382 | /** | ||
383 | * Stop a service at a peer using its ARM service. To use this function the | ||
384 | * peer must be configured earlier using GNUNET_TESTING_peer_configure2(); | ||
385 | * | ||
386 | * @param peer the peer whose service has to be stopped | ||
387 | * @param service_name name of the service to stop | ||
388 | * @param timeout how long should the ARM API try to send the request to stop | ||
389 | * the service | ||
390 | * @param cont the callback to call with result and status from ARM API | ||
391 | * @param cont_cls the closure for the above callback | ||
392 | * @return GNUNET_OK upon successfully queuing the service stop request; | ||
393 | * GNUNET_SYSERR upon error | ||
394 | */ | ||
395 | int | ||
396 | GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer, | ||
397 | const char *service_name, | ||
398 | struct GNUNET_TIME_Relative timeout, | ||
399 | GNUNET_ARM_ResultCallback cont, | ||
400 | void *cont_cls); | ||
401 | 318 | ||
402 | 319 | ||
403 | /** | 320 | /** |