summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2013-12-30 11:01:42 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2013-12-30 11:01:42 -0500
commit62aacecd7de0dc53ff4617aed905058a19b2a012 (patch)
tree5c5b4fbb63d77d65a48a29e0b75046a421ce7e9b
parent9be1d757ef2b6fcf1173522671359078ea12a6af (diff)
HTTP: continue after accept() failure
-rw-r--r--src/c/http.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/c/http.c b/src/c/http.c
index 18e188da..25d2a320 100644
--- a/src/c/http.c
+++ b/src/c/http.c
@@ -430,19 +430,19 @@ int main(int argc, char *argv[]) {
int new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size);
if (new_fd < 0) {
- fprintf(stderr, "Socket accept failed\n");
- return 1;
- }
+ if (!quiet)
+ fprintf(stderr, "Socket accept failed\n");
+ } else {
+ if (!quiet)
+ printf("Accepted connection.\n");
- if (!quiet)
- printf("Accepted connection.\n");
+ if (keepalive) {
+ int flag = 1;
+ setsockopt(new_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
+ }
- if (keepalive) {
- int flag = 1;
- setsockopt(new_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
+ uw_enqueue(new_fd);
}
-
- uw_enqueue(new_fd);
}
}