Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

hcache.h File Reference


Detailed Description

Host cache management.

Author:
Raphael Manfredi

Richard Eckart

Date:
2002-2003

#include "common.h"
#include "if/core/hcache.h"
#include "if/core/hosts.h"

Go to the source code of this file.

Functions

void hcache_init (void)
 Initialize host caches.

void hcache_shutdown (void)
 Shutdown host caches.

void hcache_close (void)
 Destroy all host caches.

void hcache_retrieve_all (void)
 Load hostcache data from disk.

void hcache_timer (time_t now)
 Host cache timer.

const gchar * host_type_to_string (host_type_t type)
 Convert host type to string.

const gchar * hcache_type_to_string (hcache_type_t type)
 Convert host cache type to string.

gboolean hcache_add (hcache_type_t type, const host_addr_t addr, guint16 port, const gchar *what)
 Register a host.

gboolean hcache_add_caught (host_type_t type, const host_addr_t addr, guint16 port, const gchar *what)
 Add a caught (fresh) host to the right list depending on the host type.

gboolean hcache_add_valid (host_type_t type, const host_addr_t addr, guint16 port, const gchar *what)
 Add a valid host to the right list depending on the host type.

gboolean hcache_node_is_bad (const host_addr_t addr)
void hcache_prune (hcache_type_t type)
 Remove hosts that exceed our maximum.

gboolean hcache_read_finished (void)
 Check whether the host caches are completely read.

gint hcache_size (host_type_t type)
gboolean hcache_is_low (host_type_t type)
 Do we have less that our mimumum amount of hosts in the cache?

gint hcache_fill_caught_array (host_type_t type, gnet_host_t *hosts, gint hcount)
 Fill `hosts', an array of `hcount' hosts already allocated with at most `hcount' hosts from out caught list, without removing those hosts from the list.

void hcache_get_caught (host_type_t type, host_addr_t *addr, guint16 *port)
 Get host IP/port information from our caught host list, or from the recent pong cache, in alternance.

gboolean hcache_find_nearby (host_type_t type, host_addr_t *addr, guint16 *port)
 Finds a host in either the pong_cache or the host_cache that is in one of the local networks.

void hcache_store_if_dirty (host_type_t type)
 Save hostcache data to disk, for the relevant host type.


Function Documentation

gboolean hcache_add hcache_type_t  type,
const host_addr_t  addr,
guint16  port,
const gchar *  what
 

Register a host.

If a host is already on the known hosts hashtable, it will not be registered. Otherwise it will be added to the hashtable of known hosts and added to one of the host lists as indicated by the "list" parameter. Sanity checks are only applied when the host is added to HL_CAUGHT, since when a host is added to any of the other lists it must have been in HL_CAUGHT or in the pong-cache before.

Returns:
TRUE when IP/port passed sanity checks, regardless of whether it was added to the cache. (See above)

gboolean hcache_add_caught host_type_t  type,
const host_addr_t  addr,
guint16  port,
const gchar *  what
 

Add a caught (fresh) host to the right list depending on the host type.

gboolean hcache_add_valid host_type_t  type,
const host_addr_t  addr,
guint16  port,
const gchar *  what
 

Add a valid host to the right list depending on the host type.

void hcache_close void   ) 
 

Destroy all host caches.

gint hcache_fill_caught_array host_type_t  type,
gnet_host_t hosts,
gint  hcount
 

Fill `hosts', an array of `hcount' hosts already allocated with at most `hcount' hosts from out caught list, without removing those hosts from the list.

Returns:
amount of hosts filled

gboolean hcache_find_nearby host_type_t  type,
host_addr_t addr,
guint16 *  port
 

Finds a host in either the pong_cache or the host_cache that is in one of the local networks.

Returns:
TRUE if host is found

void hcache_get_caught host_type_t  type,
host_addr_t addr,
guint16 *  port
 

Get host IP/port information from our caught host list, or from the recent pong cache, in alternance.

void hcache_init void   ) 
 

Initialize host caches.

gboolean hcache_is_low host_type_t  type  ) 
 

Do we have less that our mimumum amount of hosts in the cache?

gboolean hcache_node_is_bad const host_addr_t  addr  ) 
 

Returns:
TRUE if the host is in one of the "bad hosts" caches.

void hcache_prune hcache_type_t  type  ) 
 

Remove hosts that exceed our maximum.

This can be called on HCACHE_FRESH_ANY and on HCACHE_FRESH_ULTRA.

If too many hosts are in the cache, then it will prune the HCACHE_FRESH_XXX list. Only after HCACHE_FRESH_XXX is empty HCACHE_VALID_XXX will be moved to HCACHE_FRESH_XXX and then it is purged.

gboolean hcache_read_finished void   ) 
 

Check whether the host caches are completely read.

This should be used before contacting a GWebCache at start-up time.

Returns:
TRUE if the host caches have been completely loaded and FALSE if the loading is still in process.

void hcache_retrieve_all void   ) 
 

Load hostcache data from disk.

void hcache_shutdown void   ) 
 

Shutdown host caches.

gint hcache_size host_type_t  type  ) 
 

Returns:
the amount of hosts in the cache.

void hcache_store_if_dirty host_type_t  type  ) 
 

Save hostcache data to disk, for the relevant host type.

void hcache_timer time_t  now  ) 
 

Host cache timer.

const gchar* hcache_type_to_string hcache_type_t  type  ) 
 

Convert host cache type to string.

const gchar* host_type_to_string host_type_t  type  ) 
 

Convert host type to string.


Generated on Sun Feb 12 10:50:03 2006 for Gtk-Gnutella by doxygen 1.3.6