server: idle a bit more of we are not expecting work
authorJens Axboe <axboe@kernel.dk>
Fri, 23 Mar 2012 11:25:18 +0000 (12:25 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 23 Mar 2012 11:25:18 +0000 (12:25 +0100)
Don't wakeup every 100msec if we are not expecting an event
that wont already wakes up poll() automatically.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
server.c

index 5e0d322baeae1c8c4664f57f68ec9cbb23ff6d59..274497514484f36a4b22b730bc0127316c6dc16e 100644 (file)
--- a/server.c
+++ b/server.c
@@ -467,7 +467,7 @@ static void fio_server_fork_item_done(struct fio_fork_item *ffi)
        free(ffi);
 }
 
        free(ffi);
 }
 
-static void fio_server_check_fork_items(struct flist_head *list, int bla)
+static void fio_server_check_fork_items(struct flist_head *list)
 {
        struct flist_head *entry, *tmp;
        struct fio_fork_item *ffi;
 {
        struct flist_head *entry, *tmp;
        struct fio_fork_item *ffi;
@@ -484,12 +484,12 @@ static void fio_server_check_fork_items(struct flist_head *list, int bla)
 
 static void fio_server_check_jobs(void)
 {
 
 static void fio_server_check_jobs(void)
 {
-       fio_server_check_fork_items(&job_list, 0);
+       fio_server_check_fork_items(&job_list);
 }
 
 static void fio_server_check_conns(void)
 {
 }
 
 static void fio_server_check_conns(void)
 {
-       fio_server_check_fork_items(&conn_list, 1);
+       fio_server_check_fork_items(&conn_list);
 }
 
 static int handle_run_cmd(struct fio_net_cmd *cmd)
 }
 
 static int handle_run_cmd(struct fio_net_cmd *cmd)
@@ -688,7 +688,12 @@ static int handle_connection(int sk)
 
                ret = 0;
                do {
 
                ret = 0;
                do {
-                       ret = poll(&pfd, 1, 100);
+                       int timeout = 1000;
+
+                       if (!flist_empty(&job_list))
+                               timeout = 100;
+               
+                       ret = poll(&pfd, 1, timeout);
                        if (ret < 0) {
                                if (errno == EINTR)
                                        break;
                        if (ret < 0) {
                                if (errno == EINTR)
                                        break;
@@ -752,7 +757,12 @@ static int accept_loop(int listen_sk)
                pfd.fd = listen_sk;
                pfd.events = POLLIN;
                do {
                pfd.fd = listen_sk;
                pfd.events = POLLIN;
                do {
-                       ret = poll(&pfd, 1, 100);
+                       int timeout = 1000;
+
+                       if (!flist_empty(&conn_list))
+                               timeout = 100;
+
+                       ret = poll(&pfd, 1, timeout);
                        if (ret < 0) {
                                if (errno == EINTR)
                                        break;
                        if (ret < 0) {
                                if (errno == EINTR)
                                        break;