From dc90245ade772a42fee523b6dc1f733348095995 Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Sat, 25 Jul 2009 03:26:59 +0200 Subject: [PATCH] No need to store event mask in the user object since libevent already does it for us. --- src/user.c | 13 +++++-------- src/user.h | 3 --- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/user.c b/src/user.c index 1605950..16f8660 100644 --- a/src/user.c +++ b/src/user.c @@ -51,8 +51,7 @@ struct user* user_create(struct hub_info* hub, int sd) user->net.send_queue = hub_sendq_create(); user->net.recv_queue = hub_recvq_create(); - user->net.events = EV_READ; - event_set(&user->net.event, sd, user->net.events | EV_PERSIST, net_event, user); + event_set(&user->net.event, sd, EV_READ | EV_PERSIST, net_event, user); event_base_set(hub->evbase, &user->net.event); event_add(&user->net.event, 0); @@ -333,11 +332,10 @@ void user_net_io_want_write(struct user* user) #ifdef DEBUG_SENDQ hub_log(log_trace, "user_net_io_want_write: %s (pending: %d)", user_log_str(user), event_pending(&user->net.event, EV_READ | EV_WRITE, 0)); #endif - if (user->net.events == (EV_READ | EV_WRITE)) + if (event_pending(&user->net.event, EV_READ | EV_WRITE, 0) == (EV_READ | EV_WRITE)) return; - user->net.events = (EV_READ | EV_WRITE); event_del(&user->net.event); - event_set(&user->net.event, user->net.sd, user->net.events | EV_PERSIST, net_event, user); + event_set(&user->net.event, user->net.sd, EV_READ | EV_WRITE | EV_PERSIST, net_event, user); event_add(&user->net.event, 0); } @@ -346,11 +344,10 @@ void user_net_io_want_read(struct user* user) #ifdef DEBUG_SENDQ hub_log(log_trace, "user_net_io_want_read: %s (pending: %d)", user_log_str(user), event_pending(&user->net.event, EV_READ | EV_WRITE, 0)); #endif - if (user->net.events == EV_READ) + if (event_pending(&user->net.event, EV_READ | EV_WRITE, 0) == EV_READ) return; - user->net.events = EV_READ; event_del(&user->net.event); - event_set(&user->net.event, user->net.sd, user->net.events | EV_PERSIST, net_event, user); + event_set(&user->net.event, user->net.sd, EV_READ | EV_PERSIST, net_event, user); event_add(&user->net.event, 0); } diff --git a/src/user.h b/src/user.h index b5baf1a..ae15157 100644 --- a/src/user.h +++ b/src/user.h @@ -97,11 +97,8 @@ struct user_net_io int sd; /** socket descriptor */ struct event event; /** libevent struct for read/write events */ struct event timeout; /** timeout handling */ - int events; /** currently set events, used to reduce event_{add,del,set} calls */ - struct hub_recvq* recv_queue; struct hub_sendq* send_queue; - time_t tm_connected; /** time when user connected */ time_t tm_last_read; /** time the user last received something from the hub */ time_t tm_last_write; /** time the user last sent something to the hub */