*/
static const struct GNUNET_CONFIGURATION_Handle *cfg;
-/**
- * Our scheduler.
- */
-static struct GNUNET_SCHEDULER_Handle *sched;
-
/**
* Statistics handle.
*/
"Scheduling task for hostlist download using cURL\n");
#endif
ti_download
- = GNUNET_SCHEDULER_add_select (sched,
- GNUNET_SCHEDULER_PRIORITY_DEFAULT,
+ = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
GNUNET_SCHEDULER_NO_TASK,
rtime,
grs,
clean_up ();
return;
}
- if (GNUNET_TIME_absolute_get_remaining (end_time).value == 0)
+ if (GNUNET_TIME_absolute_get_remaining (end_time).rel_value == 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Timeout trying to download hostlist from `%s'\n"),
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Download in progess, have to wait...\n");
- ti_download_dispatcher_task = GNUNET_SCHEDULER_add_delayed (sched,
- WAITING_INTERVALL,
+ ti_download_dispatcher_task = GNUNET_SCHEDULER_add_delayed (WAITING_INTERVALL,
&task_download_dispatcher,
NULL);
}
if (stat_connection_count < MIN_CONNECTIONS)
{
- ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now ( sched,
- &task_download_dispatcher,
+ ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (&task_download_dispatcher,
NULL);
}
return; /* in shutdown */
}
delay = hostlist_delay;
- if (hostlist_delay.value == 0)
+ if (hostlist_delay.rel_value == 0)
hostlist_delay = GNUNET_TIME_UNIT_SECONDS;
else
hostlist_delay = GNUNET_TIME_relative_multiply (hostlist_delay, 2);
- if (hostlist_delay.value > GNUNET_TIME_UNIT_HOURS.value * (1 + stat_connection_count))
+ if (hostlist_delay.rel_value > GNUNET_TIME_UNIT_HOURS.rel_value * (1 + stat_connection_count))
hostlist_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS,
(1 + stat_connection_count));
GNUNET_STATISTICS_set (stats,
- gettext_noop("# seconds between hostlist downloads"),
- hostlist_delay.value,
+ gettext_noop("# milliseconds between hostlist downloads"),
+ hostlist_delay.rel_value,
GNUNET_YES);
if (0 == once)
{
_("Have %u/%u connections. Will consider downloading hostlist in %llums\n"),
stat_connection_count,
MIN_CONNECTIONS,
- (unsigned long long) delay.value);
- ti_check_download = GNUNET_SCHEDULER_add_delayed (sched,
- delay,
+ (unsigned long long) delay.rel_value);
+ ti_check_download = GNUNET_SCHEDULER_add_delayed (delay,
&task_check,
NULL);
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Hostlists will be saved to file again in %llums\n"),
- (unsigned long long) SAVING_INTERVALL.value);
- ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched,
- SAVING_INTERVALL,
+ (unsigned long long) SAVING_INTERVALL.rel_value);
+ 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 latency reported latency of the connection with 'other'
- * @param distance reported distance (DV) to 'other'
+ * @param atsi performance data
*/
static void
handler_connect (void *cls,
const struct
GNUNET_PeerIdentity * peer,
- struct GNUNET_TIME_Relative latency,
- uint32_t distance)
+ const struct GNUNET_TRANSPORT_ATS_Information *atsi)
{
- unsigned int max = 0 ;
- max --;
-
- if (stat_connection_count < max)
- {
+ GNUNET_assert (stat_connection_count < UINT_MAX);
stat_connection_count++;
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);
+ gettext_noop ("# active connections"),
+ -1,
+ GNUNET_NO);
}
/**
* @param cls closure (always NULL)
* @param peer the peer sending the message
* @param message the actual message
- * @param latency latency
- * @param distance distance
+ * @param atsi performance data
* @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,
- struct GNUNET_TIME_Relative latency,
- uint32_t distance)
+ const struct GNUNET_PeerIdentity * peer,
+ const struct GNUNET_MessageHeader * message,
+ const struct GNUNET_TRANSPORT_ATS_Information *atsi)
{
size_t size;
size_t uri_size;
stat_testing_hostlist = GNUNET_YES;
stat_testing_allowed = GNUNET_NO;
- ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (sched,
- TESTING_INTERVAL,
+ 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",
- TESTING_INTERVAL.value);
+ TESTING_INTERVAL.rel_value);
- ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (sched,
- &task_download_dispatcher,
+ ti_download_dispatcher_task = GNUNET_SCHEDULER_add_now (&task_download_dispatcher,
NULL);
return GNUNET_OK;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Statistics request done, scheduling hostlist download\n");
#endif
- ti_check_download = GNUNET_SCHEDULER_add_now (sched,
- &task_check,
+ ti_check_download = GNUNET_SCHEDULER_add_now (&task_check,
NULL);
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Initial time between hostlist downloads is %llums\n"),
(unsigned long long) value);
- hostlist_delay.value = value;
+ hostlist_delay.rel_value = value;
return GNUNET_OK;
}
uint32_t counter;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (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"),
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)) &&
(GNUNET_OK == GNUNET_BIO_read_int64 (rh, &last_used)) &&
hostlist->hostlist_uri = (const char *) &hostlist[1];
memcpy (&hostlist[1], uri, strlen(uri)+1);
hostlist->quality = quality;
- hostlist->time_creation.value = created;
- hostlist->time_last_usage.value = last_used;
+ hostlist->time_creation.abs_value = created;
+ hostlist->time_last_usage.abs_value = last_used;
GNUNET_CONTAINER_DLL_insert(linked_list_head, linked_list_tail, hostlist);
linked_list_size++;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
uint32_t counter;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg,
+ GNUNET_CONFIGURATION_get_value_filename (cfg,
"HOSTLIST",
"HOSTLISTFILE",
&filename))
"HOSTLISTFILE", "HOSTLIST");
return;
}
+ if (GNUNET_SYSERR != GNUNET_DISK_directory_create_for_file (filename))
+ {
wh = GNUNET_BIO_write_open (filename);
if ( NULL == wh)
{
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;
counter = 0;
(GNUNET_OK !=
GNUNET_BIO_write_int64 (wh, pos->quality)) ||
(GNUNET_OK !=
- GNUNET_BIO_write_int64 (wh, pos->time_last_usage.value)) ||
+ GNUNET_BIO_write_int64 (wh, pos->time_last_usage.abs_value)) ||
(GNUNET_OK !=
- GNUNET_BIO_write_int64 (wh, pos->time_creation.value)) ||
+ GNUNET_BIO_write_int64 (wh, pos->time_creation.abs_value)) ||
(GNUNET_OK !=
GNUNET_BIO_write_int32 (wh, pos->hello_count)))
{
*/
int
GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
- struct GNUNET_SCHEDULER_Handle *s,
struct GNUNET_STATISTICS_Handle *st,
GNUNET_CORE_ConnectEventHandler *ch,
GNUNET_CORE_DisconnectEventHandler *dh,
GNUNET_break (0);
return GNUNET_SYSERR;
}
- transport = GNUNET_TRANSPORT_connect (s, c, NULL, NULL, NULL, NULL, NULL);
+ transport = GNUNET_TRANSPORT_connect (c, NULL, NULL, NULL, NULL, NULL);
if (NULL == transport)
{
curl_global_cleanup ();
return GNUNET_SYSERR;
}
cfg = c;
- sched = s;
stats = st;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
load_hostlist_file ();
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Hostlists will be saved to file again in %llums\n"),
- (unsigned long long) SAVING_INTERVALL.value);
- ti_saving_task = GNUNET_SCHEDULER_add_delayed (sched,
- SAVING_INTERVALL,
+ (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_INFO,
_("Learning is not enabled on this peer\n"));
*msgh = NULL;
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg,
"HOSTLIST",
"HOSTLISTFILE",
&filename))
}
GNUNET_STATISTICS_get (stats,
"hostlist",
- gettext_noop("# seconds between hostlist downloads"),
+ gettext_noop("# milliseconds between hostlist downloads"),
GNUNET_TIME_UNIT_MINUTES,
&primary_task,
&process_stat,
if (ti_saving_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (sched,
- ti_saving_task);
+ GNUNET_SCHEDULER_cancel (ti_saving_task);
}
if (ti_download_dispatcher_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (sched,
- ti_download_dispatcher_task);
+ GNUNET_SCHEDULER_cancel (ti_download_dispatcher_task);
}
if (ti_testing_intervall_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (sched,
- ti_testing_intervall_task);
+ GNUNET_SCHEDULER_cancel (ti_testing_intervall_task);
}
if (ti_download != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (sched,
- ti_download);
+ GNUNET_SCHEDULER_cancel (ti_download);
}
if (ti_check_download != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (sched,
- ti_check_download);
+ GNUNET_SCHEDULER_cancel (ti_check_download);
curl_global_cleanup ();
}
if (transport != NULL)
GNUNET_free_non_null (proxy);
proxy = NULL;
cfg = NULL;
- sched = NULL;
}
/* end of hostlist-client.c */