diff options
author | 2012-04-08 16:29:28 -0400 | |
---|---|---|
committer | 2012-04-08 16:29:28 -0400 | |
commit | 340febaf99f96c3c386392fa9957029b2f191b46 (patch) | |
tree | f33a008b46bba782f5b27ac9c2777a145ef1e759 /src/c | |
parent | b4fdf677c13d1d718640c22b94989d8bb516bd6f (diff) |
Optimize code from last changeset a bit
Diffstat (limited to 'src/c')
-rw-r--r-- | src/c/urweb.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 9f318c95..54ca5927 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -229,17 +229,18 @@ static int pruning_thread_initialized = 0; static client *find_client(unsigned id) { client *c; + int i_am_pruner = pruning_thread_initialized && pthread_equal(pruning_thread, pthread_self()); - if (!pruning_thread_initialized || !pthread_equal(pruning_thread, pthread_self())) pthread_mutex_lock(&clients_mutex); + if (!i_am_pruner) pthread_mutex_lock(&clients_mutex); if (id >= n_clients) { - if (!pruning_thread_initialized || !pthread_equal(pruning_thread, pthread_self())) pthread_mutex_unlock(&clients_mutex); + if (!i_am_pruner) pthread_mutex_unlock(&clients_mutex); return NULL; } c = clients[id]; - if (!pruning_thread_initialized || !pthread_equal(pruning_thread, pthread_self())) pthread_mutex_unlock(&clients_mutex); + if (!i_am_pruner) pthread_mutex_unlock(&clients_mutex); return c; } |