diff --git a/CHANGELOG b/CHANGELOG index 7114553..f3f0a5f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +2018-10-03 + - 1.16.0 + - [API Change] Add lsquic_conn_n_avail_streams() + - [BUGFIX] only dispatch crypto stream read events if WANT_READ is on + 2018-09-27 - 1.15.0 - [API Change] Add LSCONN_ST_PEER_GOING_AWAY to the list of conn statuses diff --git a/include/lsquic.h b/include/lsquic.h index 6174460..fb49dc4 100644 --- a/include/lsquic.h +++ b/include/lsquic.h @@ -24,7 +24,7 @@ extern "C" { #endif #define LSQUIC_MAJOR_VERSION 1 -#define LSQUIC_MINOR_VERSION 15 +#define LSQUIC_MINOR_VERSION 16 #define LSQUIC_PATCH_VERSION 0 /** @@ -668,6 +668,10 @@ lsquic_engine_send_unsent_packets (lsquic_engine_t *engine); void lsquic_engine_destroy (lsquic_engine_t *); +/** Return max allowed outbound streams less current outbound streams. */ +unsigned +lsquic_conn_n_avail_streams (const lsquic_conn_t *); + void lsquic_conn_make_stream(lsquic_conn_t *); /** Return number of delayed streams currently pending */ diff --git a/src/liblsquic/lsquic_full_conn.c b/src/liblsquic/lsquic_full_conn.c index c05df58..16d37ba 100644 --- a/src/liblsquic/lsquic_full_conn.c +++ b/src/liblsquic/lsquic_full_conn.c @@ -989,12 +989,22 @@ either_side_going_away (const struct full_conn *conn) } +unsigned +lsquic_conn_n_avail_streams (const lsquic_conn_t *lconn) +{ + struct full_conn *conn = (struct full_conn *) lconn; + unsigned stream_count = count_streams(conn, 0); + if (conn->fc_cfg.max_streams_out < stream_count) + return 0; + return conn->fc_cfg.max_streams_out - stream_count; +} + + void lsquic_conn_make_stream (lsquic_conn_t *lconn) { struct full_conn *conn = (struct full_conn *) lconn; - unsigned stream_count = count_streams(conn, 0); - if (stream_count < conn->fc_cfg.max_streams_out) + if (lsquic_conn_n_avail_streams(lconn) > 0) { if (!new_stream(conn, generate_stream_id(conn), SCF_CALL_ON_NEW)) ABORT_ERROR("could not create new stream: %s", strerror(errno)); @@ -1220,6 +1230,7 @@ process_stream_frame (struct full_conn *conn, lsquic_packet_in_t *packet_in, } if (stream->id == LSQUIC_STREAM_HANDSHAKE + && (stream->stream_flags & STREAM_WANT_READ) && !(conn->fc_flags & FC_SERVER) && !(conn->fc_conn.cn_flags & LSCONN_HANDSHAKE_DONE)) { /* To enable decryption, process handshake stream as soon as its