Fixes to shutdown...

This commit is contained in:
Jan Vidar Krey
2009-08-03 23:59:02 +02:00
parent fbe98d6011
commit eca0f931bd
10 changed files with 120 additions and 65 deletions

View File

@@ -107,7 +107,7 @@ void net_con_initialize(struct net_connection* con, int sd, struct ip_addr_encap
if (events & EV_WRITE) net_con_flag_set(con, NET_WANT_WRITE);
event_set(&con->event, con->sd, events | EV_PERSIST, net_con_event, con);
event_base_set(g_hub->evbase, &con->event);
event_base_set(net_get_evbase(), &con->event);
event_add(&con->event, 0);
net_set_nonblocking(sd, 1);
@@ -134,9 +134,12 @@ void net_con_update(struct net_connection* con, int events)
void net_con_close(struct net_connection* con)
{
if (!event_pending(&con->event, EV_READ | EV_WRITE, 0))
return;
event_del(&con->event);
if (event_pending(&con->event, EV_READ | EV_WRITE, 0))
{
event_del(&con->event);
}
net_con_clear_timeout(con);
net_close(con->sd);
con->sd = -1;
}
@@ -291,7 +294,7 @@ void net_con_set_timeout(struct net_connection* con, int seconds)
{
struct timeval timeout = { seconds, 0 };
evtimer_set(&con->timeout, net_con_event, con);
event_base_set(g_hub->evbase, &con->timeout);
event_base_set(net_get_evbase(), &con->timeout);
evtimer_add(&con->timeout, &timeout);
}