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

close connection if socket recv() fails.

This prevents a problem observed on Windows whereby a client that
disconnects before fully establishing the WebSocket would cause the
server to use 100% CPU since recv() would continually return -1 for that
socket.

Signed-off-by: Nick Dowell <nick@nickdowell.com>
This commit is contained in:
Nick Dowell 2012-04-05 10:29:39 +08:00 committed by Andy Green
parent f803c0d9df
commit c04c193dc3

View file

@ -1964,7 +1964,10 @@ bail3:
if (eff_buf.token_len < 0) {
fprintf(stderr, "Socket read returned %d\n",
eff_buf.token_len);
break;
if (errno != EINTR)
libwebsocket_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
return 1;
}
if (!eff_buf.token_len) {
libwebsocket_close_and_free_session(context, wsi,