Skip to content

Commit c18c301

Browse files
Sashant8m
authored andcommitted
demos/http3: Use SSL_write_ex2() together with SSL_WRITE_FLAG_CONCLUDE
These calls were introduced by PR #23343. Change also does a minor tweak to Makefile so CFLAGS and LDFLAGS variables from the environment are respected. Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from #23602)
1 parent c5cc9c4 commit c18c301

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

demos/http3/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#
55
# LD_LIBRARY_PATH=../.. ./ossl-nghttp3-demo www.example.com:443
66

7-
CFLAGS = -I../../include -g -Wall -Wsign-compare
8-
LDFLAGS = -L../..
7+
CFLAGS += -I../../include -g -Wall -Wsign-compare
8+
LDFLAGS += -L../..
99
LDLIBS = -lcrypto -lssl -lnghttp3
1010

1111
all: ossl-nghttp3-demo

demos/http3/ossl-nghttp3.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ int OSSL_DEMO_H3_CONN_handle_events(OSSL_DEMO_H3_CONN *conn)
567567
int ec, fin;
568568
size_t i, num_vecs, written, total_written, total_len;
569569
int64_t stream_id;
570+
uint64_t flags;
570571
nghttp3_vec vecs[8] = {0};
571572
OSSL_DEMO_H3_STREAM key, *s;
572573
SSL *snew;
@@ -613,6 +614,12 @@ int OSSL_DEMO_H3_CONN_handle_events(OSSL_DEMO_H3_CONN *conn)
613614
if (ec == 0)
614615
break;
615616

617+
/*
618+
* we let SSL_write_ex2(3) to conclude the stream for us (send FIN)
619+
* after all data are written.
620+
*/
621+
flags = (fin == 0) ? 0 : SSL_WRITE_FLAG_CONCLUDE;
622+
616623
/* For each of the vectors returned, pass it to OpenSSL QUIC. */
617624
key.id = stream_id;
618625
if ((s = lh_OSSL_DEMO_H3_STREAM_retrieve(conn->streams, &key)) == NULL) {
@@ -631,7 +638,7 @@ int OSSL_DEMO_H3_CONN_handle_events(OSSL_DEMO_H3_CONN *conn)
631638
if (s->s == NULL) {
632639
/* Already did STOP_SENDING and threw away stream, ignore */
633640
written = vecs[i].len;
634-
} else if (!SSL_write_ex(s->s, vecs[i].base, vecs[i].len, &written)) {
641+
} else if (!SSL_write_ex2(s->s, vecs[i].base, vecs[i].len, flags, &written)) {
635642
if (SSL_get_error(s->s, 0) == SSL_ERROR_WANT_WRITE) {
636643
/*
637644
* We have filled our send buffer so tell nghttp3 to stop
@@ -676,11 +683,6 @@ int OSSL_DEMO_H3_CONN_handle_events(OSSL_DEMO_H3_CONN *conn)
676683
}
677684

678685
if (fin && total_written == total_len) {
679-
/*
680-
* We have written all the data so mark the stream as concluded
681-
* (FIN).
682-
*/
683-
SSL_stream_conclude(s->s, 0);
684686

685687
if (total_len == 0) {
686688
/*

0 commit comments

Comments
 (0)