diff --git a/CHANGELOG b/CHANGELOG index 6bb1965..b99a3a5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +2018-04-02 + + - [FEATURE] Windows support + + - Reduce stack use -- outgoing packet batch is now allocated on the heap. + 2018-03-09 - [OPTIMIZATION] Merge series of ACKs if possible diff --git a/README.md b/README.md index 3ca37e4..0cefdd4 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,8 @@ The client library has been tested on the following platforms: - ARM (Raspberry Pi 3) - FreeBSD - i386 +- Windows + - x86_64 - MacOS - x86_64 diff --git a/src/liblsquic/lsquic_engine.c b/src/liblsquic/lsquic_engine.c index 15c570a..1af6cc6 100644 --- a/src/liblsquic/lsquic_engine.c +++ b/src/liblsquic/lsquic_engine.c @@ -63,6 +63,13 @@ #define MIN_OUT_BATCH_SIZE 256 #define INITIAL_OUT_BATCH_SIZE 512 +struct out_batch +{ + lsquic_conn_t *conns [MAX_OUT_BATCH_SIZE]; + lsquic_packet_out_t *packets[MAX_OUT_BATCH_SIZE]; + struct lsquic_out_spec outs [MAX_OUT_BATCH_SIZE]; +}; + typedef struct lsquic_conn * (*conn_iter_f)(struct lsquic_engine *); static void @@ -196,6 +203,7 @@ struct lsquic_engine */ lsquic_time_t last_sent; lsquic_time_t deadline; + struct out_batch out_batch; }; @@ -1156,14 +1164,6 @@ encrypt_packet (lsquic_engine_t *engine, const lsquic_conn_t *conn, } -struct out_batch -{ - lsquic_conn_t *conns [MAX_OUT_BATCH_SIZE]; - lsquic_packet_out_t *packets[MAX_OUT_BATCH_SIZE]; - struct lsquic_out_spec outs [MAX_OUT_BATCH_SIZE]; -}; - - STAILQ_HEAD(closed_conns, lsquic_conn); @@ -1363,7 +1363,7 @@ send_packets_out (struct lsquic_engine *engine, unsigned n, w, n_sent, n_batches_sent; lsquic_packet_out_t *packet_out; lsquic_conn_t *conn; - struct out_batch batch; + struct out_batch *const batch = &engine->out_batch; struct conns_out_iter conns_iter; int shrink, deadline_exceeded; @@ -1415,24 +1415,24 @@ send_packets_out (struct lsquic_engine *engine, assert(conn->cn_flags & LSCONN_HAS_PEER_SA); if (packet_out->po_flags & PO_ENCRYPTED) { - batch.outs[n].buf = packet_out->po_enc_data; - batch.outs[n].sz = packet_out->po_enc_data_sz; + batch->outs[n].buf = packet_out->po_enc_data; + batch->outs[n].sz = packet_out->po_enc_data_sz; } else { - batch.outs[n].buf = packet_out->po_data; - batch.outs[n].sz = packet_out->po_data_sz; + batch->outs[n].buf = packet_out->po_data; + batch->outs[n].sz = packet_out->po_data_sz; } - batch.outs [n].peer_ctx = conn->cn_peer_ctx; - batch.outs [n].local_sa = (struct sockaddr *) conn->cn_local_addr; - batch.outs [n].dest_sa = (struct sockaddr *) conn->cn_peer_addr; - batch.conns [n] = conn; - batch.packets[n] = packet_out; + batch->outs [n].peer_ctx = conn->cn_peer_ctx; + batch->outs [n].local_sa = (struct sockaddr *) conn->cn_local_addr; + batch->outs [n].dest_sa = (struct sockaddr *) conn->cn_peer_addr; + batch->conns [n] = conn; + batch->packets[n] = packet_out; ++n; if (n == engine->batch_size) { n = 0; - w = send_batch(engine, &conns_iter, &batch, engine->batch_size); + w = send_batch(engine, &conns_iter, batch, engine->batch_size); ++n_batches_sent; n_sent += w; if (w < engine->batch_size) @@ -1449,7 +1449,7 @@ send_packets_out (struct lsquic_engine *engine, end_for: if (n > 0) { - w = send_batch(engine, &conns_iter, &batch, n); + w = send_batch(engine, &conns_iter, batch, n); n_sent += w; shrink = w < n; ++n_batches_sent; diff --git a/src/liblsquic/lsquic_send_ctl.c b/src/liblsquic/lsquic_send_ctl.c index aaace24..29e1973 100644 --- a/src/liblsquic/lsquic_send_ctl.c +++ b/src/liblsquic/lsquic_send_ctl.c @@ -1362,9 +1362,8 @@ lsquic_send_ctl_elide_stream_frames (lsquic_send_ctl_t *ctl, uint32_t stream_id) for (packet_out = TAILQ_FIRST(&ctl->sc_buffered_packets[n].bpq_packets); packet_out; packet_out = next) { - if (!(packet_out->po_frame_types & (1 << QUIC_FRAME_STREAM))) - continue; next = TAILQ_NEXT(packet_out, po_next); + assert(packet_out->po_frame_types & (1 << QUIC_FRAME_STREAM)); lsquic_packet_out_elide_reset_stream_frames(packet_out, stream_id); if (0 == packet_out->po_frame_types) { diff --git a/test/unittests/test_elision.c b/test/unittests/test_elision.c index acecaba..3065bf1 100644 --- a/test/unittests/test_elision.c +++ b/test/unittests/test_elision.c @@ -83,7 +83,7 @@ lsquic_stream_acked (lsquic_stream_t *stream) static void elide_single_stream_frame (void) { - struct packet_out_srec_iter posi = { 0 }; + struct packet_out_srec_iter posi; struct lsquic_engine_public enpub; lsquic_stream_t streams[1]; lsquic_packet_out_t *packet_out;