clean-out-poll-array-when-hanging-up-on-client.patch
authorAndy Green <andy.green@linaro.org>
Sun, 13 Feb 2011 09:15:10 +0000 (09:15 +0000)
committerAndy Green <andy.green@linaro.org>
Sun, 13 Feb 2011 09:15:10 +0000 (09:15 +0000)
Signed-off-by: Andy Green <andy.green@linaro.org>
lib/libwebsockets.c

index 718737e..e1ab1c5 100644 (file)
@@ -144,10 +144,23 @@ void
 libwebsockets_hangup_on_client(struct libwebsocket_context *this, int fd)
 {
        struct libwebsocket *wsi = wsi_from_fd(this, fd);
+       int n;
 
        if (wsi == NULL)
                return;
 
+       delete_from_fd(this, fd);
+
+       for (n = 0; n < this->fds_count - 1; n++)
+               if (this->fds[n].fd == fd) {
+                       while (n < this->fds_count - 1) {
+                               this->fds[n] = this->fds[n + 1];
+                               n++;
+                       }
+                       n = this->fds_count;
+                       this->fds_count--;
+               }
+
        libwebsocket_close_and_free_session(wsi);
 }