client allow user callback to close on nonzero return
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
bbc5c07054
commit
5ac7e7ad5a
3 changed files with 12 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* libwebsockets - small server side websockets and web server implementation
|
||||
*
|
||||
* Copyright (C) 2010-2013 Andy Green <andy@warmcat.com>
|
||||
* Copyright (C) 2010-2014 Andy Green <andy@warmcat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -382,7 +382,8 @@ spill:
|
|||
}
|
||||
}
|
||||
#endif
|
||||
if (eff_buf.token_len <= 0 && callback_action != LWS_CALLBACK_CLIENT_RECEIVE_PONG)
|
||||
if (eff_buf.token_len <= 0 &&
|
||||
callback_action != LWS_CALLBACK_CLIENT_RECEIVE_PONG)
|
||||
goto already_done;
|
||||
|
||||
eff_buf.token[eff_buf.token_len] = '\0';
|
||||
|
@ -393,7 +394,7 @@ spill:
|
|||
if (callback_action == LWS_CALLBACK_CLIENT_RECEIVE_PONG)
|
||||
lwsl_info("Client doing pong callback\n");
|
||||
|
||||
wsi->protocol->callback(
|
||||
m = wsi->protocol->callback(
|
||||
wsi->protocol->owning_server,
|
||||
wsi,
|
||||
(enum libwebsocket_callback_reasons)callback_action,
|
||||
|
@ -401,6 +402,10 @@ spill:
|
|||
eff_buf.token,
|
||||
eff_buf.token_len);
|
||||
|
||||
/* if user code wants to close, let caller know */
|
||||
if (m)
|
||||
return 1;
|
||||
|
||||
already_done:
|
||||
wsi->u.ws.rx_user_buffer_head = 0;
|
||||
break;
|
||||
|
|
|
@ -163,7 +163,7 @@ bail:
|
|||
* we will get a destroy callback to take care
|
||||
* of closing nicely
|
||||
*/
|
||||
lwsl_err("zlib error inflate %d: %s\n",
|
||||
lwsl_info("zlib error inflate %d: %s\n",
|
||||
n, conn->zs_in.msg);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ http_postbody:
|
|||
case LWS_CONNMODE_WS_CLIENT:
|
||||
for (n = 0; n < len; n++)
|
||||
if (libwebsocket_client_rx_sm(wsi, *buf++)) {
|
||||
lwsl_info("client_rx_sm failed\n");
|
||||
lwsl_debug("client_rx_sm failed\n");
|
||||
goto bail;
|
||||
}
|
||||
return 0;
|
||||
|
@ -417,7 +417,7 @@ cleanup:
|
|||
for (n = 0; n < len; n++)
|
||||
if (libwebsocket_client_rx_sm(
|
||||
wsi, *buf++) < 0) {
|
||||
lwsl_info("client rx has bailed\n");
|
||||
lwsl_debug("client rx has bailed\n");
|
||||
goto bail;
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ bail_nuke_ah:
|
|||
#endif
|
||||
|
||||
bail:
|
||||
lwsl_info("closing connection at libwebsocket_read bail:\n");
|
||||
lwsl_debug("closing connection at libwebsocket_read bail:\n");
|
||||
|
||||
libwebsocket_close_and_free_session(context, wsi,
|
||||
LWS_CLOSE_STATUS_NOSTATUS);
|
||||
|
|
Loading…
Add table
Reference in a new issue