aboutsummaryrefslogtreecommitdiff
path: root/src/arm/test_gnunet_service_arm.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-23 14:22:34 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-23 14:22:34 +0000
commit5742938289524f4c5fba7883742e4dd69cccf11d (patch)
treee16fea8b9d778f9825f897237b0c1880305776a0 /src/arm/test_gnunet_service_arm.c
parentf3edb5a8d6ba6f43f5df18f2e98bc1dae90c9d7a (diff)
downloadgnunet-5742938289524f4c5fba7883742e4dd69cccf11d.tar.gz
gnunet-5742938289524f4c5fba7883742e4dd69cccf11d.zip
refactoring ARM api to use new MQ
Diffstat (limited to 'src/arm/test_gnunet_service_arm.c')
-rw-r--r--src/arm/test_gnunet_service_arm.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/arm/test_gnunet_service_arm.c b/src/arm/test_gnunet_service_arm.c
index 33662e579..71bf55084 100644
--- a/src/arm/test_gnunet_service_arm.c
+++ b/src/arm/test_gnunet_service_arm.c
@@ -51,7 +51,7 @@ static struct GNUNET_ARM_Handle *arm;
51static void 51static void
52trigger_disconnect (void *cls) 52trigger_disconnect (void *cls)
53{ 53{
54 GNUNET_ARM_disconnect_and_free (arm); 54 GNUNET_ARM_disconnect (arm);
55 arm = NULL; 55 arm = NULL;
56} 56}
57 57
@@ -59,7 +59,6 @@ trigger_disconnect (void *cls)
59static void 59static void
60arm_stop_cb (void *cls, 60arm_stop_cb (void *cls,
61 enum GNUNET_ARM_RequestStatus status, 61 enum GNUNET_ARM_RequestStatus status,
62 const char *servicename,
63 enum GNUNET_ARM_Result result) 62 enum GNUNET_ARM_Result result)
64{ 63{
65 GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); 64 GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
@@ -100,15 +99,15 @@ service_list (void *cls,
100 stop_arm: 99 stop_arm:
101 GNUNET_ARM_request_service_stop (arm, 100 GNUNET_ARM_request_service_stop (arm,
102 "arm", 101 "arm",
103 TIMEOUT, 102 &arm_stop_cb,
104 &arm_stop_cb, NULL); 103 NULL);
105} 104}
106 105
107 106
108static void 107static void
109hostname_resolve_cb (void *cls, 108hostname_resolve_cb (void *cls,
110 const struct sockaddr *addr, 109 const struct sockaddr *addr,
111 socklen_t addrlen) 110 socklen_t addrlen)
112{ 111{
113 if ((0 == ret) || (4 == ret) || (1 == resolved_ok)) 112 if ((0 == ret) || (4 == ret) || (1 == resolved_ok))
114 return; 113 return;
@@ -120,8 +119,8 @@ hostname_resolve_cb (void *cls,
120 ret = 3; 119 ret = 3;
121 GNUNET_ARM_request_service_stop (arm, 120 GNUNET_ARM_request_service_stop (arm,
122 "arm", 121 "arm",
123 TIMEOUT, 122 &arm_stop_cb,
124 &arm_stop_cb, NULL); 123 NULL);
125 return; 124 return;
126 } 125 }
127 if (0 == asked_for_a_list) 126 if (0 == asked_for_a_list)
@@ -129,7 +128,6 @@ hostname_resolve_cb (void *cls,
129 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
130 "Resolved hostname, now checking the service list\n"); 129 "Resolved hostname, now checking the service list\n");
131 GNUNET_ARM_request_service_list (arm, 130 GNUNET_ARM_request_service_list (arm,
132 TIMEOUT,
133 &service_list, 131 &service_list,
134 NULL); 132 NULL);
135 asked_for_a_list = 1; 133 asked_for_a_list = 1;
@@ -141,7 +139,6 @@ hostname_resolve_cb (void *cls,
141static void 139static void
142arm_start_cb (void *cls, 140arm_start_cb (void *cls,
143 enum GNUNET_ARM_RequestStatus status, 141 enum GNUNET_ARM_RequestStatus status,
144 const char *servicename,
145 enum GNUNET_ARM_Result result) 142 enum GNUNET_ARM_Result result)
146{ 143{
147 GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); 144 GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK);
@@ -150,7 +147,8 @@ arm_start_cb (void *cls,
150 "Trying to resolve our own hostname!\n"); 147 "Trying to resolve our own hostname!\n");
151 /* connect to the resolver service */ 148 /* connect to the resolver service */
152 if (NULL == 149 if (NULL ==
153 GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, TIMEOUT, 150 GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC,
151 TIMEOUT,
154 &hostname_resolve_cb, 152 &hostname_resolve_cb,
155 NULL)) 153 NULL))
156 { 154 {
@@ -159,8 +157,9 @@ arm_start_cb (void *cls,
159 GNUNET_break (0); 157 GNUNET_break (0);
160 ret = 2; 158 ret = 2;
161 GNUNET_ARM_request_service_stop (arm, 159 GNUNET_ARM_request_service_stop (arm,
162 "arm", TIMEOUT, 160 "arm",
163 &arm_stop_cb, NULL); 161 &arm_stop_cb,
162 NULL);
164 } 163 }
165} 164}
166 165
@@ -171,11 +170,14 @@ run (void *cls,
171 const char *cfgfile, 170 const char *cfgfile,
172 const struct GNUNET_CONFIGURATION_Handle *c) 171 const struct GNUNET_CONFIGURATION_Handle *c)
173{ 172{
174 arm = GNUNET_ARM_connect (c, NULL, NULL); 173 arm = GNUNET_ARM_connect (c,
175 GNUNET_ARM_request_service_start (arm, "arm", 174 NULL,
175 NULL);
176 GNUNET_ARM_request_service_start (arm,
177 "arm",
176 GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 178 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
177 START_TIMEOUT, 179 &arm_start_cb,
178 &arm_start_cb, NULL); 180 NULL);
179} 181}
180 182
181 183