Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into fix.leak.init.ch…
Browse files Browse the repository at this point in the history
…annel
  • Loading branch information
Michael Ortmann committed May 29, 2024
2 parents e8d549c + 39a582c commit c2f7d78
Show file tree
Hide file tree
Showing 17 changed files with 200 additions and 289 deletions.
2 changes: 1 addition & 1 deletion doc/sphinx_source/using/tcl-commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ nick2hand <nickname> [channel]
Module: irc

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
account2nicks <handle> [channel]
account2nicks <account> [channel]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Returns: a de-duplicated Tcl list of the nickname(s) on the specified channel (if one is specified) whose nickname matches the given account; "" is returned if no match is found. This command will only work if a server supports (and Eggdrop has enabled) the account-notify and extended-join capabilities, and the server understands WHOX requests (also known as raw 354 responses). If no channel is specified, all channels are checked.
Expand Down
3 changes: 1 addition & 2 deletions src/chan.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ typedef struct memstruct {
time_t split; /* in case they were just netsplit */
time_t last; /* for measuring idle time */
time_t delay; /* for delayed autoop */
struct userrec *user;
int tried_getuser;
int tried_getuser; // TODO: use it to invalidate user cache
struct memstruct *next;
} memberlist;

Expand Down
45 changes: 1 addition & 44 deletions src/chanprog.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,6 @@ struct chanset_t *findchan_by_dname(const char *name)
return NULL;
}


/*
* "caching" functions
*/

/* Shortcut for get_user_by_host -- might have user record in one
* of the channel caches.
*/
struct userrec *check_chanlist(const char *host)
{
char *nick, *uhost, buf[UHOSTLEN];
memberlist *m;
struct chanset_t *chan;

strlcpy(buf, host, sizeof buf);
uhost = buf;
nick = splitnick(&uhost);
for (chan = chanset; chan; chan = chan->next)
for (m = chan->channel.member; m && m->nick[0]; m = m->next)
if (!rfc_casecmp(nick, m->nick) && !strcasecmp(uhost, m->userhost))
return m->user;
return NULL;
}

/* Clear the user pointers in the chanlists.
*
* Necessary when a hostmask is added/removed, a user is added or a new
Expand All @@ -152,13 +128,12 @@ void clear_chanlist(void)

for (chan = chanset; chan; chan = chan->next)
for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
m->user = NULL;
m->tried_getuser = 0;
}
}

/* Clear the user pointer of a specific nick in the chanlists.
*
* Necessary when a hostmask is added/removed, a nick changes, etc.
* Does not completely invalidate the channel cache like clear_chanlist().
*/
Expand All @@ -170,29 +145,11 @@ void clear_chanlist_member(const char *nick)
for (chan = chanset; chan; chan = chan->next)
for (m = chan->channel.member; m && m->nick[0]; m = m->next)
if (!rfc_casecmp(m->nick, nick)) {
m->user = NULL;
m->tried_getuser = 0;
break;
}
}

/* If this user@host is in a channel, set it (it was null)
*/
void set_chanlist(const char *host, struct userrec *rec)
{
char *nick, *uhost, buf[UHOSTLEN];
memberlist *m;
struct chanset_t *chan;

strlcpy(buf, host, sizeof buf);
uhost = buf;
nick = splitnick(&uhost);
for (chan = chanset; chan; chan = chan->next)
for (m = chan->channel.member; m && m->nick[0]; m = m->next)
if (!rfc_casecmp(nick, m->nick) && !strcasecmp(uhost, m->userhost))
m->user = rec;
}

/* Calculate the memory we should be using
*/
int expmem_chanprog()
Expand Down
7 changes: 1 addition & 6 deletions src/mod/channels.mod/userchan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,12 +1270,7 @@ static int expired_mask(struct chanset_t *chan, char *who)
* present in the channel and has op.
*/

if (m->user)
u = m->user;
else {
simple_sprintf(buf, "%s!%s", m->nick, m->userhost);
u = get_user_by_host(buf);
}
u = get_user_from_member(m);
/* Do not expire masks set by bots. */
if (u && u->flags & USER_BOT)
return 0;
Expand Down
Loading

0 comments on commit c2f7d78

Please sign in to comment.