diff --git a/GNUmakefile b/GNUmakefile index 0496325..a7800ce 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -13,7 +13,7 @@ USE_SSL ?= NO USE_BIGENDIAN ?= AUTO BITS ?= AUTO SILENT ?= YES -LDLIBS += -levent +LDLIBS += -lev TERSE ?= NO STACK_PROTECT ?= NO diff --git a/src/core/hub.c b/src/core/hub.c index 84119b7..4b300c9 100644 --- a/src/core/hub.c +++ b/src/core/hub.c @@ -959,8 +959,6 @@ void hub_schedule_destroy_user(struct hub_info* hub, struct hub_user* user) post.ptr = user; event_queue_post(hub->queue, &post); - net_con_close(&user->net.connection); - if (user->id.sid) { sid_free(hub->users->sids, user->id.sid); @@ -976,20 +974,6 @@ void hub_disconnect_all(struct hub_info* hub) event_queue_post(hub->queue, &post); } - -void hub_schedule_destroy_all(struct hub_info* hub) -{ - struct hub_user* user = (struct hub_user*) list_get_first(hub->users->list); - while (user) - { - - hub_schedule_destroy_user(hub, user); - user = (struct hub_user*) list_get_next(hub->users->list); - } -} - - - void hub_event_loop(struct hub_info* hub) { int ret; @@ -1026,7 +1010,7 @@ void hub_disconnect_user(struct hub_info* hub, struct hub_user* user, int reason { struct event_data post; int need_notify = 0; - + /* is user already being disconnected ? */ if (user_is_disconnecting(user)) { @@ -1035,7 +1019,8 @@ void hub_disconnect_user(struct hub_info* hub, struct hub_user* user, int reason /* stop reading from user */ net_shutdown_r(user->net.connection.sd); - + net_con_close(&user->net.connection); + LOG_TRACE("hub_disconnect_user(), user=%p, reason=%d, state=%d", user, reason, user->state); need_notify = user_is_logged_in(user) && hub->status == hub_status_running; diff --git a/src/network/connection.c b/src/network/connection.c index 9fc7d03..951633b 100644 --- a/src/network/connection.c +++ b/src/network/connection.c @@ -140,7 +140,7 @@ void net_con_update(struct net_connection* con, int ev) if (events & EV_READ) net_con_flag_set(con, NET_WANT_READ); if (events & EV_WRITE) net_con_flag_set(con, NET_WANT_WRITE); - if (event_pending(&con->event, EV_READ | EV_WRITE, 0) == events) + if (con->sd == -1 || event_pending(&con->event, EV_READ | EV_WRITE, 0) == events) return; event_del(&con->event);