summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorAlexandr Nedvedicky <sashan@openssl.org>2024-02-15 12:07:26 +0100
committerTomas Mraz <tomas@openssl.org>2024-03-01 10:56:16 +0100
commitc18c301deb44deb27f35c199e8bf44ca8b80e579 (patch)
tree7b905c2f349d6924b2e9a36889baa71460beba26 /demos
parentc5cc9c419a0a8d97a44f01f95f0e213f56da4574 (diff)
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 https://github.com/openssl/openssl/pull/23602)
Diffstat (limited to 'demos')
-rw-r--r--demos/http3/Makefile4
-rw-r--r--demos/http3/ossl-nghttp3.c14
2 files changed, 10 insertions, 8 deletions
diff --git a/demos/http3/Makefile b/demos/http3/Makefile
index aeff1e9e4f..c2275bd755 100644
--- a/demos/http3/Makefile
+++ b/demos/http3/Makefile
@@ -4,8 +4,8 @@
#
# LD_LIBRARY_PATH=../.. ./ossl-nghttp3-demo www.example.com:443
-CFLAGS = -I../../include -g -Wall -Wsign-compare
-LDFLAGS = -L../..
+CFLAGS += -I../../include -g -Wall -Wsign-compare
+LDFLAGS += -L../..
LDLIBS = -lcrypto -lssl -lnghttp3
all: ossl-nghttp3-demo
diff --git a/demos/http3/ossl-nghttp3.c b/demos/http3/ossl-nghttp3.c
index 2b2259f34f..c8c8aa8d42 100644
--- a/demos/http3/ossl-nghttp3.c
+++ b/demos/http3/ossl-nghttp3.c
@@ -567,6 +567,7 @@ int OSSL_DEMO_H3_CONN_handle_events(OSSL_DEMO_H3_CONN *conn)
int ec, fin;
size_t i, num_vecs, written, total_written, total_len;
int64_t stream_id;
+ uint64_t flags;
nghttp3_vec vecs[8] = {0};
OSSL_DEMO_H3_STREAM key, *s;
SSL *snew;
@@ -613,6 +614,12 @@ int OSSL_DEMO_H3_CONN_handle_events(OSSL_DEMO_H3_CONN *conn)
if (ec == 0)
break;
+ /*
+ * we let SSL_write_ex2(3) to conclude the stream for us (send FIN)
+ * after all data are written.
+ */
+ flags = (fin == 0) ? 0 : SSL_WRITE_FLAG_CONCLUDE;
+
/* For each of the vectors returned, pass it to OpenSSL QUIC. */
key.id = stream_id;
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)
if (s->s == NULL) {
/* Already did STOP_SENDING and threw away stream, ignore */
written = vecs[i].len;
- } else if (!SSL_write_ex(s->s, vecs[i].base, vecs[i].len, &written)) {
+ } else if (!SSL_write_ex2(s->s, vecs[i].base, vecs[i].len, flags, &written)) {
if (SSL_get_error(s->s, 0) == SSL_ERROR_WANT_WRITE) {
/*
* 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)
}
if (fin && total_written == total_len) {
- /*
- * We have written all the data so mark the stream as concluded
- * (FIN).
- */
- SSL_stream_conclude(s->s, 0);
if (total_len == 0) {
/*