1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

debug: with debug build and uv, repeat some closes

The closes have to complete after libuv returned to the
event loop.  So make sure to catch any problem that gets
introduced where another close entry in the meanwhile is
unsafe.

https://github.com/warmcat/libwebsockets/issues/1245
This commit is contained in:
Andy Green 2018-04-19 10:08:48 +08:00
parent 6059c965dd
commit 1bf30c8620
2 changed files with 13 additions and 0 deletions

View file

@ -641,6 +641,9 @@ __lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason, const char *
wsi->http.fop_fd != NULL)
lws_vfs_file_close(&wsi->http.fop_fd);
if (lwsi_state(wsi) == LRS_DEAD_SOCKET)
return;
if (wsi->socket_is_permanently_unusable ||
reason == LWS_CLOSE_STATUS_NOSTATUS_CONTEXT_DESTROY ||
lwsi_state(wsi) == LRS_SHUTDOWN)

View file

@ -868,6 +868,16 @@ close_and_handled:
lwsl_debug("%p: Close and handled\n", wsi);
lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS,
"close_and_handled");
#if defined(_DEBUG)
/*
* confirm close has no problem being called again while
* it waits for libuv service to complete the first async
* close
*/
if (LWS_LIBUV_ENABLED(context))
lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS,
"close_and_handled uv repeat test");
#endif
/*
* pollfd may point to something else after the close
* due to pollfd swapping scheme on delete on some platforms