fix-context-close.patch
authorAndy Green <andy@warmcat.com>
Sun, 30 Jan 2011 20:40:32 +0000 (20:40 +0000)
committerAndy Green <andy@warmcat.com>
Sun, 30 Jan 2011 20:40:32 +0000 (20:40 +0000)
Signed-off-by: Andy Green <andy@warmcat.com>
lib/client-handshake.c
lib/libwebsockets.c
test-server/test-client.c
test-server/test-ping.c

index 3b57bd9..c3b7cec 100644 (file)
@@ -21,6 +21,9 @@ libwebsocket_client_close(struct libwebsocket *wsi)
        int n = wsi->state;
        struct libwebsocket_context *clients;
 
+       if (n == WSI_STATE_DEAD_SOCKET)
+               return;
+
        /* mark the WSI as dead and let the callback know */
 
        wsi->state = WSI_STATE_DEAD_SOCKET;
index 989e564..403a7f6 100644 (file)
@@ -222,8 +222,11 @@ libwebsocket_context_destroy(struct libwebsocket_context *this)
        int client;
 
        /* close listening skt and per-protocol broadcast sockets */
-       for (client = 0; client < this->fds_count; client++)
-               libwebsocket_close_and_free_session(this->wsi[client]);
+       for (client = this->count_protocols + 1; client < this->fds_count; client++)
+               if (this->wsi[client]->client_mode)
+                       libwebsocket_client_close(this->wsi[client]);
+               else
+                       libwebsocket_close_and_free_session(this->wsi[client]);
 
 #ifdef LWS_OPENSSL_SUPPORT
        if (this->ssl_ctx)
index 289374a..b503343 100644 (file)
@@ -243,9 +243,6 @@ int main(int argc, char **argv)
        while (n >= 0)
                n = libwebsocket_service(context, 1000);
 
-       libwebsocket_client_close(wsi_dumb);
-       libwebsocket_client_close(wsi_mirror);
-
        libwebsocket_context_destroy(context);
 
        return 0;
index 7b901ec..b2a8684 100644 (file)
@@ -489,12 +489,6 @@ int main(int argc, char **argv)
                ((double)global_rx_count * (double)size) /
                                  ((double)(l - started) / 1000000.0) / 1024.0);
 
-//     return 0;
-fprintf(stderr, "a\n");
-       for (n = 0; n < clients; n++)
-               libwebsocket_client_close(wsi[n]);
-
-fprintf(stderr, "b\n");
        libwebsocket_context_destroy(context);
 
        return 0;