From: michael Date: Sat, 27 Jun 2015 17:18:30 +0000 (+0000) Subject: - irc.c: remove assumption that socket() returns fd higher than 0 (which it probably... X-Git-Tag: 1.1.0beta1~10 X-Git-Url: http://git.serene-ircd.net/?a=commitdiff_plain;h=20d8ca9717aaca52e0bd960b57e58feb5389d401;p=hopm.git - irc.c: remove assumption that socket() returns fd higher than 0 (which it probably won't because of log files opened before, but let's remove that limitation anyway); removed close() in irc_init() since IRC_FD is always -1 at this point git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/trunk@6215 82007160-df01-0410-b94d-b575c5fd34c7 --- diff --git a/src/irc.c b/src/irc.c index d35a14c..d8a8e33 100644 --- a/src/irc.c +++ b/src/irc.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "config.h" #include "irc.h" @@ -59,7 +60,7 @@ */ static char IRC_RAW[MSGLENMAX]; /* Buffer to read data into */ static unsigned int IRC_RAW_LEN; /* Position of IRC_RAW */ -static int IRC_FD; /* File descriptor for IRC client */ +static int IRC_FD = -1; /* File descriptor for IRC client */ static struct sockaddr_storage IRC_SVR; /* Sock Address Struct for IRC server */ static socklen_t svr_addrlen; @@ -464,8 +465,7 @@ irc_init(void) { const void *address = NULL; - if (IRC_FD) - close(IRC_FD); + assert(IRC_FD == -1); memset(&IRC_SVR, 0, sizeof(IRC_SVR)); @@ -555,11 +555,11 @@ irc_reconnect(void) time(&IRC_LASTRECONNECT); - if (IRC_FD > 0) + if (IRC_FD > -1) + { close(IRC_FD); - - /* Set IRC_FD 0 for reconnection on next irc_cycle(). */ - IRC_FD = 0; + IRC_FD = -1; /* Set IRC_FD -1 for reconnection on next irc_cycle(). */ + } log_printf("IRC -> Connection to (%s) failed, reconnecting.", IRCItem->server); } @@ -770,7 +770,7 @@ irc_cycle(void) { static struct pollfd pfd; - if (IRC_FD <= 0) + if (IRC_FD == -1) { /* Initialise negative cache. */ if (OptionsItem->negcache)