Mailing List Archive

cvs commit: apache-1.3/src/main http_main.c
brian 98/04/27 22:59:55

Modified: src CHANGES
src/main http_main.c
Log:
Submitted by: Roy Fielding
Reviewed by: Brian Behlendorf

Fix two select bugs in http_main.

Revision Changes Path
1.801 +3 -0 apache-1.3/src/CHANGES

Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.800
retrieving revision 1.801
diff -u -r1.800 -r1.801
--- CHANGES 1998/04/27 22:37:47 1.800
+++ CHANGES 1998/04/28 05:59:48 1.801
@@ -1,4 +1,7 @@
Changes with Apache 1.3b7
+
+ *) Fix two bugs in select() handling in http_main.c.
+ [Roy Fielding]

*) Suppress "error(0)" messages for ap_log_error() when the APLOG_NOERRNO
is unset (as it is in situations like timeouts) where it is unclear



1.327 +21 -25 apache-1.3/src/main/http_main.c

Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v
retrieving revision 1.326
retrieving revision 1.327
diff -u -r1.326 -r1.327
--- http_main.c 1998/04/27 08:17:28 1.326
+++ http_main.c 1998/04/28 05:59:53 1.327
@@ -1153,10 +1153,10 @@
*/
static void lingering_close(request_rec *r)
{
- char dummybuf[2048];
+ char dummybuf[512];
struct timeval tv;
- fd_set lfds, fds_read, fds_err;
- int select_rv = 0;
+ fd_set lfds;
+ int select_rv;
int lsd;

/* Prevent a slow-drip client from holding us here indefinitely */
@@ -1185,13 +1185,11 @@
/* Set up to wait for readable data on socket... */

FD_ZERO(&lfds);
- FD_SET(lsd, &lfds);

/* Wait for readable data or error condition on socket;
- * slurp up any data that arrives... We exit when we go for
- * an interval of tv length without getting any more data, get an
- * error from select(), get an exception on lsd, get an error or EOF
- * on a read, or the timer expires.
+ * slurp up any data that arrives... We exit when we go for an
+ * interval of tv length without getting any more data, get an error
+ * from select(), get an error or EOF on a read, or the timer expires.
*/

do {
@@ -1204,17 +1202,15 @@
* These parameters are reset on each pass, since they might be
* changed by select.
*/
+ FD_SET(lsd, &lfds);
tv.tv_sec = 2;
tv.tv_usec = 0;
- fds_read = lfds;
- fds_err = lfds;

- select_rv = ap_select(lsd + 1, &fds_read, NULL, &fds_err, &tv);
- } while ((select_rv > 0) && /* Something to see on socket */
- !FD_ISSET(lsd, &fds_err) && /* that isn't an error condition */
- FD_ISSET(lsd, &fds_read) && /* and is worth trying to read */
- (read(lsd, dummybuf, sizeof dummybuf) > 0));
+ select_rv = ap_select(lsd + 1, &lfds, NULL, NULL, &tv);

+ } while ((select_rv > 0) &&
+ (read(lsd, dummybuf, sizeof dummybuf) > 0));
+
/* Should now have seen final ack. Safe to finally kill socket */

ap_bclose(r->connection->client);
@@ -1277,18 +1273,18 @@

fd_max = 0;
FD_ZERO(&writable_fds);
- for (ocr = other_children; ocr; ocr = ocr->next) {
- if (ocr->write_fd == -1)
- continue;
- FD_SET(ocr->write_fd, &writable_fds);
- if (ocr->write_fd > fd_max) {
- fd_max = ocr->write_fd;
+ do {
+ for (ocr = other_children; ocr; ocr = ocr->next) {
+ if (ocr->write_fd == -1)
+ continue;
+ FD_SET(ocr->write_fd, &writable_fds);
+ if (ocr->write_fd > fd_max) {
+ fd_max = ocr->write_fd;
+ }
}
- }
- if (fd_max == 0)
- return;
+ if (fd_max == 0)
+ return;

- do {
tv.tv_sec = 0;
tv.tv_usec = 0;
rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);