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

h1: confirm POLLOUT again before starting next pipelined transaction

This commit is contained in:
Andy Green 2017-12-07 18:48:21 +08:00
parent 83af0716c5
commit 248b089ad4
4 changed files with 31 additions and 4 deletions

View file

@ -291,6 +291,11 @@ postbody_completion:
break;
}
break;
case LWSS_HTTP_DEFERRING_ACTION:
lwsl_debug("%s: LWSS_HTTP_DEFERRING_ACTION\n", __func__);
break;
default:
lwsl_err("%s: Unhandled state %d\n", __func__, wsi->state);
goto bail;

View file

@ -518,6 +518,9 @@ enum lws_connection_states {
LWSS_HTTP2_DEFERRING_ACTION = _LSF_CCB | 18 |
_LSF_POLLOUT,
LWSS_HTTP_DEFERRING_ACTION = _LSF_CCB | 19 |
_LSF_POLLOUT,
};
#define lws_state_is_ws(s) (!!(s & _LSF_WEBSOCKET))

View file

@ -1870,9 +1870,13 @@ lws_http_transaction_completed(struct lws *wsi)
if (lws_bind_protocol(wsi, &wsi->vhost->protocols[0]))
return 1;
/* otherwise set ourselves up ready to go again */
wsi->state = LWSS_HTTP;
wsi->mode = LWSCM_HTTP_SERVING;
/*
* otherwise set ourselves up ready to go again, but because we have no
* idea about the wsi writability, we make put it in a holding state
* until we can verify POLLOUT. The part of this that confirms POLLOUT
* with no partials is in lws_server_socket_service() below.
*/
wsi->state = LWSS_HTTP_DEFERRING_ACTION;
wsi->http.tx_content_length = 0;
wsi->http.tx_content_remain = 0;
wsi->hdr_parsing_completed = 0;
@ -1936,6 +1940,7 @@ lws_http_transaction_completed(struct lws *wsi)
}
lwsl_info("%s: %p: keep-alive await new transaction\n", __func__, wsi);
lws_callback_on_writable(wsi);
return 0;
}
@ -2452,6 +2457,19 @@ try_pollout:
goto fail;
}
/* clear back-to-back write detection */
wsi->could_have_pending = 0;
if (wsi->state == LWSS_HTTP_DEFERRING_ACTION) {
lwsl_debug("%s: LWSS_HTTP_DEFERRING_ACTION now writable\n",
__func__);
wsi->state = LWSS_HTTP;
if (lws_change_pollfd(wsi, LWS_POLLOUT, 0)) {
lwsl_info("failed at set pollfd\n");
goto fail;
}
}
if (wsi->mode == LWSCM_RAW) {
lws_stats_atomic_bump(wsi->context, pt,
LWSSTATS_C_WRITEABLE_CB, 1);

View file

@ -238,7 +238,7 @@ lws_handle_POLLOUT_event(struct lws *wsi, struct lws_pollfd *pollfd)
goto bail_ok;
}
/* Priority 6: user can get the callback
/* Priority 6: extensions
*/
m = lws_ext_cb_active(wsi, LWS_EXT_CB_IS_WRITEABLE, NULL, 0);
if (m)
@ -330,6 +330,7 @@ lws_handle_POLLOUT_event(struct lws *wsi, struct lws_pollfd *pollfd)
#ifndef LWS_NO_EXTENSIONS
wsi->extension_data_pending = 0;
#endif
user_service:
/* one shot */