From 835b12ef619bd89ba698626c886bb90536081b90 Mon Sep 17 00:00:00 2001 From: Valery Yatsko Date: Wed, 2 Apr 2008 14:20:27 +0400 Subject: [PATCH] Some hash stuff --- include/hash.h | 4 ++++ src/hash.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/hash.h b/include/hash.h index 976602215..01f0d74c5 100644 --- a/include/hash.h +++ b/include/hash.h @@ -98,6 +98,10 @@ extern void del_from_resv_hash(const char *name, struct ConfItem *aconf); extern struct ConfItem *hash_find_resv(const char *name); extern void clear_resv_hash(void); +void add_to_cli_fd_hash(struct Client *client_p); +void del_from_cli_fd_hash(struct Client *client_p); +struct Client *find_cli_fd_hash(int fd); + extern void hash_stats(struct Client *); #endif /* INCLUDED_hash_h */ diff --git a/src/hash.c b/src/hash.c index 41829bbe6..980153027 100644 --- a/src/hash.c +++ b/src/hash.c @@ -660,6 +660,37 @@ clear_resv_hash(void) HASH_WALK_END } +void +add_to_cli_fd_hash(struct Client *client_p) +{ + rb_dlinkAddAlloc(client_p, &clientbyfdTable[hash_cli_fd(rb_get_fd(client_p->localClient->F))]); +} + + +void +del_from_cli_fd_hash(struct Client *client_p) +{ + unsigned int hashv; + hashv = hash_cli_fd(rb_get_fd(client_p->localClient->F)); + rb_dlinkFindDestroy(client_p, &clientbyfdTable[hashv]); +} + +struct Client * +find_cli_fd_hash(int fd) +{ + struct Client *target_p; + rb_dlink_node *ptr; + unsigned int hashv; + hashv = hash_cli_fd(fd); + RB_DLINK_FOREACH(ptr, clientbyfdTable[hashv].head) + { + target_p = ptr->data; + if(rb_get_fd(target_p->localClient->F) == fd) + return target_p; + } + return NULL; +} + static void output_hash(struct Client *source_p, const char *name, int length, int *counts, int deepest) {