| 38 |
#include <sys/wait.h> |
#include <sys/wait.h> |
| 39 |
#include <sys/epoll.h> |
#include <sys/epoll.h> |
| 40 |
#include <arpa/inet.h> |
#include <arpa/inet.h> |
| 41 |
|
#include <netinet/in.h> |
| 42 |
#include <systemd/sd-daemon.h> |
#include <systemd/sd-daemon.h> |
|
#include <libssh/libssh.h> |
|
|
#include <libssh/server.h> |
|
| 43 |
|
|
| 44 |
struct process_sockaddr_t |
struct process_sockaddr_t |
| 45 |
{ |
{ |
| 48 |
}; |
}; |
| 49 |
typedef struct process_sockaddr_t PROCESS_SOCKADDR; |
typedef struct process_sockaddr_t PROCESS_SOCKADDR; |
| 50 |
|
|
| 51 |
static PROCESS_SOCKADDR process_sockaddr_pool[MAX_CLIENTS_LIMIT]; |
static PROCESS_SOCKADDR process_sockaddr_pool[MAX_CLIENT_LIMIT]; |
| 52 |
|
|
| 53 |
int net_server(const char *hostaddr, in_port_t port) |
int net_server(const char *hostaddr, in_port_t port) |
| 54 |
{ |
{ |
| 106 |
port_server = ntohs(sin.sin_port); |
port_server = ntohs(sin.sin_port); |
| 107 |
namelen = sizeof(sin); |
namelen = sizeof(sin); |
| 108 |
|
|
| 109 |
log_std("Listening at %s:%d\n", hostaddr_server, port_server); |
log_common("Listening at %s:%d\n", hostaddr_server, port_server); |
| 110 |
|
|
| 111 |
epollfd = epoll_create1(0); |
epollfd = epoll_create1(0); |
| 112 |
if (epollfd < 0) |
if (epollfd < 0) |
| 155 |
SYS_child_exit = 1; // Retry waitid |
SYS_child_exit = 1; // Retry waitid |
| 156 |
|
|
| 157 |
SYS_child_process_count--; |
SYS_child_process_count--; |
| 158 |
log_std("Child process (%d) exited\n", siginfo.si_pid); |
log_common("Child process (%d) exited\n", siginfo.si_pid); |
| 159 |
|
|
| 160 |
if (siginfo.si_pid != section_list_loader_pid) |
if (siginfo.si_pid != section_list_loader_pid) |
| 161 |
{ |
{ |
| 187 |
|
|
| 188 |
if (SYS_server_exit && !SYS_child_exit && SYS_child_process_count > 0) |
if (SYS_server_exit && !SYS_child_exit && SYS_child_process_count > 0) |
| 189 |
{ |
{ |
| 190 |
log_std("Notify %d child process to exit\n", SYS_child_process_count); |
log_common("Notify %d child process to exit\n", SYS_child_process_count); |
| 191 |
if (kill(0, SIGTERM) < 0) |
if (kill(0, SIGTERM) < 0) |
| 192 |
{ |
{ |
| 193 |
log_error("Send SIGTERM signal failed (%d)\n", errno); |
log_error("Send SIGTERM signal failed (%d)\n", errno); |
| 228 |
p_bbs_menu = p_bbs_menu_new; |
p_bbs_menu = p_bbs_menu_new; |
| 229 |
p_bbs_menu_new = NULL; |
p_bbs_menu_new = NULL; |
| 230 |
|
|
| 231 |
log_std("Reload menu successfully\n"); |
log_common("Reload menu successfully\n"); |
| 232 |
} |
} |
| 233 |
|
|
| 234 |
sd_notify(0, "READY=1"); |
sd_notify(0, "READY=1"); |
| 247 |
} |
} |
| 248 |
} |
} |
| 249 |
|
|
| 250 |
log_std("Reload data files successfully\n"); |
log_common("Reload data files successfully\n"); |
| 251 |
sd_notify(0, "READY=1"); |
sd_notify(0, "READY=1"); |
| 252 |
} |
} |
| 253 |
|
|
| 308 |
|
|
| 309 |
port_client = ntohs(sin.sin_port); |
port_client = ntohs(sin.sin_port); |
| 310 |
|
|
| 311 |
log_std("Accept connection from %s:%d\n", hostaddr_client, port_client); |
log_common("Accept connection from %s:%d\n", hostaddr_client, port_client); |
| 312 |
|
|
| 313 |
if (SYS_child_process_count - 1 < BBS_max_client) |
if (SYS_child_process_count - 1 < BBS_max_client) |
| 314 |
{ |
{ |