rbb 99/02/26 08:37:22
Modified: pthreads/src/main http_protocol.c
Log:
Inserted some error handling code, and got rid of a nasty infinite loop.
Stupid
errno not getting reset when I thought it was. This should fix the timeout
code.
Revision Changes Path
1.7 +21 -3 apache-apr/pthreads/src/main/http_protocol.c
Index: http_protocol.c
===================================================================
RCS file: /home/cvs/apache-apr/pthreads/src/main/http_protocol.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- http_protocol.c 1999/02/25 13:43:36 1.6
+++ http_protocol.c 1999/02/26 16:37:20 1.7
@@ -903,6 +903,7 @@
const char *expect;
int access_status;
struct pollfd *filedes;
+ int timeout, rv;
filedes = (struct pollfd *)malloc(sizeof(struct pollfd));
p = ap_make_sub_pool(conn->pool);
@@ -941,16 +942,33 @@
/* Get the request... */
ap_bnonblock(r->connection->client, B_RD);
+ errno = 0;
while (!read_request_line(r)) {
if (errno == EAGAIN) {
+ errno = 0;
filedes->fd = ap_bfileno(r->connection->client, B_RD);
filedes->events = POLLIN;
filedes->revents = 0;
- if (poll(filedes, 1, ap_get_timeout(r)) == 0) {
+ timeout = ap_get_timeout(r);
+ if ((rv = poll(filedes, 1, timeout)) == 0) {
ap_bclose(r->connection->client);
}
- else {
- continue;
+ else if (rv == -1) {
+ ap_bclose(r->connection->client);
+ ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
+ "Timeout hasn't occured, but something is wrong,
+ closing the connection.");
+ }
+ else {
+ if (filedes->revents &= POLLIN) {
+ continue;
+ }
+ else {
+ ap_bclose(r->connection->client);
+ ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
+ "Event other than POLLIN, closing
connection.");
+ }
+
}
}
if (r->status == HTTP_REQUEST_URI_TOO_LARGE) {