ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hopm/trunk/src/irc.c
(Generate patch)

Comparing hopm/trunk/src/irc.c (file contents):
Revision 6198 by michael, Thu Jun 25 14:36:47 2015 UTC vs.
Revision 6215 by michael, Sat Jun 27 17:18:30 2015 UTC

# Line 36 | Line 36
36   #include <errno.h>
37   #include <stdarg.h>
38   #include <regex.h>
39 + #include <assert.h>
40  
41   #include "config.h"
42   #include "irc.h"
# Line 59 | Line 60
60   */
61   static char         IRC_RAW[MSGLENMAX];  /* Buffer to read data into               */
62   static unsigned int IRC_RAW_LEN;         /* Position of IRC_RAW                    */
63 < static int          IRC_FD;              /* File descriptor for IRC client         */
63 > static int          IRC_FD = -1;         /* File descriptor for IRC client         */
64  
65   static struct sockaddr_storage IRC_SVR;  /* Sock Address Struct for IRC server     */
66   static socklen_t svr_addrlen;
# Line 464 | Line 465 | irc_init(void)
465   {
466    const void *address = NULL;
467  
468 <  if (IRC_FD)
468 <    close(IRC_FD);
468 >  assert(IRC_FD == -1);
469  
470    memset(&IRC_SVR, 0, sizeof(IRC_SVR));
471  
# Line 555 | Line 555 | irc_reconnect(void)
555  
556    time(&IRC_LASTRECONNECT);
557  
558 <  if (IRC_FD > 0)
558 >  if (IRC_FD > -1)
559 >  {
560      close(IRC_FD);
561 <
562 <  /* Set IRC_FD 0 for reconnection on next irc_cycle(). */
562 <  IRC_FD = 0;
561 >    IRC_FD = -1;  /* Set IRC_FD -1 for reconnection on next irc_cycle(). */
562 >  }
563  
564    log_printf("IRC -> Connection to (%s) failed, reconnecting.", IRCItem->server);
565   }
# Line 770 | Line 770 | irc_cycle(void)
770   {
771    static struct pollfd pfd;
772  
773 <  if (IRC_FD <= 0)
773 >  if (IRC_FD == -1)
774    {
775      /* Initialise negative cache. */
776      if (OptionsItem->negcache)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines