Commit 940f4930c8 for openssl.org

commit 940f4930c856acf21ee4280550632a59215a6127
Author: Eugene Syromiatnikov <esyr@openssl.org>
Date:   Fri Jun 26 20:02:01 2026 +0200

    demos/guide/tls-server-block.c: check results of __owur API calls

    Check results of SSL_CTX_set_session_id_context()
    and SSL_CTX_set_timeout() calls, as these functions are marked
    with __owur, leading to compilation error when compiled
    with -Werror=unused-result.

    Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

    Reviewed-by: Neil Horman <nhorman@openssl.org>
    Reviewed-by: Bob Beck <beck@openssl.org>
    MergeDate: Mon Jul 20 11:18:51 2026
    (Merged from https://github.com/openssl/openssl/pull/31751)

diff --git a/demos/guide/tls-server-block.c b/demos/guide/tls-server-block.c
index 2bee2219ed..8e8410f995 100644
--- a/demos/guide/tls-server-block.c
+++ b/demos/guide/tls-server-block.c
@@ -64,6 +64,7 @@ int main(int argc, char *argv[])
 {
     int res = EXIT_FAILURE;
     long opts;
+    long old_timeout;
     const char *hostport;
     SSL_CTX *ctx = NULL;
     BIO *acceptor_bio;
@@ -174,7 +175,11 @@ int main(int argc, char *argv[])
      * byte array, that identifies the server application, and reduces the
      * chance of inappropriate cache sharing.
      */
-    SSL_CTX_set_session_id_context(ctx, (void *)cache_id, sizeof(cache_id));
+    if (SSL_CTX_set_session_id_context(ctx, (void *)cache_id, sizeof(cache_id)) <= 0) {
+        SSL_CTX_free(ctx);
+        ERR_print_errors_fp(stderr);
+        errx(res, "Failed to set server session ID context");
+    }
     SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_SERVER);

     /*
@@ -191,7 +196,9 @@ int main(int argc, char *argv[])
      * loaded servers with sporadic connections from any given client, a longer
      * time may be appropriate.
      */
-    SSL_CTX_set_timeout(ctx, 3600);
+    old_timeout = SSL_CTX_set_timeout(ctx, 3600);
+    if (old_timeout != 3600)
+        warnx("Changing session timeout from %ld to 3600", old_timeout);

     /*
      * Clients rarely employ certificate-based authentication, and so we don't