Hi

This removes an unneeded if on a hot path.

- Lauri
>From 233611cba80afcfa5160309eb2150feb1cca768d Mon Sep 17 00:00:00 2001
From: Lauri Kasanen <[email protected]>
Date: Mon, 7 May 2012 15:54:33 +0300
Subject: [PATCH] sched: Remove unneeded active_connections check

register is only called after the connection is accepted, so we know there were 
free slots.

Signed-off-by: Lauri Kasanen <[email protected]>
---
 src/mk_scheduler.c |   36 ++++++++++++++++--------------------
 1 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/src/mk_scheduler.c b/src/mk_scheduler.c
index 48e0f5e..8d28277 100644
--- a/src/mk_scheduler.c
+++ b/src/mk_scheduler.c
@@ -118,31 +118,27 @@ int mk_sched_register_client(int remote_fd, struct 
sched_list_node *sched)
     int ret;
     struct sched_connection *sched_conn;
     struct mk_list *av_queue = &sched->av_queue;
-    unsigned long long active_connections;
 
-    active_connections = sched->accepted_connections - 
sched->closed_connections;
-    if (active_connections < config->worker_capacity) {
-        sched_conn = mk_list_entry_first(av_queue, struct sched_connection, 
_head);
+    sched_conn = mk_list_entry_first(av_queue, struct sched_connection, _head);
 
-        /* Before to continue, we need to run plugin stage 10 */
-        ret = mk_plugin_stage_run(MK_PLUGIN_STAGE_10,
-                                  remote_fd,
-                                  sched_conn, NULL, NULL);
+    /* Before to continue, we need to run plugin stage 10 */
+    ret = mk_plugin_stage_run(MK_PLUGIN_STAGE_10,
+                              remote_fd,
+                              sched_conn, NULL, NULL);
 
-        /* Close connection, otherwise continue */
-        if (ret == MK_PLUGIN_RET_CLOSE_CONX) {
-            mk_conn_close(remote_fd);
-            return MK_PLUGIN_RET_CLOSE_CONX;
-        }
+    /* Close connection, otherwise continue */
+    if (ret == MK_PLUGIN_RET_CLOSE_CONX) {
+        mk_conn_close(remote_fd);
+        return MK_PLUGIN_RET_CLOSE_CONX;
+    }
 
-        mk_list_del(&sched_conn->_head);
-        mk_list_add(&sched_conn->_head, &sched->busy_queue);
+    mk_list_del(&sched_conn->_head);
+    mk_list_add(&sched_conn->_head, &sched->busy_queue);
 
-        /* Socket and status */
-        sched_conn->socket = remote_fd;
-        sched_conn->status = MK_SCHEDULER_CONN_PENDING;
-        sched_conn->arrive_time = log_current_utime;
-    }
+    /* Socket and status */
+    sched_conn->socket = remote_fd;
+    sched_conn->status = MK_SCHEDULER_CONN_PENDING;
+    sched_conn->arrive_time = log_current_utime;
 
 
     return -1;
-- 
1.7.2.1

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to