diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-10-05 09:56:25 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-10-05 09:56:25 +0000 |
commit | d75fb1880a887a8f5339c5e8cf5e9d2b8755fdad (patch) | |
tree | f8dff53b4b88b0d87ca31a772607ee51fb0653ec /src/arm/test_arm_api.c | |
parent | b9b0940e261a4b1713d909f0a2fd54134ed5b148 (diff) | |
download | gnunet-d75fb1880a887a8f5339c5e8cf5e9d2b8755fdad.tar.gz gnunet-d75fb1880a887a8f5339c5e8cf5e9d2b8755fdad.zip |
improving ARM API
Diffstat (limited to 'src/arm/test_arm_api.c')
-rw-r--r-- | src/arm/test_arm_api.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c index fbd90583e..22fa3716e 100644 --- a/src/arm/test_arm_api.c +++ b/src/arm/test_arm_api.c | |||
@@ -40,17 +40,28 @@ static struct GNUNET_SCHEDULER_Handle *sched; | |||
40 | 40 | ||
41 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 41 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
42 | 42 | ||
43 | static struct GNUNET_ARM_Handle *arm; | ||
44 | |||
43 | static int ok = 1; | 45 | static int ok = 1; |
44 | 46 | ||
47 | |||
48 | static void | ||
49 | arm_notify_stop (void *cls, int success) | ||
50 | { | ||
51 | GNUNET_assert (success == GNUNET_NO); | ||
52 | #if START_ARM | ||
53 | GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, NULL, NULL); | ||
54 | #endif | ||
55 | } | ||
56 | |||
57 | |||
45 | static void | 58 | static void |
46 | dns_notify (void *cls, const struct sockaddr *addr, socklen_t addrlen) | 59 | dns_notify (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
47 | { | 60 | { |
48 | if (addr == NULL) | 61 | if (addr == NULL) |
49 | { | 62 | { |
50 | GNUNET_assert (ok == 0); | 63 | GNUNET_assert (ok == 0); |
51 | #if START_ARM | 64 | GNUNET_ARM_stop_service (arm, "resolver", TIMEOUT, &arm_notify_stop, NULL); |
52 | GNUNET_ARM_stop_service ("arm", cfg, sched, TIMEOUT, NULL, NULL); | ||
53 | #endif | ||
54 | return; | 65 | return; |
55 | } | 66 | } |
56 | GNUNET_assert (addr != NULL); | 67 | GNUNET_assert (addr != NULL); |
@@ -62,21 +73,17 @@ static void | |||
62 | resolver_notify (void *cls, int success) | 73 | resolver_notify (void *cls, int success) |
63 | { | 74 | { |
64 | GNUNET_assert (success == GNUNET_YES); | 75 | GNUNET_assert (success == GNUNET_YES); |
65 | sleep (1); /* FIXME: that we need to do this is a problem... */ | ||
66 | GNUNET_RESOLVER_ip_get (sched, | 76 | GNUNET_RESOLVER_ip_get (sched, |
67 | cfg, | 77 | cfg, |
68 | "localhost", AF_INET, TIMEOUT, &dns_notify, NULL); | 78 | "localhost", AF_INET, TIMEOUT, &dns_notify, NULL); |
69 | } | 79 | } |
70 | 80 | ||
81 | |||
71 | static void | 82 | static void |
72 | arm_notify (void *cls, int success) | 83 | arm_notify (void *cls, int success) |
73 | { | 84 | { |
74 | GNUNET_assert (success == GNUNET_YES); | 85 | GNUNET_assert (success == GNUNET_YES); |
75 | #if START_ARM | 86 | GNUNET_ARM_start_service (arm, "resolver", TIMEOUT, &resolver_notify, NULL); |
76 | sleep (1); /* FIXME: that we need to do this is a problem... */ | ||
77 | #endif | ||
78 | GNUNET_ARM_start_service ("resolver", | ||
79 | cfg, sched, TIMEOUT, &resolver_notify, NULL); | ||
80 | } | 87 | } |
81 | 88 | ||
82 | 89 | ||
@@ -89,8 +96,9 @@ task (void *cls, | |||
89 | { | 96 | { |
90 | cfg = c; | 97 | cfg = c; |
91 | sched = s; | 98 | sched = s; |
99 | arm = GNUNET_ARM_connect (cfg, sched, NULL); | ||
92 | #if START_ARM | 100 | #if START_ARM |
93 | GNUNET_ARM_start_service ("arm", cfg, sched, TIMEOUT, &arm_notify, NULL); | 101 | GNUNET_ARM_start_service (arm, "arm", TIMEOUT, &arm_notify, NULL); |
94 | #else | 102 | #else |
95 | arm_notify (NULL, GNUNET_YES); | 103 | arm_notify (NULL, GNUNET_YES); |
96 | #endif | 104 | #endif |