net: fix leak of fd in bind() error path
[fio.git] / engines / net.c
index 110e158f114cbe210656476ff81af305d7d80248..d036a581811ac5b945ae074169b90f66f090142f 100644 (file)
@@ -1092,6 +1092,7 @@ static int fio_netio_setup_listen_inet(struct thread_data *td, short port)
        }
 
        if (bind(fd, saddr, len) < 0) {
+               close(fd);
                td_verror(td, errno, "bind");
                return 1;
        }
@@ -1196,6 +1197,7 @@ static int fio_netio_setup(struct thread_data *td)
        if (!td->files_index) {
                add_file(td, td->o.filename ?: "net", 0, 0);
                td->o.nr_files = td->o.nr_files ?: 1;
+               td->o.open_files++;
        }
 
        if (!td->io_ops->data) {