From 57024ab1e4271f232c481ffdf0fea7736c7a9220 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Fri, 11 Jan 2013 10:30:44 +0100 Subject: [PATCH] relay: fix duplicated messages sent to irc clients (when messages are redirected) (bug #37870) --- ChangeLog | 4 +++- src/plugins/relay/irc/relay-irc.c | 27 ++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 315082d72..1307702dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu -v0.4.0-rc2, 2013-01-10 +v0.4.0-rc2, 2013-01-11 Version 0.4.0 (under dev!) @@ -106,6 +106,8 @@ Version 0.4.0 (under dev!) * perl: display script filename in error messages * perl: fix calls to callbacks during load of script when multiplicity is disabled (bug #38044) +* relay: fix duplicated messages sent to irc clients (when messages are + redirected) (bug #37870) * relay: fix memory leak when adding hdata to a message (weechat protocol) * relay: add backlog and server capability "server-time" for irc protocol, add new options relay.irc.backlog_max_minutes, relay.irc.backlog_max_number, diff --git a/src/plugins/relay/irc/relay-irc.c b/src/plugins/relay/irc/relay-irc.c index 53d40103f..5534a6e5e 100644 --- a/src/plugins/relay/irc/relay-irc.c +++ b/src/plugins/relay/irc/relay-irc.c @@ -519,21 +519,34 @@ int relay_irc_hsignal_irc_redir_cb (void *data, const char *signal, struct t_hashtable *hashtable) { + struct t_relay_client *client; int rc, client_id, num_messages, i; char pattern[128], **messages; const char *output; - struct t_relay_client *ptr_client; - /* make C compiler happy */ - (void) data; + client = (struct t_relay_client *)data; + + if (weechat_relay_plugin->debug >= 2) + { + weechat_printf (NULL, "%s: %s: client: %s%s%s", + RELAY_PLUGIN_NAME, + signal, + RELAY_COLOR_CHAT_CLIENT, + client->desc, + RELAY_COLOR_CHAT); + } rc = sscanf (signal, "irc_redirection_relay_%d_%s", &client_id, pattern); if (rc != 2) return WEECHAT_RC_OK; - ptr_client = relay_client_search_by_id (client_id); - if (!ptr_client) + /* check that client id found in signal exists */ + if (!relay_client_search_by_id (client_id)) + return WEECHAT_RC_OK; + + /* ignore redirection if it is for another relay client */ + if (client->id != client_id) return WEECHAT_RC_OK; output = weechat_hashtable_get (hashtable, "output"); @@ -545,7 +558,7 @@ relay_irc_hsignal_irc_redir_cb (void *data, const char *signal, { for (i = 0; i < num_messages; i++) { - relay_irc_sendf (ptr_client, messages[i]); + relay_irc_sendf (client, messages[i]); } weechat_string_free_split (messages); } @@ -1176,7 +1189,7 @@ relay_irc_hook_signals (struct t_relay_client *client) RELAY_IRC_DATA(client, hook_hsignal_irc_redir) = weechat_hook_hsignal ("irc_redirection_relay_*", &relay_irc_hsignal_irc_redir_cb, - NULL); + client); } /*