Permalink
Browse files

Gets rid of a couple of properties of the cherokee_thread_t class. It

was not necessary to keep track of the length of the connection lists.
  • Loading branch information...
1 parent 594981e commit 22b70164c89d07f5f39787f39462ca889596bf3c @alobbs alobbs committed Dec 30, 2011
Showing with 24 additions and 22 deletions.
  1. +1 −1 cherokee/connection_info.c
  2. +7 −3 cherokee/server.c
  3. +16 −16 cherokee/thread.c
  4. +0 −2 cherokee/thread.h
@@ -186,7 +186,7 @@ cherokee_connection_info_list_thread (cherokee_list_t *list,
/* Does it has active connections?
*/
- if (thread->active_list_num <= 0)
+ if (cherokee_list_empty (&thread->active_list))
return ret_not_found;
/* If it tries to adquire the thread ownership of the thread
View
@@ -1827,21 +1827,25 @@ cherokee_server_get_conns_num (cherokee_server_t *srv, cuint_t *num)
ret_t
cherokee_server_get_active_conns (cherokee_server_t *srv, cuint_t *num)
{
+ size_t len;
cuint_t active = 0;
cherokee_list_t *thread;
/* Active connections number
*/
list_for_each (thread, &srv->thread_list) {
- active += THREAD(thread)->active_list_num;
+ len = 0;
+ cherokee_list_get_len (&THREAD(thread)->active_list, &len);
+ active += len;
}
- active += srv->main_thread->active_list_num;
+ len = 0;
+ cherokee_list_get_len (&srv->main_thread->active_list, &len);
+ active += len;
/* Return out parameters
*/
*num = active;
-
return ret_ok;
}
View
@@ -161,8 +161,6 @@ cherokee_thread_new (cherokee_thread_t **thd,
n->conns_max = conns_max;
n->conns_keepalive_max = keepalive_max;
- n->active_list_num = 0;
- n->polling_list_num = 0;
n->reuse_list_num = 0;
n->fastcgi_servers = NULL;
@@ -289,28 +287,26 @@ static void
add_connection (cherokee_thread_t *thd, cherokee_connection_t *conn)
{
cherokee_list_add_tail (LIST(conn), &thd->active_list);
- thd->active_list_num++;
}
static void
add_connection_polling (cherokee_thread_t *thd, cherokee_connection_t *conn)
{
cherokee_list_add_tail (LIST(conn), &thd->polling_list);
- thd->polling_list_num++;
}
static void
del_connection (cherokee_thread_t *thd, cherokee_connection_t *conn)
{
+ UNUSED (thd);
cherokee_list_del (LIST(conn));
- thd->active_list_num--;
}
static void
del_connection_polling (cherokee_thread_t *thd, cherokee_connection_t *conn)
{
+ UNUSED (thd);
cherokee_list_del (LIST(conn));
- thd->polling_list_num--;
}
@@ -1718,8 +1714,8 @@ cherokee_thread_step_SINGLE_THREAD (cherokee_thread_t *thd)
/* Graceful restart
*/
if (unlikely (srv->wanna_reinit)) {
- if ((thd->active_list_num == 0) &&
- (thd->polling_list_num == 0))
+ if (cherokee_list_empty (&thd->active_list) &&
+ cherokee_list_empty (&thd->polling_list))
{
thd->exit = true;
return ret_eof;
@@ -1793,8 +1789,8 @@ watch_accept_MULTI_THREAD (cherokee_thread_t *thd,
/* Shortcut: don't waste time on watch() */
if (unlikely ((srv->wanna_exit) ||
((srv->wanna_reinit) &&
- (thd->active_list_num == 0) &&
- (thd->polling_list_num == 0))))
+ (cherokee_list_empty (&thd->active_list)) &&
+ (cherokee_list_empty (&thd->polling_list)))))
{
goto out;
}
@@ -1903,8 +1899,8 @@ cherokee_thread_step_MULTI_THREAD (cherokee_thread_t *thd,
if (unlikely (srv->wanna_reinit))
{
- if ((thd->active_list_num == 0) &&
- (thd->polling_list_num == 0))
+ if ((cherokee_list_empty (&thd->active_list)) &&
+ (cherokee_list_empty (&thd->polling_list)))
{
thd->exit = true;
return ret_eof;
@@ -1924,9 +1920,9 @@ cherokee_thread_step_MULTI_THREAD (cherokee_thread_t *thd,
*/
can_block = ((dont_block == false) &&
(thd->exit == false) &&
- (thd->active_list_num == 0) &&
- (thd->polling_list_num == 0) &&
- (thd->limiter.conns_num == 0));
+ (thd->limiter.conns_num == 0) &&
+ (cherokee_list_empty (&thd->active_list)) &&
+ (cherokee_list_empty (&thd->polling_list)));
watch_accept_MULTI_THREAD (thd, can_block, fdwatch_msecs);
@@ -1962,7 +1958,11 @@ cherokee_thread_step_MULTI_THREAD (cherokee_thread_t *thd,
int
cherokee_thread_connection_num (cherokee_thread_t *thd)
{
- return thd->active_list_num;
+ size_t len = 0;
+
+ cherokee_list_get_len (&thd->active_list, &len);
+
+ return len;
}
View
@@ -74,9 +74,7 @@ typedef struct {
cuint_t conns_max; /* max opened conns */
cuint_t conns_keepalive_max; /* max opened conns */
- int active_list_num; /* active connections */
cherokee_list_t active_list;
- int polling_list_num; /* polling connections */
cherokee_list_t polling_list;
cherokee_list_t reuse_list;
int reuse_list_num; /* reusable connections objs */

0 comments on commit 22b7016

Please sign in to comment.