summaryrefslogtreecommitdiff
path: root/modules/websocket
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2018-11-25 16:28:55 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2018-11-25 17:25:03 +0100
commitc3d3f1dedb84d699751afd74dc2d9a1c79a576ac (patch)
tree1c6f7b3c744b71592d96ff3b9fd80add0b2dcd9e /modules/websocket
parent0d69da8c0ec1df3d8486208a45979187b97d56ec (diff)
Websocket LWS keep servicing till no CB are left
Apparently, only a single WRITABLE/READABLE callback is called at each servicing. For this reason, we want to keep servicing until we end up not receiving any callback. When that happens, we can assume that we can't (or don't want to) write more, and that there is nothing left to read in the socket buffer.
Diffstat (limited to 'modules/websocket')
-rw-r--r--modules/websocket/lws_helper.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/modules/websocket/lws_helper.h b/modules/websocket/lws_helper.h
index fd8f85371b..def4f5cfd0 100644
--- a/modules/websocket/lws_helper.h
+++ b/modules/websocket/lws_helper.h
@@ -60,6 +60,7 @@ void _lws_make_protocols(void *p_obj, lws_callback_function *p_callback, PoolVec
protected: \
struct _LWSRef *_lws_ref; \
struct lws_context *context; \
+ bool _keep_servicing; \
\
static int _lws_gd_callback(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len) { \
\
@@ -71,6 +72,7 @@ protected: \
if (!ref->is_valid) \
return 0; \
CNAME *helper = (CNAME *)ref->obj; \
+ helper->_keep_servicing = true; \
return helper->_handle_cb(wsi, reason, user, in, len); \
} \
\
@@ -91,11 +93,14 @@ public: \
\
void _lws_poll() { \
ERR_FAIL_COND(context == NULL); \
- \
- if (::_lws_poll(context, _lws_ref)) { \
- context = NULL; \
- _lws_ref = NULL; \
- } \
+ do { \
+ _keep_servicing = false; \
+ if (::_lws_poll(context, _lws_ref)) { \
+ context = NULL; \
+ _lws_ref = NULL; \
+ break; \
+ } \
+ } while (_keep_servicing); \
} \
\
protected: