From: Andy Green Date: Sun, 17 Feb 2013 01:14:08 +0000 (+0800) Subject: test server kill skt with minus 1 X-Git-Tag: accepted/2.0/20130307.220733~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eadf701a6f361832cb8147396b149e4d92406a39;p=profile%2Fivi%2Flibwebsockets.git test server kill skt with minus 1 The client spams the server with mirror protocol content and then closes the connection. However the server wants to send that content back to all the mirror protocol connections, including the one that closed. The result is during the send back phase we usually see an error trying to send to the close client connection. Because we don't return -1, we don't close it on server side and the error repeats a lot before finally closing. This is a side- effect of a recent patch to drain pending input before really closing a dead connection. This patch just changes it to return -1 on the failed send attempt assertively closing the connection. Signed-off-by: Andy Green --- diff --git a/test-server/test-server.c b/test-server/test-server.c index 27208e0..c01bb62 100644 --- a/test-server/test-server.c +++ b/test-server/test-server.c @@ -385,8 +385,8 @@ callback_dumb_increment(struct libwebsocket_context *context, n = sprintf((char *)p, "%d", pss->number++); n = libwebsocket_write(wsi, p, n, LWS_WRITE_TEXT); if (n < 0) { - lwsl_err("ERROR %d writing to socket\n", n); - return 1; + lwsl_err("ERROR %d writing to di socket\n", n); + return -1; } if (close_testing && pss->number == 50) { lwsl_info("close tesing limit, closing\n"); @@ -476,8 +476,8 @@ callback_lws_mirror(struct libwebsocket_context *context, ringbuffer[pss->ringbuffer_tail].len, LWS_WRITE_TEXT); if (n < 0) { - lwsl_err("ERROR %d writing to socket\n", n); - return 1; + lwsl_err("ERROR %d writing to mirror socket\n", n); + return -1; } if (pss->ringbuffer_tail == (MAX_MESSAGE_QUEUE - 1))