log: don't use vsyslog
[fio.git] / server.c
index 4c12f65c8f1981aaad46ff26dd6944525689d638..37ba5939b32c0b17371079261220f474eb53c02f 100644 (file)
--- a/server.c
+++ b/server.c
@@ -13,6 +13,7 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <syslog.h>
+#include <signal.h>
 
 #include "fio.h"
 #include "server.h"
@@ -323,6 +324,9 @@ static int handle_probe_cmd(struct fio_net_cmd *cmd)
 
        memset(&probe, 0, sizeof(probe));
        gethostname((char *) probe.hostname, sizeof(probe.hostname));
+#ifdef FIO_BIG_ENDIAN
+       probe.bigendian = 1;
+#endif
        probe.fio_major = FIO_MAJOR;
        probe.fio_minor = FIO_MINOR;
        probe.fio_patch = FIO_PATCH;
@@ -395,8 +399,8 @@ void fio_server_idle_loop(void)
 
 static int accept_loop(int listen_sk)
 {
-       struct sockaddr addr;
-       unsigned int len = sizeof(addr);
+       struct sockaddr_in addr;
+       socklen_t len = sizeof(addr);
        struct pollfd pfd;
        int ret, sk, flags, exitval = 0;
 
@@ -425,13 +429,13 @@ again:
        if (exit_backend)
                goto out;
 
-       sk = accept(listen_sk, &addr, &len);
+       sk = accept(listen_sk, (struct sockaddr *) &addr, &len);
        if (sk < 0) {
                log_err("fio: accept: %s\n", strerror(errno));
                return -1;
        }
 
-       dprint(FD_NET, "server got a connection\n");
+       dprint(FD_NET, "server: connect from %s\n", inet_ntoa(addr.sin_addr));
 
        server_fd = sk;
 
@@ -452,7 +456,7 @@ int fio_server_text_output(const char *buf, unsigned int len)
        if (server_fd != -1)
                return fio_net_send_cmd(server_fd, FIO_NET_CMD_TEXT, buf, len);
 
-       return 0;
+       return fwrite(buf, len, 1, f_err);
 }
 
 static void convert_io_stat(struct io_stat *dst, struct io_stat *src)
@@ -627,7 +631,7 @@ static int fio_server(void)
 {
        struct sockaddr_in saddr_in;
        struct sockaddr addr;
-       unsigned int len;
+       socklen_t len;
        int sk, opt, ret;
 
        dprint(FD_NET, "starting server\n");
@@ -644,7 +648,7 @@ static int fio_server(void)
                return -1;
        }
 #ifdef SO_REUSEPORT
-       if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) < 0) {
+       if (setsockopt(sk, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) < 0) {
                log_err("fio: setsockopt: %s\n", strerror(errno));
                return -1;
        }