From bebc1bb85295c27477c984c32b14bebbea572ada Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 11 Feb 2013 12:37:13 +0800 Subject: [PATCH] valgrind free rx_user_buffer if entered CONNMODE_WS_SERVING This seems to be enough to get a clean valgrind run for the test server with 1 x chrome and 1 x libwebsockets-test-client session being run for 10s lwsts[19767]: libwebsockets-test-server exited cleanly ==19767== ==19767== HEAP SUMMARY: ==19767== in use at exit: 0 bytes in 0 blocks ==19767== total heap usage: 41,071 allocs, 41,071 frees, 27,464,834 bytes allocated ==19767== ==19767== All heap blocks were freed -- no leaks are possible ==19767== ==19767== For counts of detected and suppressed errors, rerun with: -v ==19767== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2) test client is another story... Signed-off-by: Andy Green --- lib/libwebsockets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 49a51fe..4d0f474 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -312,7 +312,7 @@ just_kill_connection: wsi->state = WSI_STATE_DEAD_SOCKET; - if (old_state == WSI_STATE_ESTABLISHED && wsi->u.ws.rx_user_buffer) { + if ((old_state == WSI_STATE_ESTABLISHED || wsi->mode == LWS_CONNMODE_WS_SERVING) && wsi->u.ws.rx_user_buffer) { free(wsi->u.ws.rx_user_buffer); wsi->u.ws.rx_user_buffer = NULL; } -- 2.7.4