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;
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;
}
}
-#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)
/**
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
stat_use_bootstrap = GNUNET_YES;
}
+
/**
* Clean up the state from the task that downloaded the
* hostlist and schedule the next task.
clean_up ();
return;
}
- if (GNUNET_TIME_absolute_get_remaining (end_time).rel_value == 0)
+ if (0 == GNUNET_TIME_absolute_get_remaining (end_time).rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Timeout trying to download hostlist from `%s'\n"),
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", current_url, __FILE__, __LINE__,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Download of hostlist from `%s' failed: `%s'\n"),
+ current_url,
curl_easy_strerror (msg->data.result));
else
{
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);
}
}
+
/**
* Task that checks if we should try to download a hostlist.
* If so, we initiate the download, otherwise we schedule
GNUNET_SCHEDULER_add_now (&task_download_dispatcher, NULL);
delay = hostlist_delay;
- if (hostlist_delay.rel_value == 0)
+ if (0 == hostlist_delay.rel_value_us)
hostlist_delay = GNUNET_TIME_UNIT_SECONDS;
else
hostlist_delay = GNUNET_TIME_relative_multiply (hostlist_delay, 2);
- if (hostlist_delay.rel_value >
- GNUNET_TIME_UNIT_HOURS.rel_value * (1 + stat_connection_count))
+ if (hostlist_delay.rel_value_us >
+ GNUNET_TIME_UNIT_HOURS.rel_value_us * (1 + stat_connection_count))
hostlist_delay =
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS,
(1 + stat_connection_count));
GNUNET_STATISTICS_set (stats,
gettext_noop
("# milliseconds between hostlist downloads"),
- hostlist_delay.rel_value, GNUNET_YES);
+ hostlist_delay.rel_value_us / 1000LL,
+ GNUNET_YES);
if (0 == once)
{
delay = GNUNET_TIME_UNIT_ZERO;
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);
+ 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_ATS_Information *atsi,
- unsigned int atsi_count)
+handler_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
GNUNET_assert (stat_connection_count < UINT_MAX);
stat_connection_count++;
* @param cls closure (always NULL)
* @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,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ const struct GNUNET_MessageHeader *message)
{
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;
&task_testing_intervall_reset, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Testing new hostlist advertisements is locked for the next %u ms\n",
- TESTING_INTERVAL.rel_value);
+ "Testing new hostlist advertisements is locked for the next %s\n",
+ GNUNET_STRINGS_relative_time_to_string (TESTING_INTERVAL,
+ GNUNET_YES));
ti_download_dispatcher_task =
GNUNET_SCHEDULER_add_now (&task_download_dispatcher, NULL);
}
-
/**
* Continuation called by the statistics code once
* we go the stat. Initiates hostlist download scheduling.
}
+/**
+ * We've received the previous delay value from statistics. Remember it.
+ *
+ * @param cls NULL, unused
+ * @param subsystem should be "hostlist", unused
+ * @param name will be "milliseconds between hostlist downloads", unused
+ * @param value previous delay value, in milliseconds (!)
+ * @param is_persistent unused, will be GNUNET_YES
+ */
static int
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;
+ hostlist_delay.rel_value_us = value * 1000LL;
+ 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
*/
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;
}
hostlist->hostlist_uri = (const char *) &hostlist[1];
memcpy (&hostlist[1], uri, strlen (uri) + 1);
hostlist->quality = quality;
- hostlist->time_creation.abs_value = created;
- hostlist->time_last_usage.abs_value = last_used;
+ hostlist->time_creation.abs_value_us = created;
+ hostlist->time_last_usage.abs_value_us = last_used;
GNUNET_CONTAINER_DLL_insert (linked_list_head, linked_list_tail, hostlist);
linked_list_size++;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
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);
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_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_BIO_write_int64 (wh, pos->time_last_usage.abs_value_us)) ||
(GNUNET_OK !=
- GNUNET_BIO_write_int64 (wh, pos->time_creation.abs_value)) ||
+ GNUNET_BIO_write_int64 (wh, pos->time_creation.abs_value_us)) ||
(GNUNET_OK != GNUNET_BIO_write_int32 (wh, pos->hello_count)))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
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);
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);
+ 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);