Which specifies the backlog value passed to listen().
Sponsored by: Robert Klemme
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.146 2017/06/26 12:11:12 fabiankeil Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.147 2017/06/26 12:12:55 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
*/
#define MAX_DNS_RETRIES 10
-#define MAX_LISTEN_BACKLOG 128
-
#ifdef HAVE_RFC2553
static jb_socket rfc2553_connect_to(const char *host, int portnum, struct client_state *csp);
#else
* Parameters :
* 1 : hostnam = TCP/IP address to bind/listen to
* 2 : portnum = port to listen on
- * 3 : pfd = pointer used to return file descriptor.
+ * 3 : backlog = Listen backlog
+ * 4 : pfd = pointer used to return file descriptor.
*
* Returns : if success, returns 0 and sets *pfd.
* if failure, returns -3 if address is in use,
* -2 if address unresolvable,
* -1 otherwise
*********************************************************************/
-int bind_port(const char *hostnam, int portnum, jb_socket *pfd)
+int bind_port(const char *hostnam, int portnum, int backlog, jb_socket *pfd)
{
#ifdef HAVE_RFC2553
struct addrinfo hints;
}
#endif /* ndef HAVE_RFC2553 */
- while (listen(fd, MAX_LISTEN_BACKLOG) == -1)
+ while (listen(fd, backlog) == -1)
{
if (errno != EINTR)
{
#ifndef JBSOCKETS_H_INCLUDED
#define JBSOCKETS_H_INCLUDED
-#define JBSOCKETS_H_VERSION "$Id: jbsockets.h,v 1.24 2014/06/02 06:22:20 fabiankeil Exp $"
+#define JBSOCKETS_H_VERSION "$Id: jbsockets.h,v 1.25 2017/06/04 14:37:05 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.h,v $
extern void close_socket(jb_socket fd);
extern void drain_and_close_socket(jb_socket fd);
-extern int bind_port(const char *hostnam, int portnum, jb_socket *pfd);
+extern int bind_port(const char *hostnam, int portnum, int backlog, jb_socket *pfd);
extern int accept_connection(struct client_state * csp, jb_socket fds[]);
extern void get_host_information(jb_socket afd, char **ip_address, char **port, char **hostname);
-const char jcc_rcs[] = "$Id: jcc.c,v 1.462 2017/06/26 12:10:31 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.463 2017/06/26 12:12:55 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
static void usage(const char *myname);
#endif
static void initialize_mutexes(void);
-static jb_socket bind_port_helper(const char *haddr, int hport);
+static jb_socket bind_port_helper(const char *haddr, int hport, int backlog);
static void bind_ports_helper(struct configuration_spec *config, jb_socket sockets[]);
static void close_ports_helper(jb_socket sockets[]);
static void listen_loop(void);
* 1 : haddr = Host address to bind to. Use NULL to bind to
* INADDR_ANY.
* 2 : hport = Specifies port to bind to.
+ * 3 : backlog = Listen backlog.
*
* Returns : Port that was opened.
*
*********************************************************************/
-static jb_socket bind_port_helper(const char *haddr, int hport)
+static jb_socket bind_port_helper(const char *haddr, int hport, int backlog)
{
int result;
jb_socket bfd;
- result = bind_port(haddr, hport, &bfd);
+ result = bind_port(haddr, hport, backlog, &bfd);
if (result < 0)
{
{
if (config->hport[i])
{
- sockets[i] = bind_port_helper(config->haddr[i], config->hport[i]);
+ sockets[i] = bind_port_helper(config->haddr[i],
+ config->hport[i], config->listen_backlog);
#if defined(FEATURE_ACCEPT_FILTER) && defined(SO_ACCEPTFILTER)
if (config->enable_accept_filter && sockets[i] != JB_INVALID_SOCKET)
{
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.163 2017/06/26 12:09:56 fabiankeil Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.164 2017/06/26 12:11:13 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
*/
#define DEFAULT_KEEP_ALIVE_TIMEOUT 180
+/*
+ * Default backlog passed to listen().
+ */
+#define DEFAULT_LISTEN_BACKLOG 128
+
const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
#ifdef FEATURE_TOGGLE
#define hash_hostname 10308071U /* "hostname" */
#define hash_keep_alive_timeout 3878599515U /* "keep-alive-timeout" */
#define hash_listen_address 1255650842U /* "listen-address" */
+#define hash_listen_backlog 1255655735U /* "listen-backlog" */
#define hash_logdir 422889U /* "logdir" */
#define hash_logfile 2114766U /* "logfile" */
#define hash_max_client_connections 3595884446U /* "max-client-connections" */
#if defined(FEATURE_ACCEPT_FILTER) && defined(SO_ACCEPTFILTER)
config->enable_accept_filter = 0;
#endif
+ config->listen_backlog = DEFAULT_LISTEN_BACKLOG;
config->trusted_cgi_referrer = NULL;
/*
* 128 client sockets ought to be enough for everybody who can't
config->haddr[i] = strdup_or_die(arg);
break;
+/* *************************************************************************
+ * listen-backlog n
+ * *************************************************************************/
+ case hash_listen_backlog :
+ /*
+ * We don't enfore an upper or lower limit because on
+ * many platforms all values are valid and negative
+ * number mean "use the highest value allowed".
+ */
+ config->listen_backlog = parse_numeric_value(cmd, arg);
+ break;
+
/* *************************************************************************
* logdir directory-name
* *************************************************************************/
#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
/** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.221 2017/05/29 10:02:11 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.222 2017/06/26 12:11:13 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
/** Use accf_http(4) if available */
int enable_accept_filter;
+ /** Backlog passed to listen() */
+ int listen_backlog;
+
#ifdef FEATURE_TRUST
/** The file name of the trust file. */