|
Data Structures |
struct | sha1_cache_entry |
| There's an in-core cache (the GHashTable sha1_cache), and a persistent copy (normally in ~/.gtk-gnutella/sha1_cache). More...
|
struct | file_sha1 |
| This is a file waiting either for the digest to be computer, or when computed to be retrofit into the share record. More...
|
struct | sha1_computation_context |
Defines |
#define | HASH_BLOCK_SHIFT 12 /**< Power of two of hash unit credit */ |
| Power of two of hash unit credit.
|
#define | HASH_BUF_SIZE 65536 /**< Size of a the reading buffer */ |
| Size of a the reading buffer.
|
#define | SHA1_MAGIC 0xa1a1a1a1U |
Functions |
| RCSID ("$Id:huge.c, v 1.24 2005/09/10 08:17:28 daichik Exp $") |
void | copy_sha1 (char *dest, const char *source) |
| copy_sha1
|
void | update_volatile_cache (struct sha1_cache_entry *sha1_cached_entry, filesize_t size, time_t mtime, const char *digest) |
| update_volatile_cache
|
void | add_volatile_cache_entry (const char *filename, filesize_t size, time_t mtime, const char *digest, gboolean known_to_be_shared) |
| add_volatile_cache_entry
|
void | cache_entry_print (FILE *f, const char *filename, const gchar *digest, filesize_t size, time_t mtime) |
void | add_persistent_cache_entry (const char *filename, filesize_t size, time_t mtime, const char *digest) |
| Add an entry to the persistent cache.
|
void | dump_cache_one_entry (gpointer unused_key, gpointer value, gpointer udata) |
| Dump one (in-memory) cache into the persistent cache.
|
void | dump_cache (void) |
| Dump the whole in-memory cache onto disk.
|
void | parse_and_append_cache_entry (char *line) |
| This function is used to read the disk cache into memory.
|
void | sha1_read_cache (void) |
| Read the whole persistent cache into memory.
|
void | push (struct file_sha1 **stack, struct file_sha1 *record) |
| Push a record onto a stack (either waiting_for_sha1_computation or waiting_for_library_build_complete).
|
void | free_cell (struct file_sha1 *cell) |
| Free a working cell.
|
void | sha1_computation_context_free (gpointer u) |
void | put_sha1_back_into_share_library (struct shared_file *sf, const char *file_name, const char *digest) |
| When SHA1 is computed, and we know what struct share it's related to, we call this function to update set the share SHA1 value.
|
void | try_to_put_sha1_back_into_share_library (void) |
| We have some SHA1 we couldn't put the values into the share library because it wasn't available.
|
void | close_current_file (struct sha1_computation_context *ctx) |
| Close the file whose hash we're computing (after calculation completed) and free the associated structure.
|
file_sha1 * | get_next_file_from_list (void) |
| Get the next file waiting for its hash to be computed from the queue (actually a stack).
|
gboolean | open_next_file (struct sha1_computation_context *ctx) |
| Open the next file waiting for its hash to be computed.
|
void | got_sha1_result (struct sha1_computation_context *ctx, char *digest) |
| Callback to be called when a computation has completed.
|
void | sha1_timer_one_step (struct sha1_computation_context *ctx, gint ticks, gint *used) |
| The timer calls repeatedly this function, consuming one unit of credit every call.
|
bgret_t | sha1_step_compute (gpointer h, gpointer u, gint ticks) |
| The routine doing all the work.
|
bgret_t | sha1_step_dump (gpointer unused_h, gpointer unused_u, gint unused_ticks) |
| Dump SHA1 cache if it is dirty.
|
void | queue_shared_file_for_sha1_computation (guint32 file_index, const char *file_name) |
| Put the file with a given file_index and file_name on the stack of the things to do.
|
gboolean | cached_entry_up_to_date (const struct sha1_cache_entry *cache_entry, const struct shared_file *sf) |
| Check to see if an (in-memory) entry cache is up to date.
|
gboolean | sha1_is_cached (const struct shared_file *sf) |
| External interface to check whether the sha1 for shared_file is known.
|
void | request_sha1 (struct shared_file *sf) |
| External interface to call for getting the hash for a shared_file.
|
void | huge_init (void) |
| Call this function at the beginning.
|
gboolean | cache_free_entry (gpointer unused_key, gpointer v, gpointer unused_udata) |
| Free SHA1 cache entry.
|
void | huge_close (void) |
| Call this when servent is shutdown.
|
gboolean | huge_improbable_sha1 (const gchar *buf, size_t len) |
| Test whether the SHA1 in its base32/binary form is improbable.
|
gboolean | huge_sha1_extract32 (const gchar *buf, size_t len, gchar *retval, gpointer header, gboolean check_old) |
| huge_sha1_extract32
|
void | huge_collect_locations (gchar *sha1, header_t *header) |
| Parse the "X-Gnutella-Alternate-Location" header if present to learn about other sources for this file.
|
Variables |
GHashTable * | sha1_cache = NULL |
gboolean | cache_dirty = FALSE |
| cache_dirty means that in-core cache is different from the one on disk when TRUE.
|
const char | sha1_persistent_cache_file_header [] |
| Disk cache.
|
char * | persistent_cache_file_name = NULL |
gpointer | sha1_task = NULL |
file_sha1 * | waiting_for_sha1_computation = NULL |
| When a hash is requested for a file and is unknown, it is first stored onto this stack, waiting to be processed.
|
file_sha1 * | waiting_for_library_build_complete = NULL |
| When the hash for a file has been computed but cannot be set into the struct shared_file because the function shared_file returned SHARE_REBUILDING (for example), the corresponding struct file_hash is stored into this stack, until such time it's possible to get struct shared_file from index with shared_file.
|