mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
lws_union_transition
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
03f0ceaf97
commit
44c116172d
5 changed files with 17 additions and 23 deletions
|
@ -723,17 +723,12 @@ check_accept:
|
|||
libwebsocket_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
|
||||
|
||||
/* free up his parsing allocations */
|
||||
|
||||
if (wsi->u.hdr.ah)
|
||||
free(wsi->u.hdr.ah);
|
||||
|
||||
/* mark him as being alive */
|
||||
|
||||
lws_union_transition(wsi, LWS_CONNMODE_WS_CLIENT);
|
||||
wsi->state = WSI_STATE_ESTABLISHED;
|
||||
wsi->mode = LWS_CONNMODE_WS_CLIENT;
|
||||
|
||||
/* union transition */
|
||||
|
||||
memset(&wsi->u, 0, sizeof(wsi->u));
|
||||
|
||||
wsi->rxflow_change_to = LWS_RXFLOW_ALLOW;
|
||||
|
||||
|
|
|
@ -847,3 +847,10 @@ lws_get_peer_write_allowance(struct libwebsocket *wsi)
|
|||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
LWS_VISIBLE void
|
||||
lws_union_transition(struct libwebsocket *wsi, enum connection_mode mode)
|
||||
{
|
||||
memset(&wsi->u, 0, sizeof(wsi->u));
|
||||
wsi->mode = mode;
|
||||
}
|
||||
|
|
|
@ -957,6 +957,9 @@ lws_issue_raw_ext_access(struct libwebsocket *wsi,
|
|||
LWS_EXTERN int
|
||||
_libwebsocket_rx_flow_control(struct libwebsocket *wsi);
|
||||
|
||||
LWS_EXTERN void
|
||||
lws_union_transition(struct libwebsocket *wsi, enum connection_mode mode);
|
||||
|
||||
LWS_EXTERN int
|
||||
user_callback_handle_rxflow(callback_function,
|
||||
struct libwebsocket_context *context,
|
||||
|
|
14
lib/server.c
14
lib/server.c
|
@ -361,9 +361,7 @@ int lws_handshake_server(struct libwebsocket_context *context,
|
|||
|
||||
ah = wsi->u.hdr.ah;
|
||||
|
||||
/* union transition */
|
||||
memset(&wsi->u, 0, sizeof(wsi->u));
|
||||
wsi->mode = LWS_CONNMODE_HTTP_SERVING_ACCEPTED;
|
||||
lws_union_transition(wsi, LWS_CONNMODE_HTTP_SERVING_ACCEPTED);
|
||||
wsi->state = WSI_STATE_HTTP;
|
||||
wsi->u.http.fd = LWS_INVALID_FILE;
|
||||
|
||||
|
@ -407,10 +405,7 @@ upgrade_h2c:
|
|||
|
||||
ah = wsi->u.hdr.ah;
|
||||
|
||||
wsi->mode = LWS_CONNMODE_HTTP2_SERVING;
|
||||
|
||||
/* union transition */
|
||||
memset(&wsi->u, 0, sizeof(wsi->u));
|
||||
lws_union_transition(wsi, LWS_CONNMODE_HTTP2_SERVING);
|
||||
|
||||
/* http2 union member has http union struct at start */
|
||||
wsi->u.http.ah = ah;
|
||||
|
@ -552,10 +547,7 @@ upgrade_ws:
|
|||
/* drop the header info -- no bail_nuke_ah after this */
|
||||
lws_free_header_table(wsi);
|
||||
|
||||
wsi->mode = LWS_CONNMODE_WS_SERVING;
|
||||
|
||||
/* union transition */
|
||||
memset(&wsi->u, 0, sizeof(wsi->u));
|
||||
lws_union_transition(wsi, LWS_CONNMODE_WS_SERVING);
|
||||
|
||||
/*
|
||||
* create the frame buffer for this connection according to the
|
||||
|
|
|
@ -132,16 +132,13 @@ void lws_http2_configure_if_upgraded(struct libwebsocket *wsi)
|
|||
return;
|
||||
|
||||
/* http2 */
|
||||
|
||||
wsi->mode = LWS_CONNMODE_HTTP2_SERVING;
|
||||
wsi->state = WSI_STATE_HTTP2_AWAIT_CLIENT_PREFACE;
|
||||
|
||||
/* adopt the header info */
|
||||
|
||||
ah = wsi->u.hdr.ah;
|
||||
|
||||
/* union transition */
|
||||
memset(&wsi->u, 0, sizeof(wsi->u));
|
||||
lws_union_transition(wsi, LWS_CONNMODE_HTTP2_SERVING);
|
||||
wsi->state = WSI_STATE_HTTP2_AWAIT_CLIENT_PREFACE;
|
||||
|
||||
/* http2 union member has http union struct at start */
|
||||
wsi->u.http.ah = ah;
|
||||
|
|
Loading…
Add table
Reference in a new issue