White space spring cleaning
[fio.git] / server.c
index d5733c4e05901a4f720e07e217320486d24e4138..664bb556071236022dddfed762a3f18af1b290ec 100644 (file)
--- a/server.c
+++ b/server.c
@@ -276,7 +276,7 @@ struct fio_net_cmd *fio_net_recv_cmd(int sk)
                                struct cmd_text_pdu *pdu = (struct cmd_text_pdu *) cmdret->payload;
                                char *buf = (char *) pdu->buf;
 
-                               buf[pdu->buf_len ] = '\0';
+                               buf[pdu->buf_len] = '\0';
                        } else if (cmdret->opcode == FIO_NET_CMD_JOB) {
                                struct cmd_job_pdu *pdu = (struct cmd_job_pdu *) cmdret->payload;
                                char *buf = (char *) pdu->buf;
@@ -392,7 +392,7 @@ int fio_net_send_quit(int sk)
 {
        dprint(FD_NET, "server: sending quit\n");
 
-       return fio_net_send_simple_cmd(server_fd, FIO_NET_CMD_QUIT, 0, NULL);
+       return fio_net_send_simple_cmd(sk, FIO_NET_CMD_QUIT, 0, NULL);
 }
 
 int fio_net_send_stop(int sk, int error, int signal)
@@ -403,7 +403,7 @@ int fio_net_send_stop(int sk, int error, int signal)
 
        epdu.error = __cpu_to_le32(error);
        epdu.signal = __cpu_to_le32(signal);
-       return fio_net_send_cmd(server_fd, FIO_NET_CMD_STOP, &epdu, sizeof(epdu), 0);
+       return fio_net_send_cmd(sk, FIO_NET_CMD_STOP, &epdu, sizeof(epdu), 0);
 }
 
 static void fio_server_add_fork_item(pid_t pid, struct flist_head *list)
@@ -467,7 +467,7 @@ static void fio_server_fork_item_done(struct fio_fork_item *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;
@@ -484,12 +484,12 @@ static void fio_server_check_fork_items(struct flist_head *list, int bla)
 
 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)
 {
-       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)
@@ -663,7 +663,7 @@ static int handle_command(struct fio_net_cmd *cmd)
                ret = handle_run_cmd(cmd);
                break;
        default:
-               log_err("fio: unknown opcode: %s\n",fio_server_op(cmd->opcode));
+               log_err("fio: unknown opcode: %s\n", fio_server_op(cmd->opcode));
                ret = 1;
        }
 
@@ -688,7 +688,12 @@ static int handle_connection(int sk)
 
                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;
@@ -752,7 +757,12 @@ static int accept_loop(int listen_sk)
                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;
@@ -1016,7 +1026,7 @@ static int fio_send_cmd_ext_pdu(int sk, uint16_t opcode, const void *buf,
        cmd.flags = __cpu_to_le32(flags);
        fio_net_cmd_crc_pdu(&cmd, buf);
 
-       return fio_sendv_data(server_fd, iov, 2);
+       return fio_sendv_data(sk, iov, 2);
 }
 
 int fio_send_iolog(struct thread_data *td, struct io_log *log, const char *name)
@@ -1502,7 +1512,7 @@ int fio_start_server(char *pidfile)
 
 #if defined(WIN32)
        WSADATA wsd;
-       WSAStartup(MAKEWORD(2,2), &wsd);
+       WSAStartup(MAKEWORD(2, 2), &wsd);
 #endif
 
        if (!pidfile)