changed the writability checker to use poll() to handle a high file descroptor in httpd-std.c.
added server.backlog-size option for httpd servers
This commit is contained in:
@ -109,6 +109,9 @@
|
||||
# if defined(HAVE_SYS_EPOLL_H)
|
||||
# include <sys/epoll.h>
|
||||
# endif
|
||||
# if defined(HAVE_SYS_POLL_H)
|
||||
# include <sys/poll.h>
|
||||
# endif
|
||||
# if defined(__linux__)
|
||||
# include <limits.h>
|
||||
# if defined(HAVE_LINUX_NETFILTER_IPV4_H)
|
||||
@ -1044,7 +1047,8 @@ bind_ok:
|
||||
}
|
||||
}
|
||||
|
||||
if (listen (fd, 10) <= -1)
|
||||
HTTPD_DBGOUT1 ("Setting backlog size to %d\n", server->dope.backlog_size);
|
||||
if (listen (fd, server->dope.backlog_size) <= -1)
|
||||
{
|
||||
qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
|
||||
goto oops;
|
||||
@ -1087,7 +1091,7 @@ static int server_accept (
|
||||
|
||||
#if 0
|
||||
/* TODO: implement maximum number of client per server??? */
|
||||
if (fd >= FD_SETSIZE)
|
||||
if (fd >= FD_SETSIZE - 1)
|
||||
{
|
||||
HTTPD_DEBUG ("ERROR: too many client - max %d, fd %d\n", (FD_SETSIZE, fd));
|
||||
/*TODO: qse_httpd_seterrnum (httpd, QSE_HTTPD_EXXXXX);*/
|
||||
@ -1857,10 +1861,27 @@ static int mux_writable (qse_httpd_t* httpd, qse_httpd_hnd_t handle, const qse_n
|
||||
tv = tmout? QSE_SECNSEC_TO_MSEC (tmout->sec, tmout->nsec): -1;
|
||||
return os2_select (&handle, 0, 1, 0, tv);
|
||||
|
||||
#elif defined(HAVE_SYS_POLL_H)
|
||||
struct pollfd p;
|
||||
int tv;
|
||||
|
||||
p.fd = handle;
|
||||
p.events = POLLOUT;
|
||||
p.revents = 0;
|
||||
|
||||
tv = tmout? QSE_SECNSEC_TO_MSEC(tmout->sec, tmout->nsec): -1;
|
||||
return poll (&p, 1, tv);
|
||||
#else
|
||||
|
||||
fd_set w;
|
||||
struct timeval tv, * tvp;
|
||||
|
||||
#if defined(FD_SETSIZE)
|
||||
/* NOTE: when the handle exceeds FD_SETSIZE,
|
||||
* select() may screw the entire program. */
|
||||
if (handle >= FD_SETSIZE - 1) return -1;
|
||||
#endif
|
||||
|
||||
FD_ZERO (&w);
|
||||
FD_SET (handle, &w);
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/si/sio.h>
|
||||
|
||||
|
||||
#if !defined(QSE_HTTPD_DEFAULT_MODPREFIX)
|
||||
# if defined(_WIN32)
|
||||
# define QSE_HTTPD_DEFAULT_MODPREFIX "qsehttpd-"
|
||||
@ -1673,6 +1672,7 @@ static int invoke_client_task (
|
||||
qse_ntime_t tmout;
|
||||
tmout.sec = 0;
|
||||
tmout.nsec = 0;
|
||||
|
||||
if (httpd->opt.scb.mux.writable (httpd, client->handle, &tmout) <= 0)
|
||||
{
|
||||
/* it is not writable yet. so just skip
|
||||
@ -1732,7 +1732,6 @@ static int perform_client_task (
|
||||
else
|
||||
{
|
||||
/* locate an active client to the tail of the client list */
|
||||
|
||||
qse_gettime (&client->last_active); /* TODO: error check??? */
|
||||
move_client_to_tail (httpd, client);
|
||||
|
||||
|
Reference in New Issue
Block a user