mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-10 05:43:12 +02:00
Fix whowasdb module causing WHOWAS entries to vanish (way too soon)
This commit is contained in:
@@ -25,6 +25,7 @@ in progress and may not always be a stable version.
|
||||
* TODO
|
||||
|
||||
### Fixes:
|
||||
* The whowasdb module caused `WHOWAS` entries to vanish (way too soon)
|
||||
* If your shell account only allowed very few file descriptors (eg: `ulimit -n`
|
||||
returned `150`), then UnrealIRCd would fail to boot. This, because due to
|
||||
reserved file descriptors you would have 0 left, or even a negative number.
|
||||
|
||||
@@ -445,6 +445,7 @@ extern void del_whowas_from_list(WhoWas **, WhoWas *);
|
||||
extern uint64_t hash_whowas_name(const char *name);
|
||||
extern void create_whowas_entry(Client *client, WhoWas *e, WhoWasEvent event);
|
||||
extern void free_whowas_fields(WhoWas *e);
|
||||
extern void free_whowas_entry(WhoWas *e);
|
||||
extern int add_to_client_hash_table(const char *, Client *);
|
||||
extern int del_from_client_hash_table(const char *, Client *);
|
||||
extern int add_to_id_hash_table(const char *, Client *);
|
||||
|
||||
@@ -588,9 +588,12 @@ int read_whowasdb(void)
|
||||
|
||||
if (nick && username && hostname && realname)
|
||||
{
|
||||
/* This is basically duplicating the code from create_whowas_entry() in src/whowas.c.
|
||||
* But we have no choice, as we can't use that function since we don't have a Client *.
|
||||
*/
|
||||
WhoWas *e = &WHOWAS[whowas_next];
|
||||
if (e->hashv != -1)
|
||||
free_whowas_fields(e);
|
||||
free_whowas_entry(e);
|
||||
/* Set values */
|
||||
//unreal_log(ULOG_DEBUG, "whowasdb", "WHOWASDB_READ_RECORD", NULL,
|
||||
// "[whowasdb] Adding '$nick'...",
|
||||
|
||||
+14
-4
@@ -33,6 +33,11 @@ WhoWas MODVAR *WHOWASHASH[WHOWAS_HASH_TABLE_SIZE];
|
||||
|
||||
MODVAR int whowas_next = 0;
|
||||
|
||||
/** Free all the fields previously created by create_whowas_entry().
|
||||
* NOTE: normally you want to call free_whowas_entry().
|
||||
* Calling this free_whowas_fields() function is unusual and mainly
|
||||
* for whowasdb which temporarily adds and removes entries.
|
||||
*/
|
||||
void free_whowas_fields(WhoWas *e)
|
||||
{
|
||||
safe_free(e->name);
|
||||
@@ -47,12 +52,17 @@ void free_whowas_fields(WhoWas *e)
|
||||
e->logon = 0;
|
||||
e->logoff = 0;
|
||||
e->connected_since = 0;
|
||||
e->hashv = -1;
|
||||
}
|
||||
|
||||
/* Remove from lists and reset hashv */
|
||||
/** Free whowas entry. This is the function you normally want to use. */
|
||||
void free_whowas_entry(WhoWas *e)
|
||||
{
|
||||
int hashv = e->hashv;
|
||||
free_whowas_fields(e);
|
||||
if (e->online)
|
||||
del_whowas_from_clist(&(e->online->user->whowas), e);
|
||||
del_whowas_from_list(&WHOWASHASH[e->hashv], e);
|
||||
e->hashv = -1;
|
||||
del_whowas_from_list(&WHOWASHASH[hashv], e);
|
||||
}
|
||||
|
||||
void create_whowas_entry(Client *client, WhoWas *e, WhoWasEvent event)
|
||||
@@ -90,7 +100,7 @@ void add_history(Client *client, int online, WhoWasEvent event)
|
||||
new = &WHOWAS[whowas_next];
|
||||
|
||||
if (new->hashv != -1)
|
||||
free_whowas_fields(new);
|
||||
free_whowas_entry(new);
|
||||
|
||||
create_whowas_entry(client, new, event);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user