459 |
*/ |
*/ |
460 |
static RequestWrapper socket_producer(int server) { |
static RequestWrapper socket_producer(int server) { |
461 |
|
|
462 |
|
int i= 0; |
463 |
int client, rv; |
int client, rv; |
|
int len= sizeof(struct sockaddr_in); |
|
464 |
struct sockaddr_in in; |
struct sockaddr_in in; |
465 |
struct pollfd fds[1]; |
struct pollfd fds[1]; |
466 |
|
int len= sizeof(struct sockaddr_in); |
467 |
|
|
468 |
fds[0].fd = server; |
fds[0].fd= server; |
469 |
fds[0].events = POLLIN | POLLPRI; |
fds[0].events= POLLIN | POLLPRI; |
470 |
|
|
|
again: |
|
471 |
errno= 0; |
errno= 0; |
472 |
|
do { |
473 |
|
i= poll(fds, 1, 1000); |
474 |
|
rv= (i == 1 && fds[0].revents & (POLLIN)); |
475 |
|
} while(i == -1 && errno == EINTR); |
476 |
|
|
477 |
if( (rv= poll(fds, 1, 1000)) > 0) { |
if(rv > 0) { |
478 |
|
|
479 |
pthread_mutex_lock(&Run.mutex_fd); |
pthread_mutex_lock(&Run.mutex_fd); |
480 |
|
|
484 |
|
|
485 |
if(stopped) { |
if(stopped) { |
486 |
log("http server: service stopped\n"); |
log("http server: service stopped\n"); |
487 |
} else if(errno == EINTR) { |
} else { |
|
goto again; |
|
|
} else { |
|
488 |
log("http server: cannot accept connection -- %s\n", STRERROR); |
log("http server: cannot accept connection -- %s\n", STRERROR); |
489 |
} |
} |
490 |
|
|
502 |
|
|
503 |
} else { |
} else { |
504 |
|
|
|
if(rv < 0) |
|
|
log("http server: cannot poll server socket -- %s\n", STRERROR); |
|
|
|
|
505 |
/* in the case that timeout or error occured, return NULL to allow |
/* in the case that timeout or error occured, return NULL to allow |
506 |
* the caller handle various states (such as stopped) which can |
* the caller handle various states (such as stopped) which can |
507 |
* occure in the meantime */ |
* occure in the meantime */ |