[vhffs-dev] [928] well, glib handle correctly hash collisions by comparing the keys values in case of collision , check with a continuous flush loop |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
- To: vhffs-dev@xxxxxxxxx
- Subject: [vhffs-dev] [928] well, glib handle correctly hash collisions by comparing the keys values in case of collision , check with a continuous flush loop
- From: subversion@xxxxxxxxxxxxx
- Date: Wed, 19 Sep 2007 17:56:06 +0200
Revision: 928
Author: gradator
Date: 2007-09-19 15:56:06 +0000 (Wed, 19 Sep 2007)
Log Message:
-----------
well, glib handle correctly hash collisions by comparing the keys values in case of collision, check with a continuous flush loop
Modified Paths:
--------------
trunk/vhffs-fs/vhffsfs.c
Modified: trunk/vhffs-fs/vhffsfs.c
===================================================================
--- trunk/vhffs-fs/vhffsfs.c 2007-09-19 15:00:53 UTC (rev 927)
+++ trunk/vhffs-fs/vhffsfs.c 2007-09-19 15:56:06 UTC (rev 928)
@@ -134,11 +134,6 @@
pthread_mutex_unlock(&vhffsfs.cachelock);
}
-guint vhffsfs_cache_hash(gconstpointer p) {
- //just to test hash collisions
- return 100;
-}
-
void vhffsfs_cache_add(char *query, PGresult *result) {
vhffsfs_cache_query *vcq;
vhffsfs_cache_lock();
@@ -165,7 +160,7 @@
vhffsfs_cache_lock();
vcq = g_hash_table_lookup(vhffsfs.cachequeries, query);
// non existing or still referenced
- if(!vcq || vcq->ref > 0 || strcmp(vcq->query, query) ) {
+ if(!vcq || vcq->ref > 0) {
vhffsfs_cache_unlock();
return;
}
@@ -183,7 +178,7 @@
PGresult *vhffsfs_cache_lookup(char *query) {
vhffsfs_cache_lock();
vhffsfs_cache_query *vcq = g_hash_table_lookup(vhffsfs.cachequeries, query);
- if(vcq && !strcmp(vcq->query,query) ) {
+ if(vcq) {
// timeout
if(vhffsfs_cache_timeout(vcq->arrival, VHFFSFS_CACHE_QUERY_TIMEOUT)) {
#ifdef WITH_CACHE_DEBUG
@@ -213,7 +208,10 @@
vhffsfs_cache_lock();
vhffsfs_cache_query *vcq = g_hash_table_lookup(vhffsfs.cachequeries, query);
if(vcq && vcq->ref > 0) vcq->ref--;
- else fprintf(stderr, "CACHE: CORRUPT: '%s'\n", query);
+ else {
+ if(!vcq) fprintf(stderr, "CACHE: CORRUPT: '%s': NOT IN TABLE\n", query);
+ else fprintf(stderr, "CACHE: CORRUPT: '%s': REF IS ALREADY SET TO 0\n", query);
+ }
vhffsfs_cache_unlock();
}
@@ -226,7 +224,7 @@
GPtrArray *keys;
int i;
- sleep(VHFFSFS_CACHE_QUERY_FLUSH_EVERY);
+ //sleep(VHFFSFS_CACHE_QUERY_FLUSH_EVERY);
keys = g_ptr_array_sized_new(4096);
@@ -240,7 +238,7 @@
vhffsfs_cache_unlock();
// sleep a bit to not lock the cache too much
- sleep(1);
+ //sleep(1);
for(i = 0 ; i < keys->len ; i++) {
char *query = keys->pdata[i];
@@ -259,7 +257,7 @@
free(query);
//sleep a bit to not lock the cache too much
- usleep(100000);
+ //usleep(100000);
}
g_ptr_array_free(keys, TRUE);
@@ -1641,7 +1639,7 @@
vhffsfs.minimumrightfile = 00400;
vhffsfs.minimumrightdir = 02700;
#ifdef WITH_CACHE
- vhffsfs.cachequeries = g_hash_table_new(vhffsfs_cache_hash, g_str_equal);
+ vhffsfs.cachequeries = g_hash_table_new(g_str_hash, g_str_equal);
vhffsfs.cachekeys = g_ptr_array_sized_new(4096);
pthread_mutex_init(&vhffsfs.cachelock, NULL);
vhffsfs.cachethreadstarted = 0;