sockets were left open if connection could not be
authorTobias Maier <tobias.maier@netplace.com>
Wed, 30 May 2012 04:46:42 +0000 (12:46 +0800)
committerAndy Green <andy.green@linaro.org>
Wed, 30 May 2012 04:46:42 +0000 (12:46 +0800)
 established resulting in a mass of unusable open file
 descriptors

Signed-off-by: Tobias Maier <tobias.maier@netplace.com>
lib/client-handshake.c

index f8d0b69..d3d3daa 100644 (file)
@@ -80,6 +80,11 @@ struct libwebsocket *__libwebsocket_client_connect_2(
        if (connect(wsi->sock, (struct sockaddr *)&server_addr,
                                             sizeof(struct sockaddr)) == -1)  {
                fprintf(stderr, "Connect failed\n");
+#ifdef WIN32
+               closesocket(wsi->sock);
+#else
+               close(wsi->sock);
+#endif
                goto oom4;
        }