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

h2: client sid: must be allocated at header send

There is no way to allocate a client wsi mux sid before the headers are
send, because we don't know the order in which new wsi headers will be sent
and so seen by the peer.

The peer inisists that sid indexes only increase... we cannot allocat sids
monotonically at the client and then send them disordered...
This commit is contained in:
Andy Green 2020-05-04 08:26:48 +01:00
parent 85dc0883a2
commit 51ad2f2d9e
2 changed files with 14 additions and 9 deletions

View file

@ -327,7 +327,7 @@ set(PACKAGE "libwebsockets")
set(CPACK_PACKAGE_NAME "${PACKAGE}")
set(CPACK_PACKAGE_VERSION_MAJOR "4")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "4")
set(CPACK_PACKAGE_VERSION_PATCH "5")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")

View file

@ -316,10 +316,13 @@ lws_wsi_h2_adopt(struct lws *parent_wsi, struct lws *wsi)
#endif
wsi->h2.initialized = 1;
#if 0
/* only assign sid at header send time when we know it */
if (!wsi->mux.my_sid) {
wsi->mux.my_sid = nwsi->h2.h2n->highest_sid;
nwsi->h2.h2n->highest_sid += 2;
}
#endif
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);
@ -2329,14 +2332,16 @@ lws_h2_client_handshake(struct lws *wsi)
lwsl_debug("%s\n", __func__);
nwsi->h2.h2n->highest_sid_opened = sid;
if (!wsi->mux.my_sid)
wsi->mux.my_sid = sid;
else {
lwsl_debug("%s: %p already sid %d\n",
__func__, wsi, wsi->mux.my_sid);
//assert(0);
}
/*
* We MUST allocate our sid here at the point we're about to send the
* stream open. It's because we don't know the order in which multiple
* open streams will send their headers... in h2, sending the headers
* is the point the stream is opened. The peer requires that we only
* open streams in ascending sid order
*/
wsi->mux.my_sid = nwsi->h2.h2n->highest_sid_opened = sid;
lwsl_info("%s: wsi %p: assigning SID %d at header send\n", __func__, wsi, sid);
lwsl_info("%s: CLIENT_WAITING_TO_SEND_HEADERS: pollout (sid %d)\n",
__func__, wsi->mux.my_sid);