diff --git a/src/network/epoll.c b/src/network/epoll.c index bb9055e..0232a4d 100644 --- a/src/network/epoll.c +++ b/src/network/epoll.c @@ -114,6 +114,9 @@ int net_backend_process() return 0; } + g_backend->now = time(0); + timeout_queue_process(&g_backend->timeout_queue, g_backend->now); + for (n = 0; n < res; n++) { struct net_connection_epoll* con = (struct net_connection_epoll*) g_backend->events[n].data.ptr; @@ -232,6 +235,10 @@ void net_con_close(struct net_connection* con_) { LOG_WARN("epoll_ctl() delete failed."); } + + net_close(con->sd); + con->sd = -1; + net_con_print("DEL", con); net_cleanup_delayed_free(g_backend->cleaner, con_); } diff --git a/src/network/select.c b/src/network/select.c index 6b35f64..069cdad 100644 --- a/src/network/select.c +++ b/src/network/select.c @@ -117,6 +117,9 @@ int net_backend_process() return 0; } + g_backend->now = time(0); + timeout_queue_process(&g_backend->timeout_queue, g_backend->now); + for (n = 0, found = 0; found < res && n < (maxfd+1); n++) { struct net_connection_select* con = g_backend->conns[n]; @@ -197,6 +200,9 @@ void net_con_close(struct net_connection* con) net_con_clear_timeout(con); + net_close(con->sd); + con->sd = -1; + net_con_print("DEL", (struct net_connection_select*) con); net_cleanup_delayed_free(g_backend->cleaner, con); } diff --git a/src/util/timeout.c b/src/util/timeout.c index c728f31..e5c3760 100644 --- a/src/util/timeout.c +++ b/src/util/timeout.c @@ -63,7 +63,6 @@ size_t timeout_queue_process(struct timeout_queue* t, time_t now) while ((evt = t->events[pos % t->max])) { timeout_queue_remove(t, evt); - timeout_evt_reset(evt); evt->callback(evt); events++; } @@ -125,8 +124,7 @@ void timeout_queue_remove(struct timeout_queue* t, struct timeout_evt* evt) evt->prev->next = evt->next; evt->next->prev = evt->prev; } - evt->next = 0; - evt->prev = 0; + timeout_evt_reset(evt); } void timeout_queue_reschedule(struct timeout_queue* t, struct timeout_evt* evt, size_t seconds)