pmd: handle case we are already on drain list
Provide internal helper for adding to list that takes care of the case we are already on the list. https://github.com/warmcat/libwebsockets/issues/847
This commit is contained in:
parent
5a354ae44a
commit
d2d87776f9
5 changed files with 35 additions and 15 deletions
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
int lws_client_rx_sm(struct lws *wsi, unsigned char c)
|
int lws_client_rx_sm(struct lws *wsi, unsigned char c)
|
||||||
{
|
{
|
||||||
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
|
|
||||||
int callback_action = LWS_CALLBACK_CLIENT_RECEIVE;
|
int callback_action = LWS_CALLBACK_CLIENT_RECEIVE;
|
||||||
int handled, n, m, rx_draining_ext = 0;
|
int handled, n, m, rx_draining_ext = 0;
|
||||||
unsigned short close_code;
|
unsigned short close_code;
|
||||||
|
@ -548,17 +547,14 @@ utf8_fail: lwsl_info("utf8 error\n");
|
||||||
if (callback_action == LWS_CALLBACK_CLIENT_RECEIVE_PONG)
|
if (callback_action == LWS_CALLBACK_CLIENT_RECEIVE_PONG)
|
||||||
lwsl_info("Client doing pong callback\n");
|
lwsl_info("Client doing pong callback\n");
|
||||||
|
|
||||||
if (n && eff_buf.token_len) {
|
if (n && eff_buf.token_len)
|
||||||
/* extension had more... main loop will come back
|
/* extension had more... main loop will come back
|
||||||
* we want callback to be done with this set, if so,
|
* we want callback to be done with this set, if so,
|
||||||
* because lws_is_final() hides it was final until the
|
* because lws_is_final() hides it was final until the
|
||||||
* last chunk
|
* last chunk
|
||||||
*/
|
*/
|
||||||
wsi->u.ws.rx_draining_ext = 1;
|
lws_add_wsi_to_draining_ext_list(wsi);
|
||||||
wsi->u.ws.rx_draining_ext_list = pt->rx_draining_ext_list;
|
else
|
||||||
pt->rx_draining_ext_list = wsi;
|
|
||||||
lwsl_ext("%s: RX EXT DRAINING: Adding to list\n", __func__);
|
|
||||||
} else
|
|
||||||
lws_remove_wsi_from_draining_ext_list(wsi);
|
lws_remove_wsi_from_draining_ext_list(wsi);
|
||||||
|
|
||||||
if (wsi->state == LWSS_RETURNED_CLOSE_ALREADY ||
|
if (wsi->state == LWSS_RETURNED_CLOSE_ALREADY ||
|
||||||
|
|
|
@ -954,16 +954,39 @@ LWS_VISIBLE int lws_frame_is_binary(struct lws *wsi)
|
||||||
{
|
{
|
||||||
return wsi->u.ws.frame_is_binary;
|
return wsi->u.ws.frame_is_binary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
lws_add_wsi_to_draining_ext_list(struct lws *wsi)
|
||||||
|
{
|
||||||
|
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
|
||||||
|
|
||||||
|
if (wsi->u.ws.rx_draining_ext)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lwsl_ext("%s: RX EXT DRAINING: Adding to list\n", __func__);
|
||||||
|
|
||||||
|
wsi->u.ws.rx_draining_ext = 1;
|
||||||
|
wsi->u.ws.rx_draining_ext_list = pt->rx_draining_ext_list;
|
||||||
|
pt->rx_draining_ext_list = wsi;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
lws_remove_wsi_from_draining_ext_list(struct lws *wsi)
|
lws_remove_wsi_from_draining_ext_list(struct lws *wsi)
|
||||||
{
|
{
|
||||||
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
|
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
|
||||||
struct lws **w = &pt->rx_draining_ext_list;
|
struct lws **w = &pt->rx_draining_ext_list;
|
||||||
|
|
||||||
|
if (!wsi->u.ws.rx_draining_ext)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lwsl_ext("%s: RX EXT DRAINING: Removing from list\n", __func__);
|
||||||
|
|
||||||
wsi->u.ws.rx_draining_ext = 0;
|
wsi->u.ws.rx_draining_ext = 0;
|
||||||
|
|
||||||
/* remove us from context draining ext list */
|
/* remove us from context draining ext list */
|
||||||
while (*w) {
|
while (*w) {
|
||||||
if (*w == wsi) {
|
if (*w == wsi) {
|
||||||
|
/* if us, point it instead to who we were pointing to */
|
||||||
*w = wsi->u.ws.rx_draining_ext_list;
|
*w = wsi->u.ws.rx_draining_ext_list;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -980,7 +1003,6 @@ lws_remove_wsi_from_draining_ext_list(struct lws *wsi)
|
||||||
int
|
int
|
||||||
lws_rx_sm(struct lws *wsi, unsigned char c)
|
lws_rx_sm(struct lws *wsi, unsigned char c)
|
||||||
{
|
{
|
||||||
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
|
|
||||||
int callback_action = LWS_CALLBACK_RECEIVE;
|
int callback_action = LWS_CALLBACK_RECEIVE;
|
||||||
int ret = 0, n, rx_draining_ext = 0;
|
int ret = 0, n, rx_draining_ext = 0;
|
||||||
struct lws_tokens eff_buf;
|
struct lws_tokens eff_buf;
|
||||||
|
@ -1446,10 +1468,7 @@ drain_extension:
|
||||||
|
|
||||||
if (n && eff_buf.token_len) {
|
if (n && eff_buf.token_len) {
|
||||||
/* extension had more... main loop will come back */
|
/* extension had more... main loop will come back */
|
||||||
// lwsl_notice("ext has stuff to drain\n");
|
lws_add_wsi_to_draining_ext_list(wsi);
|
||||||
wsi->u.ws.rx_draining_ext = 1;
|
|
||||||
wsi->u.ws.rx_draining_ext_list = pt->rx_draining_ext_list;
|
|
||||||
pt->rx_draining_ext_list = wsi;
|
|
||||||
} else
|
} else
|
||||||
lws_remove_wsi_from_draining_ext_list(wsi);
|
lws_remove_wsi_from_draining_ext_list(wsi);
|
||||||
|
|
||||||
|
|
|
@ -1990,6 +1990,8 @@ LWS_EXTERN int
|
||||||
lws_plat_change_pollfd(struct lws_context *context, struct lws *wsi,
|
lws_plat_change_pollfd(struct lws_context *context, struct lws *wsi,
|
||||||
struct lws_pollfd *pfd);
|
struct lws_pollfd *pfd);
|
||||||
LWS_EXTERN void
|
LWS_EXTERN void
|
||||||
|
lws_add_wsi_to_draining_ext_list(struct lws *wsi);
|
||||||
|
LWS_EXTERN void
|
||||||
lws_remove_wsi_from_draining_ext_list(struct lws *wsi);
|
lws_remove_wsi_from_draining_ext_list(struct lws *wsi);
|
||||||
LWS_EXTERN int
|
LWS_EXTERN int
|
||||||
lws_plat_context_early_init(void);
|
lws_plat_context_early_init(void);
|
||||||
|
|
|
@ -489,9 +489,10 @@ lws_service_flag_pending(struct lws_context *context, int tsi)
|
||||||
while (wsi) {
|
while (wsi) {
|
||||||
pt->fds[wsi->position_in_fds_table].revents |=
|
pt->fds[wsi->position_in_fds_table].revents |=
|
||||||
pt->fds[wsi->position_in_fds_table].events & LWS_POLLIN;
|
pt->fds[wsi->position_in_fds_table].events & LWS_POLLIN;
|
||||||
if (pt->fds[wsi->position_in_fds_table].revents &
|
if (pt->fds[wsi->position_in_fds_table].revents & LWS_POLLIN) {
|
||||||
LWS_POLLIN)
|
|
||||||
forced = 1;
|
forced = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
wsi = wsi->u.ws.rx_draining_ext_list;
|
wsi = wsi->u.ws.rx_draining_ext_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue