From d84f89a5d8d75ea311c12a1ef89b7eea28c560fb Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 23 Feb 2010 12:21:13 +0100 Subject: [PATCH] Optimize client_set_state for active state Function client_set_state no longer calls session_active_clients to check whether active clients has reached zero - when the state that is being set for the client parameter is already known to be "active". --- src/client.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client.c b/src/client.c index 4c6c780..016d874 100644 --- a/src/client.c +++ b/src/client.c @@ -117,7 +117,9 @@ enum client_state client_get_state(struct client *cl) void client_set_state(struct client *cl, enum client_state st) { cl->state = st; - if (cl->session) + /* no need to check for all client being non-active if this one + already is. Note that session_active_clients also LOCKS session */ + if (!client_is_active(cl) && cl->session) { int no_active = session_active_clients(cl->session); if (no_active == 0) -- 1.7.10.4