summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2001-09-05 02:26:59 +0000
committerBob Beck <beck@cvs.openbsd.org>2001-09-05 02:26:59 +0000
commitb5cb0bde2aee1e005dfbc3a0c6f5d3a5cb9df108 (patch)
treeb9f3f865a356bda6dd483ed520eebd87d6072e23 /usr.sbin
parent7dded57325a882739006307c90b45838ff10aa47 (diff)
correct select(FD_SETSIZE,...) misuse
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/httpd/src/main/buff.c4
-rw-r--r--usr.sbin/httpd/src/modules/ssl/ssl_engine_io.c4
-rw-r--r--usr.sbin/httpd/src/support/ab.c12
3 files changed, 13 insertions, 7 deletions
diff --git a/usr.sbin/httpd/src/main/buff.c b/usr.sbin/httpd/src/main/buff.c
index 693539c8ca7..9d55d23aceb 100644
--- a/usr.sbin/httpd/src/main/buff.c
+++ b/usr.sbin/httpd/src/main/buff.c
@@ -160,7 +160,7 @@ int sendwithtimeout(int sock, const char *buf, int len, int flags)
FD_ZERO(&fdset);
FD_SET(sock, &fdset);
tv.tv_usec = 0;
- rv = select(FD_SETSIZE, NULL, &fdset, NULL, &tv);
+ rv = select(sock + 1, NULL, &fdset, NULL, &tv);
if (rv == SOCKET_ERROR)
err = WSAGetLastError();
else if (rv == 0) {
@@ -228,7 +228,7 @@ int recvwithtimeout(int sock, char *buf, int len, int flags)
FD_ZERO(&fdset);
FD_SET(sock, &fdset);
tv.tv_usec = 0;
- rv = select(FD_SETSIZE, &fdset, NULL, NULL, &tv);
+ rv = select(sock + 1, &fdset, NULL, NULL, &tv);
if (rv == SOCKET_ERROR)
err = WSAGetLastError();
else if (rv == 0) {
diff --git a/usr.sbin/httpd/src/modules/ssl/ssl_engine_io.c b/usr.sbin/httpd/src/modules/ssl/ssl_engine_io.c
index 4ba1574ca88..a313eb4d5a1 100644
--- a/usr.sbin/httpd/src/modules/ssl/ssl_engine_io.c
+++ b/usr.sbin/httpd/src/modules/ssl/ssl_engine_io.c
@@ -515,7 +515,7 @@ static int SSL_sendwithtimeout(BUFF *fb, const char *buf, int len)
FD_ZERO(&fdset);
FD_SET((unsigned int)sock, &fdset);
tv.tv_usec = 0;
- rv = select(FD_SETSIZE, NULL, &fdset, NULL, &tv);
+ rv = select(sock + 1, NULL, &fdset, NULL, &tv);
if (rv == SOCKET_ERROR)
err = WSAGetLastError();
else if (rv == 0) {
@@ -572,7 +572,7 @@ static int SSL_recvwithtimeout(BUFF *fb, char *buf, int len)
FD_ZERO(&fdset);
FD_SET((unsigned int)sock, &fdset);
tv.tv_usec = 0;
- rv = select(FD_SETSIZE, &fdset, NULL, NULL, &tv);
+ rv = select(sock + 1, &fdset, NULL, NULL, &tv);
if (rv == SOCKET_ERROR)
err = WSAGetLastError();
else if (rv == 0) {
diff --git a/usr.sbin/httpd/src/support/ab.c b/usr.sbin/httpd/src/support/ab.c
index acca8363bcb..285b0dfe893 100644
--- a/usr.sbin/httpd/src/support/ab.c
+++ b/usr.sbin/httpd/src/support/ab.c
@@ -226,6 +226,7 @@ struct connection *con; /* connection array */
struct data *stats; /* date for each request */
fd_set readbits, writebits; /* bits for select */
+int fd_max; /* for select */
struct sockaddr_in server; /* server addr structure */
#ifndef BEOS
@@ -286,6 +287,7 @@ static void write_request(struct connection * c)
c->state = STATE_READ;
FD_SET(c->fd, &readbits);
FD_CLR(c->fd, &writebits);
+ fd_max = fd_max < c->fd ? c->fd : fd_max;
}
/* --------------------------------------------------------- */
@@ -541,6 +543,7 @@ static void start_connect(struct connection * c)
if (errno == EINPROGRESS) {
c->state = STATE_CONNECTING;
FD_SET(c->fd, &writebits);
+ fd_max = fd_max < c->fd ? c->fd : fd_max;
return;
}
else {
@@ -556,6 +559,7 @@ static void start_connect(struct connection * c)
/* connected first time */
c->state = STATE_CONNECTING;
FD_SET(c->fd, &writebits);
+ fd_max = fd_max < c->fd ? c->fd : fd_max;
}
/* --------------------------------------------------------- */
@@ -788,6 +792,7 @@ static void test(void)
FD_ZERO(&readbits);
FD_ZERO(&writebits);
+ fd_max = 0;
/* setup request */
if (posting <= 0) {
@@ -853,7 +858,8 @@ static void test(void)
/* Timeout of 30 seconds. */
timeout.tv_sec = 30;
timeout.tv_usec = 0;
- n = ap_select(FD_SETSIZE, &sel_read, &sel_write, &sel_except, &timeout);
+ n = ap_select(fd_max + 1, &sel_read, &sel_write, &sel_except,
+ &timeout);
if (!n) {
err("\nServer timed out\n\n");
}
@@ -886,14 +892,14 @@ static void test(void)
static void copyright(void)
{
if (!use_html) {
- printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.6 $> apache-1.3");
+ printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.7 $> apache-1.3");
printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n");
printf("Copyright (c) 1998-1999 The Apache Group, http://www.apache.org/\n");
printf("\n");
}
else {
printf("<p>\n");
- printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-1.3<br>\n", VERSION, "$Revision: 1.6 $");
+ printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-1.3<br>\n", VERSION, "$Revision: 1.7 $");
printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
printf(" Copyright (c) 1998-1999 The Apache Group, http://www.apache.org/<br>\n");
printf("</p>\n<p>\n");