| 566 |
{ |
{ |
| 567 |
log_error("setsockopt SO_REUSEADDR error (%d)\n", errno); |
log_error("setsockopt SO_REUSEADDR error (%d)\n", errno); |
| 568 |
} |
} |
| 569 |
|
#if defined(SO_REUSEPORT) |
| 570 |
if (setsockopt(socket_server[i], SOL_SOCKET, SO_REUSEPORT, &flags_server[i], sizeof(flags_server[i])) < 0) |
if (setsockopt(socket_server[i], SOL_SOCKET, SO_REUSEPORT, &flags_server[i], sizeof(flags_server[i])) < 0) |
| 571 |
{ |
{ |
| 572 |
log_error("setsockopt SO_REUSEPORT error (%d)\n", errno); |
log_error("setsockopt SO_REUSEPORT error (%d)\n", errno); |
| 573 |
} |
} |
| 574 |
|
#endif |
| 575 |
|
|
| 576 |
if (bind(socket_server[i], (struct sockaddr *)&sin, sizeof(sin)) < 0) |
if (bind(socket_server[i], (struct sockaddr *)&sin, sizeof(sin)) < 0) |
| 577 |
{ |
{ |
| 641 |
{ |
{ |
| 642 |
SYS_child_exit = 0; |
SYS_child_exit = 0; |
| 643 |
|
|
| 644 |
pid = waitpid(-1, NULL, WNOHANG); |
pid = waitpid(-1, &ret, WNOHANG); |
| 645 |
if (pid > 0) |
if (pid > 0) |
| 646 |
{ |
{ |
| 647 |
SYS_child_exit = 1; // Retry waitid |
SYS_child_exit = 1; // Retry waitid |
|
|
|
| 648 |
SYS_child_process_count--; |
SYS_child_process_count--; |
| 649 |
log_common("Child process (%d) exited\n", pid); |
|
| 650 |
|
if (WIFEXITED(ret)) |
| 651 |
|
{ |
| 652 |
|
log_common("Child process (%d) exited, status=%d\n", pid, WEXITSTATUS(ret)); |
| 653 |
|
} |
| 654 |
|
else if (WIFSIGNALED(ret)) |
| 655 |
|
{ |
| 656 |
|
log_common("Child process (%d) is killed, status=%d\n", pid, WTERMSIG(ret)); |
| 657 |
|
} |
| 658 |
|
else |
| 659 |
|
{ |
| 660 |
|
log_common("Child process (%d) exited abnormally, status=%d\n", pid, ret); |
| 661 |
|
} |
| 662 |
|
|
| 663 |
if (pid != section_list_loader_pid) |
if (pid != section_list_loader_pid) |
| 664 |
{ |
{ |
| 862 |
while (!SYS_server_exit) // Accept all incoming connections until error |
while (!SYS_server_exit) // Accept all incoming connections until error |
| 863 |
{ |
{ |
| 864 |
addrlen = sizeof(sin); |
addrlen = sizeof(sin); |
| 865 |
socket_client = accept(socket_server[SSH_v2], (struct sockaddr *)&sin, &addrlen); |
socket_client = accept(socket_server[SSH_v2], (struct sockaddr *)&sin, (socklen_t *)&addrlen); |
| 866 |
if (socket_client < 0) |
if (socket_client < 0) |
| 867 |
{ |
{ |
| 868 |
if (errno == EAGAIN || errno == EWOULDBLOCK) |
if (errno == EAGAIN || errno == EWOULDBLOCK) |