summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2016-04-02 16:14:01 +0200
committerLemonBoy <thatlemon@gmail.com>2016-06-26 21:45:03 +0200
commited06e43ec816eb4b9f1a736ecba6802a586887a8 (patch)
treed819f0b06a5d036bdfa3ba3d54b0d801939f223b
parentfd371cc345aeb0254750c801f6570b5208974ce4 (diff)
downloadirssi-ed06e43ec816eb4b9f1a736ecba6802a586887a8.zip
Some small adjustments to the netsplit code.
By making the signal handler hooked to the "print starting" event smarter we can avoid dumping the whole netsplit stats for every server/channel when a message arrives. Issue #420
-rw-r--r--src/fe-common/irc/fe-netjoin.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/fe-common/irc/fe-netjoin.c b/src/fe-common/irc/fe-netjoin.c
index f5cb081e..6e54b313 100644
--- a/src/fe-common/irc/fe-netjoin.c
+++ b/src/fe-common/irc/fe-netjoin.c
@@ -164,7 +164,7 @@ static void print_channel_netjoins(char *channel, TEMP_PRINT_REC *rec,
g_free(channel);
}
-static void print_netjoins(NETJOIN_SERVER_REC *server)
+static void print_netjoins(NETJOIN_SERVER_REC *server, const char *channel)
{
TEMP_PRINT_REC *temp;
GHashTable *channels;
@@ -186,6 +186,9 @@ static void print_netjoins(NETJOIN_SERVER_REC *server)
char *channel = rec->now_channels->data;
char *realchannel = channel + 1;
+ if (channel != NULL && strcasecmp(realchannel, channel) != 0)
+ continue;
+
temp = g_hash_table_lookup(channels, realchannel);
if (temp == NULL) {
temp = g_new0(TEMP_PRINT_REC, 1);
@@ -235,20 +238,31 @@ static void print_netjoins(NETJOIN_SERVER_REC *server)
/* something is going to be printed to screen, print our current netsplit
message before it. */
-static void sig_print_starting(void)
+static void sig_print_starting(TEXT_DEST_REC *dest)
{
- GSList *tmp, *next;
+ NETJOIN_SERVER_REC *rec;
if (printing_joins)
return;
- for (tmp = joinservers; tmp != NULL; tmp = next) {
- NETJOIN_SERVER_REC *server = tmp->data;
+ /* Do not dump the netsplit stats unless:
+ * a) This is an IRC server
+ * b) The message level is high enough
+ * b) The message belongs to a channel
+ * c) There's a NETJOIN record for this server
+ */
+ if (!IS_IRC_SERVER(dest->server))
+ return;
- next = tmp->next;
- if (server->netjoins != NULL)
- print_netjoins(server);
- }
+ if (dest->level != MSGLEVEL_MSGS)
+ return;
+
+ if (!server_ischannel(dest->server, dest->target))
+ return;
+
+ rec = netjoin_find_server(IRC_SERVER(dest->server));
+ if (rec != NULL && rec->netjoins != NULL)
+ print_netjoins(rec, dest->target);
}
static int sig_check_netjoins(void)
@@ -272,7 +286,7 @@ static int sig_check_netjoins(void)
}
if (server->netjoins != NULL)
- print_netjoins(server);
+ print_netjoins(server, NULL);
}
/* now remove all netjoins which haven't had any new joins