]> granicus.if.org Git - libevent/commitdiff
Avoid a resource leak on error in http client benchmark
authorNick Mathewson <nickm@torproject.org>
Mon, 25 Jun 2012 17:55:45 +0000 (13:55 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 25 Jun 2012 17:55:45 +0000 (13:55 -0400)
test/bench_httpclient.c

index 727abc67987cb167ba8008e73e6baf03ac536b5d..149b4fdcc118b1594c8ba59bd3b32fcd9693f4ea 100644 (file)
@@ -140,12 +140,15 @@ launch_request(void)
        sin.sin_port = htons(8080);
        if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
                return -1;
-       if (evutil_make_socket_nonblocking(sock) < 0)
+       if (evutil_make_socket_nonblocking(sock) < 0) {
+               evutil_closesocket(sock);
                return -1;
+       }
        frob_socket(sock);
        if (connect(sock, (struct sockaddr*)&sin, sizeof(sin)) < 0) {
                int e = errno;
                if (! EVUTIL_ERR_CONNECT_RETRIABLE(e)) {
+                       evutil_closesocket(sock);
                        return -1;
                }
        }