net engine: fix listenfd/pipe fd leaks
authorJens Axboe <jens.axboe@oracle.com>
Sun, 24 Jun 2007 19:28:39 +0000 (21:28 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Sun, 24 Jun 2007 19:28:39 +0000 (21:28 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
engines/net.c

index bc3946d588f4c389d448ca4c3c36cb1d4c1d0b84..4538a04d3d829dcf22dfa5f5ba6b5ed429dc96f0 100644 (file)
@@ -424,6 +424,13 @@ static void fio_netio_cleanup(struct thread_data *td)
        struct netio_data *nd = td->io_ops->data;
 
        if (nd) {
        struct netio_data *nd = td->io_ops->data;
 
        if (nd) {
+               if (nd->listenfd != -1)
+                       close(nd->listenfd);
+               if (nd->pipes[0] != -1)
+                       close(nd->pipes[0]);
+               if (nd->pipes[1] != -1)
+                       close(nd->pipes[1]);
+
                free(nd);
                td->io_ops->data = NULL;
        }
                free(nd);
                td->io_ops->data = NULL;
        }
@@ -438,6 +445,7 @@ static int fio_netio_setup(struct thread_data *td)
 
                memset(nd, 0, sizeof(*nd));
                nd->listenfd = -1;
 
                memset(nd, 0, sizeof(*nd));
                nd->listenfd = -1;
+               nd->pipes[0] = nd->pipes[1] = -1;
                td->io_ops->data = nd;
        }
 
                td->io_ops->data = nd;
        }