diff --git a/src/core/main.c b/src/core/main.c index f270b8f..4c9a172 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -144,8 +144,6 @@ int main_loop() hub_set_variables(hub, &acl); - break; - hub_event_loop(hub); hub_free_variables(hub); diff --git a/src/network/network.c b/src/network/network.c index 5602821..ddb541b 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -83,8 +83,7 @@ size_t net_get_max_sockets() return 1024; #else #ifdef WIN32 - LOG_WARN("Windows system, limited to 4096 connections."); - return 4096; + return FD_SETSIZE; #else LOG_WARN("System does not have getrlimit(): constrained to 1024 sockets"); return 1024; @@ -650,12 +649,16 @@ const char* net_get_local_address(int fd) if (getsockname(fd, (struct sockaddr*) name, &namelen) != -1) { +#ifndef WINSOCK int af = storage.ss_family; if (af == AF_INET6) { net_address_to_string(af, (void*) &name6->sin6_addr, address, INET6_ADDRSTRLEN); } else +#else + int af = AF_INET; +#endif { net_address_to_string(af, (void*) &name4->sin_addr, address, INET6_ADDRSTRLEN); } diff --git a/src/network/select.c b/src/network/select.c index bd57cc6..1a0ef28 100644 --- a/src/network/select.c +++ b/src/network/select.c @@ -35,6 +35,7 @@ struct net_backend_select struct net_connection_select** conns; fd_set rfds; fd_set wfds; + fd_set xfds; int maxfd; struct net_backend_common* common; }; @@ -58,6 +59,7 @@ int net_backend_poll_select(struct net_backend* data, int ms) FD_ZERO(&backend->rfds); FD_ZERO(&backend->wfds); + FD_ZERO(&backend->xfds); backend->maxfd = -1; for (n = 0, found = 0; found < backend->common->num && n < backend->common->max; n++) @@ -73,10 +75,14 @@ int net_backend_poll_select(struct net_backend* data, int ms) } backend->maxfd++; - res = select(backend->maxfd, &backend->rfds, &backend->wfds, 0, &tval); - - if (res == -1 && errno == EINTR) + res = select(backend->maxfd, &backend->rfds, &backend->wfds, &backend->xfds, &tval); + if (res == -1) + { + printf("Error: %d\n", net_error()); + } + if (res == -1 && net_error() == EINTR) return 0; + return res; } @@ -122,11 +128,13 @@ void net_con_backend_add_select(struct net_backend* data, struct net_connection* { struct net_backend_select* backend = (struct net_backend_select*) data; backend->conns[con->sd] = (struct net_connection_select*) con; + con->flags |= (events & (NET_EVENT_READ | NET_EVENT_WRITE)); } + void net_con_backend_mod_select(struct net_backend* data, struct net_connection* con, int events) { - con->flags |= (events & (NET_EVENT_READ | NET_EVENT_WRITE));; + con->flags |= (events & (NET_EVENT_READ | NET_EVENT_WRITE)); } void net_con_backend_del_select(struct net_backend* data, struct net_connection* con) diff --git a/src/system.h b/src/system.h index 38cb5ef..a909fd0 100644 --- a/src/system.h +++ b/src/system.h @@ -37,6 +37,9 @@ #endif #ifdef WINSOCK +#ifndef FD_SETSIZE +#define FD_SETSIZE 4096 +#endif #include #include #else