]> jfr.im git - irc/quakenet/newserv.git/blobdiff - nickrate/nickrate.c
CHANSERV: remove accidental sendemail from SETEMAIL command.
[irc/quakenet/newserv.git] / nickrate / nickrate.c
index 7d28b9358722d45e394142cff9ddbcade886dd02..6da2f43cca9eebb314ebe5d0ae329bcd576c8e6f 100644 (file)
@@ -14,6 +14,9 @@
 #include <unistd.h>
 #include <netinet/in.h>
 #include <string.h>
+#include "../lib/version.h"
+
+MODULE_VERSION("")
 
 unsigned int nicks;
 unsigned int quits;
@@ -65,6 +68,7 @@ int nr_openlistensocket(int portnum) {
   }
   
   if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *) &opt, sizeof(opt))!=0) {
+    close(fd);
     Error("proxyscan",ERR_ERROR,"Unable to set SO_REUSEADDR on listen socket.");
     return -1;
   }
@@ -75,6 +79,7 @@ int nr_openlistensocket(int portnum) {
   sin.sin_port=htons(portnum);
   
   if (bind(fd, (struct sockaddr *) &sin, sizeof(sin))) {
+    close(fd);
     Error("proxyscan",ERR_ERROR,"Unable to bind listen socket (%d).",errno);
     return -1;
   }
@@ -82,6 +87,7 @@ int nr_openlistensocket(int portnum) {
   listen(fd,5);
   
   if (ioctl(fd, FIONBIO, &opt)!=0) {
+    close(fd);
     Error("proxyscan",ERR_ERROR,"Unable to set listen socket non-blocking.");
     return -1;
   }
@@ -98,7 +104,7 @@ void nr_handlelistensocket(int fd, short events) {
   socklen_t addrsize=sizeof(sin);
   char buf[20];
   int newfd;
-  if ((newfd=accept(fd, (struct sockaddr *)&sin, &addrsize))>0) {
+  if ((newfd=accept(fd, (struct sockaddr *)&sin, &addrsize))>-1) {
     /* Got new connection */
     sprintf(buf,"%u\n",nicks);
     write(newfd,buf,strlen(buf));