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

h2: take care to retain initial sid

This commit is contained in:
Andy Green 2020-04-06 13:22:01 +01:00
parent 8385cb427f
commit 5e99b9f3ee
5 changed files with 33 additions and 9 deletions

View file

@ -357,7 +357,7 @@ find_package(Git)
if(GIT_EXECUTABLE)
execute_process(
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND "${GIT_EXECUTABLE}" describe --tags
COMMAND "${GIT_EXECUTABLE}" describe --tags --always
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

View file

@ -1088,6 +1088,12 @@ lws_wsi_client_stash_item(struct lws *wsi, int stash_idx, int hdr_idx)
void
lws_wsi_mux_insert(struct lws *wsi, struct lws *parent_wsi, int sid)
{
lwsl_info("%s: wsi %p, par %p: assign sid %d (curr %d)\n", __func__,
wsi, parent_wsi, sid, wsi->mux.my_sid);
if (wsi->mux.my_sid && wsi->mux.my_sid != (unsigned int)sid)
assert(0);
wsi->mux.my_sid = sid;
wsi->mux.parent_wsi = parent_wsi;
wsi->role_ops = parent_wsi->role_ops;
@ -1204,8 +1210,8 @@ lws_wsi_mux_mark_parents_needing_writeable(struct lws *wsi)
wsi2 = wsi;
while (wsi2) {
wsi2->mux.requested_POLLOUT = 1;
lwsl_info("%s: mark %p (sid %u) pending writable\n", __func__,
wsi2, wsi2->mux.my_sid);
lwsl_info("%s: mark wsi: %p, sid %u, pending writable\n",
__func__, wsi2, wsi2->mux.my_sid);
wsi2 = wsi2->mux.parent_wsi;
}

View file

@ -248,6 +248,8 @@ lws_wsi_server_new(struct lws_vhost *vh, struct lws *parent_wsi,
h2n->highest_sid_opened = sid;
lws_wsi_mux_insert(wsi, parent_wsi, sid);
if (sid >= h2n->highest_sid)
h2n->highest_sid = sid + 2;
wsi->mux_substream = 1;
wsi->seen_nonpseudoheader = 0;
@ -319,6 +321,9 @@ lws_wsi_h2_adopt(struct lws *parent_wsi, struct lws *wsi)
nwsi->h2.h2n->highest_sid += 2;
}
lwsl_info("%s: binding wsi %p to sid %d (next %d)\n", __func__,
wsi, (int)wsi->mux.my_sid, (int)nwsi->h2.h2n->highest_sid);
lws_wsi_mux_insert(wsi, parent_wsi, wsi->mux.my_sid);
wsi->txc.tx_cr = nwsi->h2.h2n->peer_set.s[H2SET_INITIAL_WINDOW_SIZE];
@ -1219,6 +1224,9 @@ lws_h2_parse_frame_header(struct lws *wsi)
return 1;
}
if (h2n->sid >= h2n->highest_sid)
h2n->highest_sid = h2n->sid + 2;
h2n->swsi->h2.initialized = 1;
if (lws_h2_update_peer_txcredit(h2n->swsi,
@ -1569,6 +1577,9 @@ lws_h2_parse_end_of_frame(struct lws *wsi)
}
switch (h2n->swsi->h2.h2_state) {
case LWS_H2_STATE_IDLE:
lws_h2_state(h2n->swsi, LWS_H2_STATE_OPEN);
break;
case LWS_H2_STATE_OPEN:
if (h2n->swsi->h2.END_STREAM)
lws_h2_state(h2n->swsi,
@ -1582,7 +1593,8 @@ lws_h2_parse_end_of_frame(struct lws *wsi)
#if defined(LWS_WITH_CLIENT)
if (h2n->swsi->client_mux_substream) {
lwsl_info("%s: headers: client path\n", __func__);
lwsl_info("%s: wsi %p: headers: client path (h2 state %s)\n",
__func__, wsi, h2_state_names[h2n->swsi->h2.h2_state]);
break;
}
#endif
@ -2318,7 +2330,13 @@ lws_h2_client_handshake(struct lws *wsi)
lwsl_debug("%s\n", __func__);
nwsi->h2.h2n->highest_sid_opened = sid;
wsi->mux.my_sid = sid;
if (!wsi->mux.my_sid)
wsi->mux.my_sid = sid;
else {
lwsl_debug("%s: %p already sid %d\n",
__func__, wsi, (int)wsi->mux.my_sid);
//assert(0);
}
lwsl_info("%s: CLIENT_WAITING_TO_SEND_HEADERS: pollout (sid %d)\n",
__func__, wsi->mux.my_sid);
@ -2430,7 +2448,7 @@ lws_h2_client_handshake(struct lws *wsi)
wsi->txc.manual = 1;
}
if (lws_h2_update_peer_txcredit(wsi, sid, n))
if (lws_h2_update_peer_txcredit(wsi, wsi->mux.my_sid, n))
return 1;
lws_h2_state(wsi, LWS_H2_STATE_OPEN);

View file

@ -859,8 +859,8 @@ rops_perform_user_POLLOUT_h2(struct lws *wsi)
goto next_child;
}
lwsl_info("%s: child %p (wsistate 0x%x)\n", __func__, w,
(unsigned int)w->wsistate);
lwsl_info("%s: child wsi %p, sid %d, (wsistate 0x%x)\n",
__func__, w, w->mux.my_sid, (unsigned int)w->wsistate);
/* priority 1: post compression-transform buffered output */

View file

@ -933,7 +933,7 @@ lws_client_interpret_server_handshake(struct lws *wsi)
wsi->http.ah = ah1;
lwsl_info("%s: client connection up\n", __func__);
lwsl_info("%s: wsi %p: client connection up\n", __func__, wsi);
/*
* Did we get a response from the server with an explicit