Module: ngircd.git Branch: master Commit: 08d49a8fa02ef11b22d611d11c595812ce207ac8 URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=08d49...
Author: Alexander Barton alex@barton.de Date: Tue Aug 6 23:16:35 2013 +0200
Fix return code of some IRC_WriteXXX() functions
These functions usually write to more than one target, and therefore can't return value indicating success or failure in a sane way. And, even more omportant, these functions should send to as much as possible clients and not stop at the first client which isn't reachable any more!
---
src/ngircd/channel.c | 5 +++-- src/ngircd/irc-write.c | 36 ++++++++++++++++-------------------- src/ngircd/irc-write.h | 8 ++++---- 3 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/src/ngircd/channel.c b/src/ngircd/channel.c index c5f65fe..06b88ba 100644 --- a/src/ngircd/channel.c +++ b/src/ngircd/channel.c @@ -931,8 +931,9 @@ Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Command, if (Client_Conn(From) > NONE) Conn_UpdateIdle(Client_Conn(From));
- return IRC_WriteStrChannelPrefix(Client, Chan, From, true, - "%s %s :%s", Command, Channel_Name(Chan), Text); + IRC_WriteStrChannelPrefix(Client, Chan, From, true, "%s %s :%s", + Command, Channel_Name(Chan), Text); + return CONNECTED; }
diff --git a/src/ngircd/irc-write.c b/src/ngircd/irc-write.c index ea9b9a0..f4d4361 100644 --- a/src/ngircd/irc-write.c +++ b/src/ngircd/irc-write.c @@ -41,7 +41,7 @@ static const char *Get_Prefix PARAMS((CLIENT *Target, CLIENT *Client)); static void cb_writeStrServersPrefixFlag PARAMS((CLIENT *Client, CLIENT *Prefix, void *Buffer)); -static bool Send_Marked_Connections PARAMS((CLIENT *Prefix, const char *Buffer)); +static void Send_Marked_Connections PARAMS((CLIENT *Prefix, const char *Buffer));
#ifdef PROTOTYPES @@ -112,11 +112,11 @@ va_dcl
#ifdef PROTOTYPES -GLOBAL bool +GLOBAL void IRC_WriteStrChannel(CLIENT *Client, CHANNEL *Chan, bool Remote, const char *Format, ...) #else -GLOBAL bool +GLOBAL void IRC_WriteStrChannel(Client, Chan, Remote, Format, va_alist) CLIENT *Client; CHANNEL *Chan; @@ -139,21 +139,21 @@ va_dcl vsnprintf( buffer, 1000, Format, ap ); va_end( ap );
- return IRC_WriteStrChannelPrefix( Client, Chan, Client_ThisServer( ), Remote, "%s", buffer ); + IRC_WriteStrChannelPrefix(Client, Chan, Client_ThisServer(), + Remote, "%s", buffer ); } /* IRC_WriteStrChannel */
- /** * send message to all clients in the same channel, but only send message * once per remote server. */ #ifdef PROTOTYPES -GLOBAL bool +GLOBAL void IRC_WriteStrChannelPrefix(CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, bool Remote, const char *Format, ...) #else -GLOBAL bool +GLOBAL void IRC_WriteStrChannelPrefix(Client, Chan, Prefix, Remote, Format, va_alist) CLIENT *Client; CHANNEL *Chan; @@ -204,7 +204,7 @@ va_dcl } cl2chan = Channel_NextMember( Chan, cl2chan ); } - return Send_Marked_Connections(Prefix, buffer); + Send_Marked_Connections(Prefix, buffer); } /* IRC_WriteStrChannelPrefix */
@@ -324,11 +324,11 @@ IRC_WriteStrServersPrefixFlag_CB(CLIENT *ExceptOf, CLIENT *Prefix, char Flag, * only send message once per remote server. */ #ifdef PROTOTYPES -GLOBAL bool +GLOBAL void IRC_WriteStrRelatedPrefix(CLIENT *Client, CLIENT *Prefix, bool Remote, const char *Format, ...) #else -GLOBAL bool +GLOBAL void IRC_WriteStrRelatedPrefix(Client, Prefix, Remote, Format, va_alist) CLIENT *Client; CLIENT *Prefix; @@ -384,7 +384,7 @@ va_dcl
chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan ); } - return Send_Marked_Connections(Prefix, buffer); + Send_Marked_Connections(Prefix, buffer); } /* IRC_WriteStrRelatedPrefix */
@@ -471,11 +471,10 @@ cb_writeStrServersPrefixFlag(CLIENT *Client, CLIENT *Prefix, void *Buffer) } /* cb_writeStrServersPrefixFlag */
-static bool +static void Send_Marked_Connections(CLIENT *Prefix, const char *Buffer) { CONN_ID conn; - bool ok = CONNECTED;
assert(Prefix != NULL); assert(Buffer != NULL); @@ -483,16 +482,13 @@ Send_Marked_Connections(CLIENT *Prefix, const char *Buffer) conn = Conn_First(); while (conn != NONE) { if (Conn_Flag(conn) == SEND_TO_SERVER) - ok = Conn_WriteStr(conn, ":%s %s", - Client_ID(Prefix), Buffer); + Conn_WriteStr(conn, ":%s %s", + Client_ID(Prefix), Buffer); else if (Conn_Flag(conn) == SEND_TO_USER) - ok = Conn_WriteStr(conn, ":%s %s", - Client_MaskCloaked(Prefix), Buffer); - if (!ok) - break; + Conn_WriteStr(conn, ":%s %s", + Client_MaskCloaked(Prefix), Buffer); conn = Conn_Next( conn ); } - return ok; }
diff --git a/src/ngircd/irc-write.h b/src/ngircd/irc-write.h index dc8dec2..ddfe2f0 100644 --- a/src/ngircd/irc-write.h +++ b/src/ngircd/irc-write.h @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2008 Alexander Barton (alex@barton.de) + * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,9 +21,9 @@ GLOBAL bool IRC_WriteStrClient PARAMS((CLIENT *Client, const char *Format, ...)) GLOBAL bool IRC_WriteStrClientPrefix PARAMS((CLIENT *Client, CLIENT *Prefix, const char *Format, ...));
-GLOBAL bool IRC_WriteStrChannel PARAMS((CLIENT *Client, CHANNEL *Chan, +GLOBAL void IRC_WriteStrChannel PARAMS((CLIENT *Client, CHANNEL *Chan, bool Remote, const char *Format, ...)); -GLOBAL bool IRC_WriteStrChannelPrefix PARAMS((CLIENT *Client, CHANNEL *Chan, +GLOBAL void IRC_WriteStrChannelPrefix PARAMS((CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, bool Remote, const char *Format, ...));
GLOBAL void IRC_WriteStrServers PARAMS((CLIENT *ExceptOf, @@ -36,7 +36,7 @@ GLOBAL void IRC_WriteStrServersPrefixFlag_CB PARAMS((CLIENT *ExceptOf, CLIENT *Prefix, char Flag, void (*callback)(CLIENT *, CLIENT *, void *), void *cb_data));
-GLOBAL bool IRC_WriteStrRelatedPrefix PARAMS((CLIENT *Client, CLIENT *Prefix, +GLOBAL void IRC_WriteStrRelatedPrefix PARAMS((CLIENT *Client, CLIENT *Prefix, bool Remote, const char *Format, ...));
GLOBAL void IRC_SendWallops PARAMS((CLIENT *Client, CLIENT *From,