diff --git a/include/hash.h b/include/hash.h index 9766022..01f0d74 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 41829bb..9801530 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) {