diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-05-12 14:01:29 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-05-12 14:01:29 +0000 |
commit | d75e6e4273b1bb43b5ca9f6b207c10fc824efbae (patch) | |
tree | 4b2548eabb82b8a00df676558125640fe72eac3c /src/mesh/test_mesh_api.c | |
parent | d95d14541ab481ad4697a432b5598535af07804c (diff) | |
download | gnunet-d75e6e4273b1bb43b5ca9f6b207c10fc824efbae.tar.gz gnunet-d75e6e4273b1bb43b5ca9f6b207c10fc824efbae.zip |
fixes
Diffstat (limited to 'src/mesh/test_mesh_api.c')
-rw-r--r-- | src/mesh/test_mesh_api.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/mesh/test_mesh_api.c b/src/mesh/test_mesh_api.c index 00212eb49..5f988f555 100644 --- a/src/mesh/test_mesh_api.c +++ b/src/mesh/test_mesh_api.c | |||
@@ -7,16 +7,31 @@ static struct GNUNET_MESH_MessageHandler handlers[] = { | |||
7 | {NULL, 0, 0} | 7 | {NULL, 0, 0} |
8 | }; | 8 | }; |
9 | 9 | ||
10 | static struct GNUNET_OS_Process *arm_pid; | ||
11 | |||
12 | static struct GNUNET_MESH_Handle *mesh; | ||
13 | |||
14 | static struct GNUNET_DHT_Handle *dht; | ||
15 | |||
16 | static void | ||
17 | do_shutdown (void *cls, | ||
18 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
19 | { | ||
20 | if (NULL != mesh) | ||
21 | GNUNET_MESH_disconnect (mesh); | ||
22 | if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM)) | ||
23 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
24 | GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid)); | ||
25 | GNUNET_OS_process_close (arm_pid); | ||
26 | } | ||
27 | |||
10 | 28 | ||
11 | static void | 29 | static void |
12 | run (void *cls, | 30 | run (void *cls, |
13 | char *const *args, | 31 | char *const *args, |
14 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { | 32 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { |
15 | struct GNUNET_OS_Process *arm_pid; | ||
16 | struct GNUNET_MESH_Handle *mesh; | ||
17 | struct GNUNET_DHT_Handle *dht; | ||
18 | GNUNET_MESH_ApplicationType app; | 33 | GNUNET_MESH_ApplicationType app; |
19 | char buffer[2048]; | 34 | // char buffer[2048]; |
20 | 35 | ||
21 | 36 | ||
22 | arm_pid = GNUNET_OS_start_process (NULL, NULL, | 37 | arm_pid = GNUNET_OS_start_process (NULL, NULL, |
@@ -41,16 +56,15 @@ run (void *cls, | |||
41 | } | 56 | } |
42 | 57 | ||
43 | /* do real test work here */ | 58 | /* do real test work here */ |
44 | if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM)) | 59 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
45 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 60 | &do_shutdown, |
46 | GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid)); | 61 | NULL); |
47 | GNUNET_OS_process_close (arm_pid); | ||
48 | |||
49 | return; | ||
50 | } | 62 | } |
51 | 63 | ||
52 | 64 | ||
53 | 65 | ||
66 | |||
67 | |||
54 | int main (int argc, char *argv[]) { | 68 | int main (int argc, char *argv[]) { |
55 | int ret; | 69 | int ret; |
56 | char *const argv2[] = {"test-mesh-api", | 70 | char *const argv2[] = {"test-mesh-api", |