1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

This patch fixes the problem that irssi keeps saying Netsplit over for joins from a certain user, if that user split and then rejoined some but not all channels they used to be in. (by Jilles Tjoelker)

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4376 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Wouter Coekaerts 2006-09-22 08:49:10 +00:00 committed by coekie
parent 93184ce08d
commit ea9f3be18c

View File

@ -255,12 +255,17 @@ static int sig_check_netjoins(void)
{ {
GSList *tmp, *next; GSList *tmp, *next;
int diff; int diff;
time_t now;
now = time(NULL);
/* first print all netjoins which haven't had any new joins
* for NETJOIN_WAIT_TIME; this may cause them to be removed
* (all users who rejoined, rejoined all channels) */
for (tmp = joinservers; tmp != NULL; tmp = next) { for (tmp = joinservers; tmp != NULL; tmp = next) {
NETJOIN_SERVER_REC *server = tmp->data; NETJOIN_SERVER_REC *server = tmp->data;
next = tmp->next; next = tmp->next;
diff = time(NULL)-server->last_netjoin; diff = now-server->last_netjoin;
if (diff <= NETJOIN_WAIT_TIME) { if (diff <= NETJOIN_WAIT_TIME) {
/* wait for more JOINs */ /* wait for more JOINs */
continue; continue;
@ -268,8 +273,18 @@ static int sig_check_netjoins(void)
if (server->netjoins != NULL) if (server->netjoins != NULL)
print_netjoins(server); print_netjoins(server);
else if (diff >= NETJOIN_MAX_WAIT) { }
/* waited long enough, remove the netjoin */
/* now remove all netjoins which haven't had any new joins
* for NETJOIN_MAX_WAIT (user rejoined some but not all channels
* after split) */
for (tmp = joinservers; tmp != NULL; tmp = next) {
NETJOIN_SERVER_REC *server = tmp->data;
next = tmp->next;
diff = now-server->last_netjoin;
if (diff >= NETJOIN_MAX_WAIT) {
/* waited long enough, forget about the rest */
netjoin_server_remove(server); netjoin_server_remove(server);
} }
} }
@ -294,6 +309,8 @@ static void msg_join(IRC_SERVER_REC *server, const char *channel,
{ {
NETSPLIT_REC *split; NETSPLIT_REC *split;
NETJOIN_REC *netjoin; NETJOIN_REC *netjoin;
GSList *channels;
int rejoin = 1;
if (!IS_IRC_SERVER(server)) if (!IS_IRC_SERVER(server))
return; return;
@ -307,6 +324,25 @@ static void msg_join(IRC_SERVER_REC *server, const char *channel,
if (split == NULL && netjoin == NULL) if (split == NULL && netjoin == NULL)
return; return;
/* if this was not a channel they split from, treat it normally */
if (netjoin != NULL) {
if (!gslist_find_icase_string(netjoin->old_channels, channel))
return;
} else {
channels = split->channels;
while (channels != NULL) {
NETSPLIT_CHAN_REC *schannel = channels->data;
if (!strcasecmp(schannel->name, channel))
break;
channels = channels->next;
}
/* we still need to create a NETJOIN_REC now as the
* NETSPLIT_REC will be destroyed */
if (channels == NULL)
rejoin = 0;
}
if (join_tag == -1) { if (join_tag == -1) {
join_tag = g_timeout_add(1000, (GSourceFunc) join_tag = g_timeout_add(1000, (GSourceFunc)
sig_check_netjoins, NULL); sig_check_netjoins, NULL);
@ -316,9 +352,12 @@ static void msg_join(IRC_SERVER_REC *server, const char *channel,
if (netjoin == NULL) if (netjoin == NULL)
netjoin = netjoin_add(server, nick, split->channels); netjoin = netjoin_add(server, nick, split->channels);
if (rejoin)
{
netjoin->now_channels = g_slist_append(netjoin->now_channels, netjoin->now_channels = g_slist_append(netjoin->now_channels,
g_strconcat(" ", channel, NULL)); g_strconcat(" ", channel, NULL));
signal_stop(); signal_stop();
}
} }
static int netjoin_set_nickmode(IRC_SERVER_REC *server, NETJOIN_REC *rec, static int netjoin_set_nickmode(IRC_SERVER_REC *server, NETJOIN_REC *rec,