Increase TCP/IP listener backlog from 3 (which I am guessing was
authorMike Taylor <mike@indexdata.com>
Tue, 19 Jul 2005 12:40:52 +0000 (12:40 +0000)
committerMike Taylor <mike@indexdata.com>
Tue, 19 Jul 2005 12:40:52 +0000 (12:40 +0000)
copied from the SunOS manual entry way back when) so SOMAXCONN, so
that the socket will queue as many incoming connections as it's able
to handle ongoing connections.  In other words, it will never now
refuse a connection that it would be able to handle merely because
it's not got around to accepting() enough of the pending connections
yet.  This is the behaviour anyway under Linux, where the listen()
argument is ignored; but not under BSD and on systems such as
MS-Windows that use BSD-derived TCP/IP stacks.  The behaviour of
YAZ-based servers should now be uniform across operating systems in
this respect.

src/tcpip.c

index db0e834..6400e7d 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tcpip.c,v 1.16 2005-06-25 15:46:06 adam Exp $
+ * $Id: tcpip.c,v 1.17 2005-07-19 12:40:52 mike Exp $
  */
 /**
  * \file tcpip.c
  */
 /**
  * \file tcpip.c
@@ -534,7 +534,8 @@ static int tcpip_bind(COMSTACK h, void *address, int mode)
         h->cerrno = CSYSERR;
         return -1;
     }
         h->cerrno = CSYSERR;
         return -1;
     }
-    if (mode == CS_SERVER && listen(h->iofile, 3) < 0)
+    /* Allow a maximum-sized backlog of waiting-to-connect clients */
+    if (mode == CS_SERVER && listen(h->iofile, SOMAXCONN) < 0)
     {
         h->cerrno = CSYSERR;
         return -1;
     {
         h->cerrno = CSYSERR;
         return -1;