Commit df5e997e authored by Sergey Lyubka's avatar Sergey Lyubka

ns_server_poll() waking up by ns_server_wakeup()

parent 0a3cb63c
......@@ -767,6 +767,7 @@ int ns_server_poll(struct ns_server *server, int milli) {
FD_ZERO(&read_set);
FD_ZERO(&write_set);
ns_add_to_set(server->listening_sock, &read_set, &max_fd);
ns_add_to_set(server->ctl[1], &read_set, &max_fd);
for (conn = server->active_connections; conn != NULL; conn = tmp_conn) {
tmp_conn = conn->next;
......@@ -797,6 +798,14 @@ int ns_server_poll(struct ns_server *server, int milli) {
}
}
// Read possible wakeup calls
if (server->ctl[1] != INVALID_SOCKET &&
FD_ISSET(server->ctl[1], &read_set)) {
unsigned char ch;
recv(server->ctl[1], &ch, 1, 0);
send(server->ctl[1], &ch, 1, 0);
}
for (conn = server->active_connections; conn != NULL; conn = tmp_conn) {
tmp_conn = conn->next;
if (FD_ISSET(conn->sock, &read_set)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment