Hide things not appropriate behind is_backend
authorJens Axboe <axboe@kernel.dk>
Fri, 30 Sep 2011 00:00:35 +0000 (18:00 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 30 Sep 2011 00:00:35 +0000 (18:00 -0600)
Also add explicit command to exit the server, FIO_QUIT.

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

diff --git a/fio.c b/fio.c
index 8c844af..5e4d0e6 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -137,7 +137,9 @@ static void *disk_thread_main(void *data)
                if (!threads)
                        break;
                update_io_ticks();
-               print_thread_status();
+
+               if (!is_backend)
+                       print_thread_status();
        }
 
        return NULL;
@@ -1698,8 +1700,6 @@ int exec_run(void)
        if (!thread_number)
                return 0;
 
-       printf("%d threads\n", thread_number);
-
        if (write_bw_log) {
                setup_log(&agg_io_log[DDIR_READ]);
                setup_log(&agg_io_log[DDIR_WRITE]);
diff --git a/fio.h b/fio.h
index 49ddd92..d36ee16 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -650,6 +650,7 @@ extern int fio_gtod_cpu;
 extern enum fio_cs fio_clock_source;
 extern int warnings_fatal;
 extern int terse_version;
+extern int is_backend;
 
 extern struct thread_data *threads;
 
diff --git a/init.c b/init.c
index 5d57091..ce16450 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1317,7 +1317,7 @@ static int parse_cmd_line(int argc, char *argv[])
                exit(exit_val);
 
        if (is_backend)
-               fio_server();
+               return fio_server();
 
        if (td) {
                if (!ret)
@@ -1367,6 +1367,8 @@ int parse_options(int argc, char *argv[])
                        return 0;
                if (exec_profile)
                        return 0;
+               if (is_backend)
+                       return 0;
 
                log_err("No jobs(s) defined\n\n");
                usage(argv[0]);
index bd49b9c..541216c 100644 (file)
--- a/server.c
+++ b/server.c
@@ -25,23 +25,26 @@ static int accept_loop(int listen_sk)
 {
        struct sockaddr addr;
        unsigned int len = sizeof(addr);
-       int sk;
+       int sk, do_exit = 0;
 
 again:
        sk = accept(listen_sk, &addr, &len);
-       printf("got a hit\n");
        if (sk < 0) {
                log_err("fio: accept failed\n");
                return -1;
        }
 
        /* read forever */
-       for (;;) {
+       while (!do_exit) {
                char buf[131072];
                int ret;
 
                ret = recv(sk, buf, 4096, 0);
                if (ret > 0) {
+                       if (!strncmp("FIO_QUIT", buf, 8)) {
+                               do_exit = 1;
+                               break;
+                       }
                        parse_jobs_ini(buf, 1, 0);
                        exec_run();
                        reset_fio_state();
@@ -54,8 +57,11 @@ again:
        }
 
        close(sk);
-       printf("closed\n");
-       goto again;
+
+       if (!do_exit)
+               goto again;
+
+       return 0;
 }
 
 int fio_server(void)