diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-12 21:31:39 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-12 21:31:39 +0000 |
commit | a3a0876515d21f481958d64ad697c13b5c9dc0fd (patch) | |
tree | 8b983a14fe3a9d13a27d7c74daf32c15b864e946 /src/hostlist/gnunet-daemon-hostlist.c | |
parent | c2f5b2142fa3a95c7c4aba81010754776955143c (diff) | |
download | gnunet-a3a0876515d21f481958d64ad697c13b5c9dc0fd.tar.gz gnunet-a3a0876515d21f481958d64ad697c13b5c9dc0fd.zip |
-doxygen, style, possibly fixing hostlist-client missing first core connect notification
Diffstat (limited to 'src/hostlist/gnunet-daemon-hostlist.c')
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index c3543027a..b83356d10 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c | |||
@@ -28,13 +28,9 @@ | |||
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "hostlist-client.h" | 29 | #include "hostlist-client.h" |
30 | #include "gnunet_core_service.h" | 30 | #include "gnunet_core_service.h" |
31 | #include "gnunet_getopt_lib.h" | 31 | #include "gnunet_util_lib.h" |
32 | #include "gnunet_protocols.h" | 32 | #include "gnunet_protocols.h" |
33 | #include "gnunet_program_lib.h" | ||
34 | #include "gnunet_statistics_service.h" | 33 | #include "gnunet_statistics_service.h" |
35 | #include "gnunet_strings_lib.h" | ||
36 | #include "gnunet_time_lib.h" | ||
37 | #include "gnunet_util_lib.h" | ||
38 | 34 | ||
39 | #if HAVE_MHD | 35 | #if HAVE_MHD |
40 | 36 | ||
@@ -156,7 +152,8 @@ advertisement_handler (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
156 | 152 | ||
157 | 153 | ||
158 | /** | 154 | /** |
159 | * Method called whenever a given peer connects. Wrapper to call both client's and server's functions | 155 | * Method called whenever a given peer connects. Wrapper to call both |
156 | * client's and server's functions | ||
160 | * | 157 | * |
161 | * @param cls closure | 158 | * @param cls closure |
162 | * @param peer peer identity this notification is about | 159 | * @param peer peer identity this notification is about |
@@ -169,17 +166,17 @@ connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
169 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
170 | "A new peer connected, notifying client and server\n"); | 167 | "A new peer connected, notifying client and server\n"); |
171 | if (NULL != client_ch) | 168 | if (NULL != client_ch) |
172 | { | ||
173 | (*client_ch) (cls, peer); | 169 | (*client_ch) (cls, peer); |
174 | } | ||
175 | #if HAVE_MHD | 170 | #if HAVE_MHD |
176 | if (NULL != server_ch) | 171 | if (NULL != server_ch) |
177 | (*server_ch) (cls, peer); | 172 | (*server_ch) (cls, peer); |
178 | #endif | 173 | #endif |
179 | } | 174 | } |
180 | 175 | ||
176 | |||
181 | /** | 177 | /** |
182 | * Method called whenever a given peer disconnects. Wrapper to call both client's and server's functions | 178 | * Method called whenever a given peer disconnects. Wrapper to call |
179 | * both client's and server's functions | ||
183 | * | 180 | * |
184 | * @param cls closure | 181 | * @param cls closure |
185 | * @param peer peer identity this notification is about | 182 | * @param peer peer identity this notification is about |
@@ -199,6 +196,7 @@ disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
199 | #endif | 196 | #endif |
200 | } | 197 | } |
201 | 198 | ||
199 | |||
202 | /** | 200 | /** |
203 | * Last task run during shutdown. Disconnects us from | 201 | * Last task run during shutdown. Disconnects us from |
204 | * the other services. | 202 | * the other services. |
@@ -206,7 +204,8 @@ disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
206 | static void | 204 | static void |
207 | cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 205 | cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
208 | { | 206 | { |
209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostlist daemon is shutting down\n"); | 207 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
208 | "Hostlist daemon is shutting down\n"); | ||
210 | if (core != NULL) | 209 | if (core != NULL) |
211 | { | 210 | { |
212 | GNUNET_CORE_disconnect (core); | 211 | GNUNET_CORE_disconnect (core); |
@@ -260,31 +259,27 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
260 | ("None of the functions for the hostlist daemon were enabled. I have no reason to run!\n")); | 259 | ("None of the functions for the hostlist daemon were enabled. I have no reason to run!\n")); |
261 | return; | 260 | return; |
262 | } | 261 | } |
263 | |||
264 | |||
265 | |||
266 | stats = GNUNET_STATISTICS_create ("hostlist", cfg); | 262 | stats = GNUNET_STATISTICS_create ("hostlist", cfg); |
267 | |||
268 | core = | ||
269 | GNUNET_CORE_connect (cfg, NULL, &core_init, &connect_handler, | ||
270 | &disconnect_handler, NULL, GNUNET_NO, NULL, | ||
271 | GNUNET_NO, | ||
272 | learning ? learn_handlers : no_learn_handlers); | ||
273 | |||
274 | if (bootstrapping) | 263 | if (bootstrapping) |
275 | { | ||
276 | GNUNET_HOSTLIST_client_start (cfg, stats, &client_ch, &client_dh, | 264 | GNUNET_HOSTLIST_client_start (cfg, stats, &client_ch, &client_dh, |
277 | &client_adv_handler, learning); | 265 | &client_adv_handler, learning); |
278 | } | 266 | core = |
267 | GNUNET_CORE_connect (cfg, NULL, | ||
268 | &core_init, | ||
269 | &connect_handler, | ||
270 | &disconnect_handler, NULL, | ||
271 | GNUNET_NO, NULL, | ||
272 | GNUNET_NO, | ||
273 | learning ? learn_handlers : no_learn_handlers); | ||
274 | |||
279 | 275 | ||
280 | #if HAVE_MHD | 276 | #if HAVE_MHD |
281 | if (provide_hostlist) | 277 | if (provide_hostlist) |
282 | { | ||
283 | GNUNET_HOSTLIST_server_start (cfg, stats, core, &server_ch, &server_dh, | 278 | GNUNET_HOSTLIST_server_start (cfg, stats, core, &server_ch, &server_dh, |
284 | advertising); | 279 | advertising); |
285 | } | ||
286 | #endif | 280 | #endif |
287 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, | 281 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
282 | &cleaning_task, | ||
288 | NULL); | 283 | NULL); |
289 | 284 | ||
290 | if (NULL == core) | 285 | if (NULL == core) |