Remember to close sockets on error
[fio.git] / engines / net.c
index faa08d5f6741b10641c36f12de933f88406846fe..d6821a4092e7898aa0fea956a6069931fde3a8b2 100644 (file)
@@ -389,6 +389,7 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f)
 
                if (connect(f->fd, (struct sockaddr *) &nd->addr, len) < 0) {
                        td_verror(td, errno, "connect");
+                       close(f->fd);
                        return 1;
                }
        } else {
@@ -399,6 +400,7 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f)
 
                if (connect(f->fd, (struct sockaddr *) addr, len) < 0) {
                        td_verror(td, errno, "connect");
+                       close(f->fd);
                        return 1;
                }
        }
@@ -543,6 +545,7 @@ static int fio_netio_setup_listen_unix(struct thread_data *td, const char *path)
 
        if (bind(fd, (struct sockaddr *) addr, len) < 0) {
                log_err("fio: bind: %s\n", strerror(errno));
+               close(fd);
                return -1;
        }