net: set runstate to SETTING_UP while waiting for a connection
authorJens Axboe <axboe@kernel.dk>
Thu, 29 Nov 2012 19:02:50 +0000 (20:02 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 29 Nov 2012 19:02:50 +0000 (20:02 +0100)
Otherwise the status print thinks it's running, and displays
bad stats.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/net.c

index 419508e47a5ec037a33c2c00781973820cbdc752..373821b2142bb8d3a7428179d4c4218ff05118e1 100644 (file)
@@ -475,24 +475,32 @@ static int fio_netio_accept(struct thread_data *td, struct fio_file *f)
        struct netio_data *nd = td->io_ops->data;
        struct netio_options *o = td->eo;
        fio_socklen_t socklen = sizeof(nd->addr);
+       int state;
 
        if (o->proto == FIO_TYPE_UDP) {
                f->fd = nd->listenfd;
                return 0;
        }
 
+       state = td->runstate;
+       td_set_runstate(td, TD_SETTING_UP);
+
        log_info("fio: waiting for connection\n");
 
        if (poll_wait(td, nd->listenfd, POLLIN) < 0)
-               return 1;
+               goto err;
 
        f->fd = accept(nd->listenfd, (struct sockaddr *) &nd->addr, &socklen);
        if (f->fd < 0) {
                td_verror(td, errno, "accept");
-               return 1;
+               goto err;
        }
 
+       td_set_runstate(td, state);
        return 0;
+err:
+       td_set_runstate(td, state);
+       return 1;
 }
 
 static int fio_netio_open_file(struct thread_data *td, struct fio_file *f)