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.
case CURLMSG_DONE:
if ((msg->data.result != CURLE_OK) &&
(msg->data.result != CURLE_GOT_NOTHING))
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Download of hostlist from `%s' failed: `%s'\n"),
current_url,
curl_easy_strerror (msg->data.result));
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
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);
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;
}
-
/**
* Continuation called by the statistics code once
* we go the stat. Initiates hostlist download scheduling.
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
*/
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;
}
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_free (filename);
}
+
/**
* Start downloading hostlists from hostlist servers as necessary.
*/
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);