sg engine: fix old comment
[fio.git] / engines / net.c
index 2e136f3dc104007522f67142deafdad3eee12925..66f1e607ed7f258e6b804ae4471fc23fa3e21c19 100644 (file)
@@ -1,5 +1,8 @@
 /*
- * Transfer data over the net.
+ * net engine
+ *
+ * IO engine that reads/writes to/from sockets.
+ *
  */
 #include <stdio.h>
 #include <stdlib.h>
@@ -58,7 +61,7 @@ static int fio_netio_queue(struct thread_data *td, struct io_u *io_u)
                 * if we are going to write more, set MSG_MORE
                 */
                if (td->this_io_bytes[DDIR_WRITE] + io_u->xfer_buflen <
-                   td->io_size)
+                   td->o.size)
                        flags = MSG_MORE;
 
                ret = send(f->fd, io_u->xfer_buf, io_u->xfer_buflen, flags);
@@ -108,7 +111,7 @@ static int fio_netio_accept(struct thread_data *td, struct fio_file *f)
        struct pollfd pfd;
        int ret;
 
-       fprintf(f_out, "fio: waiting for connection\n");
+       log_info("fio: waiting for connection\n");
 
        /*
         * Accept loop. poll for incoming events, accept them. Repeat until we
@@ -221,26 +224,20 @@ static int fio_netio_init(struct thread_data *td)
 {
        struct netio_data *nd = td->io_ops->data;
        unsigned short port;
-       struct fio_file *f;
        char host[64], buf[128];
        char *sep;
-       int ret, i;
-
-       if (!td->total_file_size) {
-               log_err("fio: need size= set\n");
-               return 1;
-       }
+       int ret;
 
        if (td_rw(td)) {
                log_err("fio: network connections must be read OR write\n");
                return 1;
        }
 
-       strcpy(buf, td->filename);
+       strcpy(buf, td->o.filename);
 
-       sep = strchr(buf, ':');
+       sep = strchr(buf, '/');
        if (!sep) {
-               log_err("fio: bad network host:port <<%s>>\n", td->filename);
+               log_err("fio: bad network host/port <<%s>>\n", td->o.filename);
                return 1;
        }
 
@@ -257,18 +254,7 @@ static int fio_netio_init(struct thread_data *td)
                ret = fio_netio_setup_connect(td, host, port);
        }
 
-       if (ret)
-               return ret;
-
-       td->io_size = td->total_file_size;
-       td->total_io_size = td->io_size;
-
-       for_each_file(td, f, i) {
-               f->file_size = td->total_file_size / td->nr_files;
-               f->real_file_size = f->file_size;
-       }
-
-       return 0;
+       return ret;
 }
 
 static void fio_netio_cleanup(struct thread_data *td)
@@ -283,11 +269,21 @@ static void fio_netio_cleanup(struct thread_data *td)
 
 static int fio_netio_setup(struct thread_data *td)
 {
-       struct netio_data *nd = malloc(sizeof(*nd));
+       struct netio_data *nd;
+       struct fio_file *f;
+       unsigned int i;
+
+       if (!td->io_ops->data) {
+               nd = malloc(sizeof(*nd));;
+
+               memset(nd, 0, sizeof(*nd));
+               nd->listenfd = -1;
+               td->io_ops->data = nd;
+
+               for_each_file(td, f, i)
+                       f->real_file_size = -1ULL;
+       }
 
-       memset(nd, 0, sizeof(*nd));
-       nd->listenfd = -1;
-       td->io_ops->data = nd;
        return 0;
 }