*/
static struct Hostlist * current_hostlist;
-/*
+/**
* Size of the linke list used to store hostlists
*/
static unsigned int linked_list_size;
*/
static void update_hostlist ( )
{
+ char *stat;
if ( (use_preconfigured_list == GNUNET_NO) && ( NULL != current_hostlist ) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
{
current_hostlist->times_used++;
current_hostlist->quality = checked_add ( current_hostlist->quality, HOSTLIST_SUCCESSFUL_DOWNLOAD);
+ GNUNET_asprintf (&stat,
+ gettext_noop("# advertised URI `%s' downloaded"),
+ current_hostlist->hostlist_uri);
+
+ GNUNET_STATISTICS_update ( stats,
+ stat,
+ 1,
+ GNUNET_YES);
+ GNUNET_free (stat);
}
else
current_hostlist->quality = checked_sub ( current_hostlist->quality, HOSTLIST_FAILED_DOWNLOAD );
GNUNET_CONTAINER_DLL_insert(linked_list_head, linked_list_tail, hostlist);
linked_list_size++;
+ GNUNET_STATISTICS_set (stats,
+ gettext_noop("# advertised hostlist URIs"),
+ linked_list_size,
+ GNUNET_NO);
+
if (MAX_NUMBER_HOSTLISTS >= linked_list_size)
return GNUNET_OK;
(unsigned long long) lowest_quality->quality);
GNUNET_CONTAINER_DLL_remove (linked_list_head, linked_list_tail, lowest_quality);
linked_list_size--;
+
+ GNUNET_STATISTICS_set (stats,
+ gettext_noop("# advertised hostlist URIs"),
+ linked_list_size,
+ GNUNET_NO);
+
GNUNET_free (lowest_quality);
return GNUNET_OK;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Loading saved hostlist entries from file `%s' \n"), filename);
+ if ( GNUNET_NO == GNUNET_DISK_file_test (filename) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Hostlist file `%s' is not existing\n"), filename);
+ GNUNET_free ( filename );
+ return;
+ }
struct GNUNET_BIO_ReadHandle * rh = GNUNET_BIO_read_open (filename);
if (NULL == rh)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("%u hostlist URIs loaded from file\n"), counter);
GNUNET_STATISTICS_set (stats,
- gettext_noop("# hostlis URIs read from file"),
+ gettext_noop("# hostlist URIs read from file"),
counter,
GNUNET_YES);
+ GNUNET_STATISTICS_set (stats,
+ gettext_noop("# advertised hostlist URIs"),
+ linked_list_size,
+ GNUNET_NO);
GNUNET_free_non_null (uri);
emsg = NULL;
/**
- * Method to load persistent hostlist file during hostlist client shutdown
+ * Method to save persistent hostlist 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 )
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("No `%s' specified in `%s' configuration, cannot save hostlists to file.\n"),
"HOSTLISTFILE", "HOSTLIST");
- GNUNET_free (filename);
return;
}
wh = GNUNET_BIO_write_open (filename);
_("Could not open file `%s' for writing to save hostlists: %s\n"),
filename,
STRERROR (errno));
- GNUNET_free (filename);
+ GNUNET_free (filename);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"HTTP-PROXY",
&proxy))
proxy = NULL;
+ learning = learn;
*ch = &connect_handler;
*dh = &disconnect_handler;
- if (learn)
- *msgh = &advertisement_handler;
- else
- *msgh = NULL;
linked_list_head = NULL;
linked_list_tail = NULL;
use_preconfigured_list = GNUNET_YES;
- learning = learn;
+
if ( GNUNET_YES == learning )
{
+ *msgh = &advertisement_handler;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Learning is enabled on this peer\n"));
load_hostlist_file ();
{
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,
"HOSTLIST",
"HOSTLISTFILE",
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Hostlist client shutdown\n");
#endif
- save_hostlist_file ( GNUNET_YES );
+ if ( GNUNET_YES == learning )
+ save_hostlist_file ( GNUNET_YES );
if (current_task != GNUNET_SCHEDULER_NO_TASK)
{