mirror of
https://github.com/emikulic/darkhttpd.git
synced 2023-08-10 21:13:08 +03:00
After accepting a connection, attempt a read straight away instead of
going through an iteration of the select() loop.
This commit is contained in:
parent
f3ce5d1eb9
commit
ba91f1cdb3
@ -296,6 +296,9 @@ static const char default_mimetype[] = "application/octet-stream";
|
||||
#define keep_alive(conn) ((conn)->conn_close ? \
|
||||
"Connection: close\r\n" : keep_alive_field)
|
||||
|
||||
/* Prototypes. */
|
||||
static void poll_recv_request(struct connection *conn);
|
||||
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
@ -1171,6 +1174,9 @@ static void accept_connection(void)
|
||||
if (debug) printf("accepted connection from %s:%u\n",
|
||||
inet_ntoa(addrin.sin_addr),
|
||||
ntohs(addrin.sin_port) );
|
||||
|
||||
/* try to read straight away rather than going through select() */
|
||||
poll_recv_request(conn);
|
||||
}
|
||||
|
||||
|
||||
@ -1995,9 +2001,14 @@ static void poll_recv_request(struct connection *conn)
|
||||
conn->socket, (int)recvd);
|
||||
if (recvd <= 0)
|
||||
{
|
||||
if (recvd == -1)
|
||||
if (recvd == -1) {
|
||||
if (errno == EAGAIN) {
|
||||
if (debug) printf("poll_recv_request would have blocked\n");
|
||||
return;
|
||||
}
|
||||
if (debug) printf("recv(%d) error: %s\n",
|
||||
conn->socket, strerror(errno));
|
||||
}
|
||||
conn->conn_close = 1;
|
||||
conn->state = DONE;
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user