#include "gnunet_common.h"
#include "gnunet_bio_lib.h"
-#define DEBUG_HOSTLIST_CLIENT GNUNET_NO
-
/**
* Number of connections that we must have to NOT download
*/
static struct Hostlist *hostlist_to_test;
+/**
+ * Handle for our statistics GET operation.
+ */
+static struct GNUNET_STATISTICS_GetHandle *sget;
+
/**
* Set to GNUNET_YES if the current URL had some problems.
*/
left -= cpy;
if (download_pos < sizeof (struct GNUNET_MessageHeader))
{
- GNUNET_assert (left == 0);
+ GNUNET_assert (0 == left);
break;
}
msg = (const struct GNUNET_MessageHeader *) download_buffer;
}
if (GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) msg) == msize)
{
-#if DEBUG_HOSTLIST_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received valid `%s' message from hostlist server.\n",
"HELLO");
-#endif
GNUNET_STATISTICS_update (stats,
gettext_noop
("# valid HELLOs downloaded from hostlist servers"),
size_t pos;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "HOSTLIST", "SERVERS", &servers))
+ GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "SERVERS",
+ &servers))
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _
- ("No `%s' specified in `%s' configuration, will not bootstrap.\n"),
- "SERVERS", "HOSTLIST");
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+ "hostlist", "SERVERS");
return NULL;
}
}
if (urls == 0)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _
- ("No `%s' specified in `%s' configuration, will not bootstrap.\n"),
- "SERVERS", "HOSTLIST");
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+ "hostlist", "SERVERS");
GNUNET_free (servers);
return NULL;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Testing new advertised hostlist if it is obtainable\n");
current_hostlist = hostlist_to_test;
- return strdup (hostlist_to_test->hostlist_uri);
+ return GNUNET_strdup (hostlist_to_test->hostlist_uri);
}
if ((GNUNET_YES == stat_use_bootstrap) || (linked_list_size == 0))
current_hostlist = NULL;
return get_bootstrap_server ();
}
- index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- linked_list_size);
+ index =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, linked_list_size);
counter = 0;
pos = linked_list_head;
while (counter < index)
pos = pos->next;
counter++;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Using learned hostlist `%s'\n", pos->hostlist_uri);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using learned hostlist `%s'\n",
+ pos->hostlist_uri);
current_hostlist = pos;
- return strdup (pos->hostlist_uri);
+ return GNUNET_strdup (pos->hostlist_uri);
}
-#define CURL_EASY_SETOPT(c, a, b) do { ret = curl_easy_setopt(c, a, b); if (ret != CURLE_OK) GNUNET_log(GNUNET_ERROR_TYPE_WARNING, _("%s failed at %s:%d: `%s'\n"), "curl_easy_setopt", __FILE__, __LINE__, curl_easy_strerror(ret)); } while (0)
+#define CURL_EASY_SETOPT(c, a, b) do { ret = curl_easy_setopt (c, a, b); if (CURLE_OK != ret) GNUNET_log(GNUNET_ERROR_TYPE_WARNING, _("%s failed at %s:%d: `%s'\n"), "curl_easy_setopt", __FILE__, __LINE__, curl_easy_strerror (ret)); } while (0)
/**
* Method to save hostlist to a file during hostlist client shutdown
* @param shutdown set if called because of shutdown, entries in linked list will be destroyed
*/
-static void save_hostlist_file (int shutdown);
+static void
+save_hostlist_file (int shutdown);
/**
temp = val1 + val2;
if (temp < val1)
return maxv;
- else
- return temp;
+ return temp;
}
+
/**
* Subtract val2 from val1 with underflow check
* @param val1 value 1
{
if (val1 <= val2)
return 0;
- else
- return (val1 - val2);
+ return (val1 - val2);
}
+
/**
* Method to check if a URI is in hostlist linked list
* @param uri uri to check
linked_list_size--;
GNUNET_free (lowest_quality);
}
- GNUNET_CONTAINER_DLL_insert (linked_list_head,
- linked_list_tail, hostlist_to_test);
+ GNUNET_CONTAINER_DLL_insert (linked_list_head, linked_list_tail,
+ hostlist_to_test);
linked_list_size++;
- GNUNET_STATISTICS_set (stats,
- gettext_noop ("# advertised hostlist URIs"),
+ GNUNET_STATISTICS_set (stats, gettext_noop ("# advertised hostlist URIs"),
linked_list_size, GNUNET_NO);
stat_testing_hostlist = GNUNET_NO;
}
stat_use_bootstrap = GNUNET_YES;
}
+
/**
* Clean up the state from the task that downloaded the
* hostlist and schedule the next task.
mret = curl_multi_remove_handle (multi, curl);
if (mret != CURLM_OK)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("%s failed at %s:%d: `%s'\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
"curl_multi_remove_handle", __FILE__, __LINE__,
curl_multi_strerror (mret));
}
mret = curl_multi_cleanup (multi);
if (mret != CURLM_OK)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("%s failed at %s:%d: `%s'\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
"curl_multi_cleanup", __FILE__, __LINE__,
curl_multi_strerror (mret));
multi = NULL;
mret = curl_multi_fdset (multi, &rs, &ws, &es, &max);
if (mret != CURLM_OK)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("%s failed at %s:%d: `%s'\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
"curl_multi_fdset", __FILE__, __LINE__,
curl_multi_strerror (mret));
clean_up ();
mret = curl_multi_timeout (multi, &timeout);
if (mret != CURLM_OK)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("%s failed at %s:%d: `%s'\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
"curl_multi_timeout", __FILE__, __LINE__,
curl_multi_strerror (mret));
clean_up ();
gws = GNUNET_NETWORK_fdset_create ();
GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
-#if DEBUG_HOSTLIST_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Scheduling task for hostlist download using cURL\n");
-#endif
- ti_download
- = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- GNUNET_SCHEDULER_NO_TASK,
- rtime, grs, gws, &task_download, multi);
+ ti_download =
+ GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+ rtime, grs, gws,
+ &task_download, multi);
GNUNET_NETWORK_fdset_destroy (gws);
GNUNET_NETWORK_fdset_destroy (grs);
}
/**
* Task that is run when we are ready to receive more data from the hostlist
- * server.
+ * server.
*
* @param cls closure, unused
* @param tc task context, unused
ti_download = GNUNET_SCHEDULER_NO_TASK;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
{
-#if DEBUG_HOSTLIST_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Shutdown requested while trying to download hostlist from `%s'\n",
current_url);
-#endif
update_hostlist ();
clean_up ();
return;
clean_up ();
return;
}
-#if DEBUG_HOSTLIST_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Ready for processing hostlist client request\n");
-#endif
-
do
{
running = 0;
case CURLMSG_DONE:
if ((msg->data.result != CURLE_OK) &&
(msg->data.result != CURLE_GOT_NOTHING))
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("%s failed for `%s' at %s:%d: `%s'\n"),
- "curl_multi_perform",
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Download of hostlist from `%s' failed: `%s'\n"),
current_url,
- __FILE__,
- __LINE__, curl_easy_strerror (msg->data.result));
+ curl_easy_strerror (msg->data.result));
else
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
if (mret != CURLM_OK)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("%s failed at %s:%d: `%s'\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("%s failed at %s:%d: `%s'\n"),
"curl_multi_perform", __FILE__, __LINE__,
curl_multi_strerror (mret));
clean_up ();
stat_bytes_downloaded = 0;
GNUNET_STATISTICS_update (stats,
- gettext_noop ("# hostlist downloads initiated"),
- 1, GNUNET_NO);
+ gettext_noop ("# hostlist downloads initiated"), 1,
+ GNUNET_NO);
if (proxy != NULL)
CURL_EASY_SETOPT (curl, CURLOPT_PROXY, proxy);
download_pos = 0;
return;
}
CURL_EASY_SETOPT (curl, CURLOPT_FOLLOWLOCATION, 1);
+ CURL_EASY_SETOPT (curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
+ CURL_EASY_SETOPT (curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
CURL_EASY_SETOPT (curl, CURLOPT_MAXREDIRS, 4);
/* no need to abort if the above failed */
CURL_EASY_SETOPT (curl, CURLOPT_URL, current_url);
mret = curl_multi_add_handle (multi, curl);
if (mret != CURLM_OK)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("%s failed at %s:%d: `%s'\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
"curl_multi_add_handle", __FILE__, __LINE__,
curl_multi_strerror (mret));
mret = curl_multi_cleanup (multi);
if (mret != CURLM_OK)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("%s failed at %s:%d: `%s'\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"),
"curl_multi_cleanup", __FILE__, __LINE__,
curl_multi_strerror (mret));
multi = NULL;
}
}
+
/**
* Task that checks if we should try to download a hostlist.
* If so, we initiate the download, otherwise we schedule
ti_check_download = GNUNET_SCHEDULER_NO_TASK;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
-
- if (stat_connection_count < MIN_CONNECTIONS)
- {
- ti_download_dispatcher_task =
- GNUNET_SCHEDULER_add_now (&task_download_dispatcher, NULL);
- }
-
if (stats == NULL)
{
curl_global_cleanup ();
return; /* in shutdown */
}
+ if ( (stat_connection_count < MIN_CONNECTIONS) &&
+ (GNUNET_SCHEDULER_NO_TASK == ti_download_dispatcher_task) )
+ ti_download_dispatcher_task =
+ GNUNET_SCHEDULER_add_now (&task_download_dispatcher, NULL);
+
delay = hostlist_delay;
if (hostlist_delay.rel_value == 0)
hostlist_delay = GNUNET_TIME_UNIT_SECONDS;
once = 1;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _
- ("Have %u/%u connections. Will consider downloading hostlist in %llums\n"),
+ _("Have %u/%u connections. Will consider downloading hostlist in %s\n"),
stat_connection_count, MIN_CONNECTIONS,
- (unsigned long long) delay.rel_value);
+ GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
ti_check_download = GNUNET_SCHEDULER_add_delayed (delay, &task_check, NULL);
}
ti_saving_task = GNUNET_SCHEDULER_NO_TASK;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Scheduled saving of hostlists\n"));
save_hostlist_file (GNUNET_NO);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Hostlists will be saved to file again in %llums\n"),
- (unsigned long long) SAVING_INTERVALL.rel_value);
- ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL,
- &task_hostlist_saving, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Hostlists will be saved to file again in %s\n",
+ GNUNET_STRINGS_relative_time_to_string(SAVING_INTERVALL, GNUNET_YES));
+ ti_saving_task =
+ GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving,
+ NULL);
}
* @param cls closure
* @param peer peer identity this notification is about
* @param atsi performance data
+ * @param atsi_count number of records in 'atsi'
*/
static void
-handler_connect (void *cls,
- const struct
- GNUNET_PeerIdentity *peer,
- const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+handler_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
GNUNET_assert (stat_connection_count < UINT_MAX);
stat_connection_count++;
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# active connections"),
- 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (stats, gettext_noop ("# active connections"), 1,
+ GNUNET_NO);
}
{
GNUNET_assert (stat_connection_count > 0);
stat_connection_count--;
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# active connections"),
- -1, GNUNET_NO);
+ GNUNET_STATISTICS_update (stats, gettext_noop ("# active connections"), -1,
+ GNUNET_NO);
}
* @param peer the peer sending the message
* @param message the actual message
* @param atsi performance data
+ * @param atsi_count number of records in 'atsi'
* @return GNUNET_OK to keep the connection open,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
-handler_advertisement (void *cls,
- const struct GNUNET_PeerIdentity *peer,
+handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
size_t size;
size_t uri_size;
hostlist->hostlist_uri = (const char *) &hostlist[1];
memcpy (&hostlist[1], uri, uri_size);
hostlist->time_creation = GNUNET_TIME_absolute_get ();
- hostlist->time_last_usage = GNUNET_TIME_absolute_get_zero ();
hostlist->quality = HOSTLIST_INITIAL;
hostlist_to_test = hostlist;
stat_testing_hostlist = GNUNET_YES;
stat_testing_allowed = GNUNET_NO;
- ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (TESTING_INTERVAL,
- &task_testing_intervall_reset,
- NULL);
+ ti_testing_intervall_task =
+ GNUNET_SCHEDULER_add_delayed (TESTING_INTERVAL,
+ &task_testing_intervall_reset, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Testing new hostlist advertisements is locked for the next %u ms\n",
}
-
/**
- * Continuation called by the statistics code once
+ * Continuation called by the statistics code once
* we go the stat. Initiates hostlist download scheduling.
*
* @param cls closure
static void
primary_task (void *cls, int success)
{
- if (stats == NULL)
- return; /* in shutdown */
-#if DEBUG_HOSTLIST_CLIENT
+ sget = NULL;
+ GNUNET_assert (stats != NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Statistics request done, scheduling hostlist download\n");
-#endif
ti_check_download = GNUNET_SCHEDULER_add_now (&task_check, NULL);
}
static int
-process_stat (void *cls,
- const char *subsystem,
- const char *name, uint64_t value, int is_persistent)
+process_stat (void *cls, const char *subsystem, const char *name,
+ uint64_t value, int is_persistent)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Initial time between hostlist downloads is %llums\n"),
- (unsigned long long) value);
hostlist_delay.rel_value = value;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Initial time between hostlist downloads is %s\n",
+ GNUNET_STRINGS_relative_time_to_string (hostlist_delay, GNUNET_YES));
return GNUNET_OK;
}
+
/**
* Method to load persistent hostlist file during hostlist client startup
*/
uint32_t counter;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg,
- "HOSTLIST",
- "HOSTLISTFILE", &filename))
+ GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE",
+ &filename))
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _
- ("No `%s' specified in `%s' configuration, cannot load hostlists from file.\n"),
- "HOSTLISTFILE", "HOSTLIST");
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+ "hostlist", "HOSTLISTFILE");
return;
}
if (GNUNET_NO == GNUNET_DISK_file_test (filename))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Hostlist file `%s' is not existing\n"), filename);
+ _("Hostlist file `%s' does not exist\n"), filename);
GNUNET_free (filename);
return;
}
counter = 0;
while ((GNUNET_OK == GNUNET_BIO_read_string (rh, "url", &uri, MAX_URL_LEN)) &&
- (NULL != uri) &&
- (GNUNET_OK == GNUNET_BIO_read_int32 (rh, ×_used)) &&
- (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &quality)) &&
+ (NULL != uri) && (GNUNET_OK == GNUNET_BIO_read_int32 (rh, ×_used))
+ && (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &quality)) &&
(GNUNET_OK == GNUNET_BIO_read_int64 (rh, &last_used)) &&
(GNUNET_OK == GNUNET_BIO_read_int64 (rh, &created)) &&
(GNUNET_OK == GNUNET_BIO_read_int32 (rh, &hellos_returned)))
break;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("%u hostlist URIs loaded from file\n"), counter);
- GNUNET_STATISTICS_set (stats,
- gettext_noop ("# hostlist URIs read from file"),
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("%u hostlist URIs loaded from file\n"),
+ counter);
+ GNUNET_STATISTICS_set (stats, gettext_noop ("# hostlist URIs read from file"),
counter, GNUNET_YES);
- GNUNET_STATISTICS_set (stats,
- gettext_noop ("# advertised hostlist URIs"),
+ GNUNET_STATISTICS_set (stats, gettext_noop ("# advertised hostlist URIs"),
linked_list_size, GNUNET_NO);
GNUNET_free_non_null (uri);
emsg = NULL;
- GNUNET_BIO_read_close (rh, &emsg);
+ (void) GNUNET_BIO_read_close (rh, &emsg);
if (emsg != NULL)
GNUNET_free (emsg);
GNUNET_free (filename);
uint32_t counter;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (cfg,
- "HOSTLIST",
- "HOSTLISTFILE", &filename))
+ GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE",
+ &filename))
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _
- ("No `%s' specified in `%s' configuration, cannot save hostlists to file.\n"),
- "HOSTLISTFILE", "HOSTLIST");
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+ "hostlist", "HOSTLISTFILE");
return;
}
if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename))
GNUNET_free (filename);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Writing %u hostlist URIs to `%s'\n"),
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Writing %u hostlist URIs to `%s'\n"),
linked_list_size, filename);
/* add code to write hostlists to file using bio */
ok = GNUNET_YES;
}
if (GNUNET_YES == ok)
{
- if ((GNUNET_OK !=
- GNUNET_BIO_write_string (wh, pos->hostlist_uri)) ||
- (GNUNET_OK !=
- GNUNET_BIO_write_int32 (wh, pos->times_used)) ||
- (GNUNET_OK !=
- GNUNET_BIO_write_int64 (wh, pos->quality)) ||
+ if ((GNUNET_OK != GNUNET_BIO_write_string (wh, pos->hostlist_uri)) ||
+ (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pos->times_used)) ||
+ (GNUNET_OK != GNUNET_BIO_write_int64 (wh, pos->quality)) ||
(GNUNET_OK !=
GNUNET_BIO_write_int64 (wh, pos->time_last_usage.abs_value)) ||
(GNUNET_OK !=
GNUNET_free (filename);
}
+
/**
* Start downloading hostlists from hostlist servers as necessary.
*/
char *filename;
int result;
+ GNUNET_assert (NULL != st);
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
{
GNUNET_break (0);
cfg = c;
stats = st;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
- "HOSTLIST", "HTTP-PROXY", &proxy))
+ GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "HTTP-PROXY",
+ &proxy))
proxy = NULL;
stat_learning = learn;
*ch = &handler_connect;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Learning is enabled on this peer\n"));
load_hostlist_file ();
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Hostlists will be saved to file again in %llums\n"),
- (unsigned long long) SAVING_INTERVALL.rel_value);
- ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL,
- &task_hostlist_saving, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Hostlists will be saved to file again in %s\n",
+ GNUNET_STRINGS_relative_time_to_string (SAVING_INTERVALL, GNUNET_YES));
+ ti_saving_task =
+ GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving,
+ NULL);
}
else
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Learning is not enabled on this peer\n"));
*msgh = NULL;
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg,
- "HOSTLIST",
- "HOSTLISTFILE",
- &filename))
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST",
+ "HOSTLISTFILE", &filename))
{
if (GNUNET_YES == GNUNET_DISK_file_test (filename))
{
}
GNUNET_free (filename);
}
- GNUNET_STATISTICS_get (stats,
- "hostlist",
- gettext_noop
- ("# milliseconds between hostlist downloads"),
- GNUNET_TIME_UNIT_MINUTES, &primary_task, &process_stat,
- NULL);
+ sget = GNUNET_STATISTICS_get (stats, "hostlist",
+ gettext_noop
+ ("# milliseconds between hostlist downloads"),
+ GNUNET_TIME_UNIT_MINUTES, &primary_task, &process_stat,
+ NULL);
return GNUNET_OK;
}
GNUNET_HOSTLIST_client_stop ()
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostlist client shutdown\n");
-#if DEBUG_HOSTLIST_CLIENT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostlist client shutdown\n");
-#endif
+ if (NULL != sget)
+ {
+ GNUNET_STATISTICS_get_cancel (sget);
+ sget = NULL;
+ }
+ stats = NULL;
if (GNUNET_YES == stat_learning)
save_hostlist_file (GNUNET_YES);
-
if (ti_saving_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (ti_saving_task);
+ ti_saving_task = GNUNET_SCHEDULER_NO_TASK;
}
if (ti_download_dispatcher_task != GNUNET_SCHEDULER_NO_TASK)
- {
+ {
GNUNET_SCHEDULER_cancel (ti_download_dispatcher_task);
+ ti_download_dispatcher_task = GNUNET_SCHEDULER_NO_TASK;
}
if (ti_testing_intervall_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (ti_testing_intervall_task);
+ ti_testing_intervall_task = GNUNET_SCHEDULER_NO_TASK;
}
if (ti_download != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (ti_download);
+ ti_download = GNUNET_SCHEDULER_NO_TASK;
}
if (ti_check_download != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (ti_check_download);
+ ti_check_download = GNUNET_SCHEDULER_NO_TASK;
curl_global_cleanup ();
}
if (transport != NULL)
GNUNET_TRANSPORT_disconnect (transport);
transport = NULL;
}
- GNUNET_assert (NULL == transport);
GNUNET_free_non_null (proxy);
proxy = NULL;
cfg = NULL;