diff options
-rw-r--r-- | src/common/libalgo/hashtbl.c | 2 | ||||
-rw-r--r-- | src/kernel/user/ipc.c | 8 | ||||
-rw-r--r-- | src/kernel/user/process.c | 2 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/common/libalgo/hashtbl.c b/src/common/libalgo/hashtbl.c index 6fb5b60..0284d75 100644 --- a/src/common/libalgo/hashtbl.c +++ b/src/common/libalgo/hashtbl.c @@ -67,7 +67,7 @@ void hashtbl_check_size(hashtbl_t *ht) { if (4 * ht->nitems < ht->size) nsize = ht->size / 2; if (4 * ht->nitems > 3 * ht->size) nsize = ht->size * 2; - if (nsize != 0) { + if (nsize != 0 && nsize >= DEFAULT_HT_INIT_SIZE) { hashtbl_item_t **nitems = (hashtbl_item_t**)malloc(nsize * sizeof(hashtbl_item_t*)); if (nitems == 0) return; // if we can't realloc, too bad, we just lose space/efficienty diff --git a/src/kernel/user/ipc.c b/src/kernel/user/ipc.c index 308a9c1..2a43da1 100644 --- a/src/kernel/user/ipc.c +++ b/src/kernel/user/ipc.c @@ -324,8 +324,8 @@ STATIC_MUTEX(token_table_mutex); typedef struct { token_t tok; - fs_handle_t *h; uint64_t time; + fs_handle_t *h; } token_table_entry_t; static token_table_entry_t *expired_token = 0; @@ -344,7 +344,7 @@ void token_expiration_check(void* x) { } hashtbl_iter(token_table, find_expired_token); - if (expired_token) { + if (expired_token != 0) { hashtbl_remove(token_table, &expired_token->tok); unref_file(expired_token->h); free(expired_token); @@ -370,7 +370,7 @@ bool gen_token_for(fs_handle_t *h, token_t *tok) { while (!worker_push_in(1000000, token_expiration_check, 0)) yield(); } - e = (token_table_entry_t*)malloc(sizeof(token_t)); + e = (token_table_entry_t*)malloc(sizeof(token_table_entry_t)); if (!e) goto end; prng_bytes((uint8_t*)e->tok.bytes, TOKEN_LENGTH); @@ -418,6 +418,8 @@ hash_t token_hash_fun(const void* v) { } bool token_eq_fun(const void* a, const void* b) { + if (a == b) return true; + token_t *ta = (token_t*)a, *tb = (token_t*)b; for (int i = 0; i < TOKEN_LENGTH; i++) { if (ta->bytes[i] != tb->bytes[i]) return false; diff --git a/src/kernel/user/process.c b/src/kernel/user/process.c index f56998e..320638d 100644 --- a/src/kernel/user/process.c +++ b/src/kernel/user/process.c @@ -449,6 +449,8 @@ bool proc_add_fs(process_t *p, fs_t *fs, const char* name) { if (hashtbl_find(p->filesystems, n) != 0) goto end; add_ok = hashtbl_add(p->filesystems, n, fs); + + dbg_printf("Bind %s: 0x%p\n", name, fs); end: mutex_unlock(&p->lock); |