comparison src/c/http.c @ 1948:6b80900ddc66

HTTP: continue after accept() failure
author Adam Chlipala <adam@chlipala.net>
date Mon, 30 Dec 2013 11:01:42 -0500
parents 8b1692660dac
children c93fbd139732
comparison
equal deleted inserted replaced
1947:619191c71abb 1948:6b80900ddc66
428 428
429 while (1) { 429 while (1) {
430 int new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size); 430 int new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size);
431 431
432 if (new_fd < 0) { 432 if (new_fd < 0) {
433 fprintf(stderr, "Socket accept failed\n"); 433 if (!quiet)
434 return 1; 434 fprintf(stderr, "Socket accept failed\n");
435 } 435 } else {
436 436 if (!quiet)
437 if (!quiet) 437 printf("Accepted connection.\n");
438 printf("Accepted connection.\n"); 438
439 439 if (keepalive) {
440 if (keepalive) { 440 int flag = 1;
441 int flag = 1; 441 setsockopt(new_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
442 setsockopt(new_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int)); 442 }
443 } 443
444 444 uw_enqueue(new_fd);
445 uw_enqueue(new_fd); 445 }
446 } 446 }
447 } 447 }
448 448
449 void *uw_init_client_data() { 449 void *uw_init_client_data() {
450 return NULL; 450 return NULL;