Some hash stuff

This commit is contained in:
Valery Yatsko 2008-04-02 14:20:27 +04:00
parent 58e8319c1c
commit 01ebafc985
2 changed files with 35 additions and 0 deletions

View File

@ -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 struct ConfItem *hash_find_resv(const char *name);
extern void clear_resv_hash(void); 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 *); extern void hash_stats(struct Client *);
#endif /* INCLUDED_hash_h */ #endif /* INCLUDED_hash_h */

View File

@ -660,6 +660,37 @@ clear_resv_hash(void)
HASH_WALK_END 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 static void
output_hash(struct Client *source_p, const char *name, int length, int *counts, int deepest) output_hash(struct Client *source_p, const char *name, int length, int *counts, int deepest)
{ {