1.10.2: Don't go over limit when creating delayed streams

This commit is contained in:
Dmitri Tikhonov 2018-08-09 10:04:52 -04:00
parent 81a42a854f
commit c6457e4258
4 changed files with 59 additions and 17 deletions

View file

@ -1,3 +1,8 @@
2018-08-09
- 1.10.2
- [BUGFIX] Don't go over limit when creating delayed streams
2018-07-10 2018-07-10
- 1.10.1 - 1.10.1

View file

@ -6,6 +6,7 @@ to the LiteSpeed Client Library:
- Amol Desphande -- Windows support - Amol Desphande -- Windows support
- Alexis La Goutte -- Travis-CI integration - Alexis La Goutte -- Travis-CI integration
- Bernhard Jaeger -- DNS Resolution - Bernhard Jaeger -- DNS Resolution
- Zhang Chi -- libevent build fix on Darwin
Thank you! Thank you!

View file

@ -25,7 +25,7 @@ extern "C" {
#define LSQUIC_MAJOR_VERSION 1 #define LSQUIC_MAJOR_VERSION 1
#define LSQUIC_MINOR_VERSION 10 #define LSQUIC_MINOR_VERSION 10
#define LSQUIC_PATCH_VERSION 1 #define LSQUIC_PATCH_VERSION 2
/** /**
* Engine flags: * Engine flags:
@ -110,6 +110,11 @@ enum lsquic_version
#define LSQUIC_DEPRECATED_VERSIONS 0 #define LSQUIC_DEPRECATED_VERSIONS 0
/**
* List of version in which the server does not include CID in short packets.
*/
#define LSQUIC_FORCED_TCID0_VERSIONS 0
/** /**
* @struct lsquic_stream_if * @struct lsquic_stream_if
* @brief The definition of callback functions call by lsquic_stream to * @brief The definition of callback functions call by lsquic_stream to

View file

@ -2348,12 +2348,52 @@ packetize_standalone_stream_resets (struct full_conn *conn)
} }
static void
create_delayed_streams (struct full_conn *conn)
{
unsigned stream_count, avail, i;
stream_count = count_streams(conn, 0);
if (stream_count >= conn->fc_cfg.max_streams_out)
return;
avail = conn->fc_cfg.max_streams_out - stream_count;
if (conn->fc_n_delayed_streams < avail)
avail = conn->fc_n_delayed_streams;
struct lsquic_stream *new_streams[ avail ];
LSQ_DEBUG("creating delayed streams");
for (i = 0; i < avail; ++i)
{
/* Delay calling on_new in order not to let the user screw up
* the counts by making more streams.
*/
new_streams[i] = new_stream(conn, generate_stream_id(conn), 0);
if (!new_streams[i])
{
ABORT_ERROR("%s: cannot create new stream: %s", __func__,
strerror(errno));
return;
}
}
LSQ_DEBUG("created %u delayed stream%.*s", avail, avail != 1, "s");
assert(count_streams(conn, 0) <= conn->fc_cfg.max_streams_out);
conn->fc_n_delayed_streams -= avail;
for (i = 0; i < avail; ++i)
lsquic_stream_call_on_new(new_streams[i]);
}
static void static void
service_streams (struct full_conn *conn) service_streams (struct full_conn *conn)
{ {
struct lsquic_hash_elem *el; struct lsquic_hash_elem *el;
lsquic_stream_t *stream, *next; lsquic_stream_t *stream, *next;
int n_our_destroyed = 0; int closed_some = 0;
for (stream = TAILQ_FIRST(&conn->fc_pub.service_streams); stream; stream = next) for (stream = TAILQ_FIRST(&conn->fc_pub.service_streams); stream; stream = next)
{ {
@ -2364,15 +2404,17 @@ service_streams (struct full_conn *conn)
*/ */
ABORT_ERROR("aborted due to error in stream %"PRIu32, stream->id); ABORT_ERROR("aborted due to error in stream %"PRIu32, stream->id);
if (stream->stream_flags & STREAM_CALL_ONCLOSE) if (stream->stream_flags & STREAM_CALL_ONCLOSE)
{
lsquic_stream_call_on_close(stream); lsquic_stream_call_on_close(stream);
closed_some |= is_our_stream(conn, stream);
conn_mark_stream_closed(conn, stream->id);
}
if (stream->stream_flags & STREAM_FREE_STREAM) if (stream->stream_flags & STREAM_FREE_STREAM)
{ {
n_our_destroyed += is_our_stream(conn, stream);
TAILQ_REMOVE(&conn->fc_pub.service_streams, stream, next_service_stream); TAILQ_REMOVE(&conn->fc_pub.service_streams, stream, next_service_stream);
el = lsquic_hash_find(conn->fc_pub.all_streams, &stream->id, sizeof(stream->id)); el = lsquic_hash_find(conn->fc_pub.all_streams, &stream->id, sizeof(stream->id));
if (el) if (el)
lsquic_hash_erase(conn->fc_pub.all_streams, el); lsquic_hash_erase(conn->fc_pub.all_streams, el);
conn_mark_stream_closed(conn, stream->id);
SAVE_STREAM_HISTORY(conn, stream); SAVE_STREAM_HISTORY(conn, stream);
lsquic_stream_destroy(stream); lsquic_stream_destroy(stream);
} }
@ -2387,19 +2429,8 @@ service_streams (struct full_conn *conn)
conn->fc_stream_ifs[STREAM_IF_STD].stream_if_ctx, NULL); conn->fc_stream_ifs[STREAM_IF_STD].stream_if_ctx, NULL);
} }
else else
while (n_our_destroyed && conn->fc_n_delayed_streams) if (closed_some && conn->fc_n_delayed_streams)
{ create_delayed_streams(conn);
--n_our_destroyed;
--conn->fc_n_delayed_streams;
LSQ_DEBUG("creating delayed stream");
if (!new_stream(conn, generate_stream_id(conn), SCF_CALL_ON_NEW))
{
ABORT_ERROR("%s: cannot create new stream: %s", __func__,
strerror(errno));
break;
}
assert(count_streams(conn, 0) <= conn->fc_cfg.max_streams_out);
}
} }