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 | |
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')
-rw-r--r-- | src/hostlist/gnunet-daemon-hostlist.c | 45 | ||||
-rw-r--r-- | src/hostlist/hostlist-client.c | 23 |
2 files changed, 33 insertions, 35 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) |
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 488443f6e..42c4dc994 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c | |||
@@ -33,8 +33,7 @@ | |||
33 | #include "gnunet_transport_service.h" | 33 | #include "gnunet_transport_service.h" |
34 | #include "gnunet-daemon-hostlist.h" | 34 | #include "gnunet-daemon-hostlist.h" |
35 | #include <curl/curl.h> | 35 | #include <curl/curl.h> |
36 | #include "gnunet_common.h" | 36 | #include "gnunet_util_lib.h" |
37 | #include "gnunet_bio_lib.h" | ||
38 | 37 | ||
39 | 38 | ||
40 | /** | 39 | /** |
@@ -416,6 +415,7 @@ get_bootstrap_server () | |||
416 | return ret; | 415 | return ret; |
417 | } | 416 | } |
418 | 417 | ||
418 | |||
419 | /** | 419 | /** |
420 | * Method deciding if a preconfigured or advertisied hostlist is used on a 50:50 ratio | 420 | * Method deciding if a preconfigured or advertisied hostlist is used on a 50:50 ratio |
421 | * @return uri to use, NULL if there is no URL available | 421 | * @return uri to use, NULL if there is no URL available |
@@ -479,6 +479,7 @@ save_hostlist_file (int shutdown); | |||
479 | 479 | ||
480 | /** | 480 | /** |
481 | * add val2 to val1 with overflow check | 481 | * add val2 to val1 with overflow check |
482 | * | ||
482 | * @param val1 value 1 | 483 | * @param val1 value 1 |
483 | * @param val2 value 2 | 484 | * @param val2 value 2 |
484 | * @return result | 485 | * @return result |
@@ -501,6 +502,7 @@ checked_add (uint64_t val1, uint64_t val2) | |||
501 | 502 | ||
502 | /** | 503 | /** |
503 | * Subtract val2 from val1 with underflow check | 504 | * Subtract val2 from val1 with underflow check |
505 | * | ||
504 | * @param val1 value 1 | 506 | * @param val1 value 1 |
505 | * @param val2 value 2 | 507 | * @param val2 value 2 |
506 | * @return result | 508 | * @return result |
@@ -516,8 +518,9 @@ checked_sub (uint64_t val1, uint64_t val2) | |||
516 | 518 | ||
517 | /** | 519 | /** |
518 | * Method to check if a URI is in hostlist linked list | 520 | * Method to check if a URI is in hostlist linked list |
521 | * | ||
519 | * @param uri uri to check | 522 | * @param uri uri to check |
520 | * @return GNUNET_YES if existing in linked list, GNUNET_NO if not | 523 | * @return #GNUNET_YES if existing in linked list, #GNUNET_NO if not |
521 | */ | 524 | */ |
522 | static int | 525 | static int |
523 | linked_list_contains (const char *uri) | 526 | linked_list_contains (const char *uri) |
@@ -1130,8 +1133,8 @@ handler_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
1130 | * @param cls closure (always NULL) | 1133 | * @param cls closure (always NULL) |
1131 | * @param peer the peer sending the message | 1134 | * @param peer the peer sending the message |
1132 | * @param message the actual message | 1135 | * @param message the actual message |
1133 | * @return GNUNET_OK to keep the connection open, | 1136 | * @return #GNUNET_OK to keep the connection open, |
1134 | * GNUNET_SYSERR to close it (signal serious error) | 1137 | * #GNUNET_SYSERR to close it (signal serious error) |
1135 | */ | 1138 | */ |
1136 | static int | 1139 | static int |
1137 | handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer, | 1140 | handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer, |
@@ -1211,8 +1214,8 @@ handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1211 | * we go the stat. Initiates hostlist download scheduling. | 1214 | * we go the stat. Initiates hostlist download scheduling. |
1212 | * | 1215 | * |
1213 | * @param cls closure | 1216 | * @param cls closure |
1214 | * @param success GNUNET_OK if statistics were | 1217 | * @param success #GNUNET_OK if statistics were |
1215 | * successfully obtained, GNUNET_SYSERR if not. | 1218 | * successfully obtained, #GNUNET_SYSERR if not. |
1216 | */ | 1219 | */ |
1217 | static void | 1220 | static void |
1218 | primary_task (void *cls, int success) | 1221 | primary_task (void *cls, int success) |
@@ -1256,8 +1259,6 @@ load_hostlist_file () | |||
1256 | char *uri; | 1259 | char *uri; |
1257 | char *emsg; | 1260 | char *emsg; |
1258 | struct Hostlist *hostlist; | 1261 | struct Hostlist *hostlist; |
1259 | |||
1260 | uri = NULL; | ||
1261 | uint32_t times_used; | 1262 | uint32_t times_used; |
1262 | uint32_t hellos_returned; | 1263 | uint32_t hellos_returned; |
1263 | uint64_t quality; | 1264 | uint64_t quality; |
@@ -1265,6 +1266,7 @@ load_hostlist_file () | |||
1265 | uint64_t created; | 1266 | uint64_t created; |
1266 | uint32_t counter; | 1267 | uint32_t counter; |
1267 | 1268 | ||
1269 | uri = NULL; | ||
1268 | if (GNUNET_OK != | 1270 | if (GNUNET_OK != |
1269 | GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE", | 1271 | GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE", |
1270 | &filename)) | 1272 | &filename)) |
@@ -1275,7 +1277,8 @@ load_hostlist_file () | |||
1275 | } | 1277 | } |
1276 | 1278 | ||
1277 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1279 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1278 | _("Loading saved hostlist entries from file `%s' \n"), filename); | 1280 | _("Loading saved hostlist entries from file `%s' \n"), |
1281 | filename); | ||
1279 | if (GNUNET_NO == GNUNET_DISK_file_test (filename)) | 1282 | if (GNUNET_NO == GNUNET_DISK_file_test (filename)) |
1280 | { | 1283 | { |
1281 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1284 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |