Author: Isomer <isomer@coders.net>
[ircu2.10.12-pk.git] / ircd / listener.c
index f158ec1a71e933d7014db0be4317d3fc7e8e7d55..f6ce0e3df52abef023ecd28c20da99e9be30f2ff 100644 (file)
@@ -23,6 +23,7 @@
 #include "ircd.h"
 #include "ircd_alloc.h"
 #include "ircd_osdep.h"
+#include "ircd_reply.h"
 #include "ircd_string.h"
 #include "numeric.h"
 #include "s_bsd.h"
@@ -127,11 +128,9 @@ void show_ports(struct Client* sptr, int show_hidden, int port, int count)
     }
     else
       flags[1] = '\0';
-        
-    sendto_one(sptr, rpl_str(RPL_STATSPLINE),
-               me.name, sptr->name, listener->port,
-               listener->ref_count, flags, 
-               (listener->active) ? "active" : "disabled");
+
+    send_reply(sptr, RPL_STATSPLINE, listener->port, listener->ref_count,
+              flags, (listener->active) ? "active" : "disabled");
     if (--count == 0)
       break;
   }
@@ -245,7 +244,7 @@ static void set_listener_mask(struct Listener* listener, const char* mask)
 
   assert(0 != listener);
 
-  if (EmptyString(mask) && strcmp(mask,"*")!=0) {
+  if (EmptyString(mask) || 0 == strcmp(mask, "*")) {
     listener->mask.s_addr = 0;
     return;
   }
@@ -413,8 +412,15 @@ void accept_connection(struct Listener* listener)
    * point, just assume that connections cannot
    * be accepted until some old is closed first.
    */
-  if (-1 == (fd = accept(listener->fd, (struct sockaddr*) &addr, &addrlen)))
+  if (-1 == (fd = accept(listener->fd, (struct sockaddr*) &addr, &addrlen))) {
+    /* Lotsa admins seem to have problems with not giving enough file descriptors
+     * to their server so we'll add a generic warning mechanism here.  If it
+     * turns out too many messages are generated for meaningless reasons we
+     * can filter them back.
+     */
+    sendto_op_mask(SNO_TCPCOMMON,"Unable to accept connection: %s", strerror(errno));
     return;
+  }
   /*
    * check for connection limit
    */