git: 35b976c6ce61 - main - tests/kern/ssl_sendfile: reduce copy & paste
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 10 Mar 2026 21:03:57 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=35b976c6ce6145678ab378b21fdeab687a0a76d5
commit 35b976c6ce6145678ab378b21fdeab687a0a76d5
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2026-03-10 17:36:21 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2026-03-10 21:02:40 +0000
tests/kern/ssl_sendfile: reduce copy & paste
Provide sendme_locked_wait() for a common pattern. Not functional change.
---
tests/sys/kern/ssl_sendfile.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/tests/sys/kern/ssl_sendfile.c b/tests/sys/kern/ssl_sendfile.c
index 884079e80be5..066674f5fb03 100644
--- a/tests/sys/kern/ssl_sendfile.c
+++ b/tests/sys/kern/ssl_sendfile.c
@@ -252,6 +252,14 @@ sendme_locked(struct ctx *c, off_t offset, size_t size, bool nb)
ATF_REQUIRE(pthread_cond_signal(&c->cv) == 0);
}
+static void
+sendme_locked_wait(struct ctx *c, off_t offset, size_t size, bool nb)
+{
+ sendme_locked(c, offset, size, nb);
+ while (c->state != READY)
+ ATF_REQUIRE(pthread_cond_wait(&c->cv, &c->mtx) == 0);
+}
+
static void
sendme(struct ctx *c, off_t offset, size_t size, bool nb)
{
@@ -454,9 +462,7 @@ ATF_TC_BODY(eagain_vs_eof, tc)
* socket. Internall sendfile(2) returns -1 and errno == EAGAIN.
*/
ATF_REQUIRE(pthread_mutex_lock(&c.mtx) == 0);
- sendme_locked(&c, 0, FSIZE, true);
- while (c.state != READY)
- ATF_REQUIRE(pthread_cond_wait(&c.cv, &c.mtx) == 0);
+ sendme_locked_wait(&c, 0, FSIZE, true);
ATF_REQUIRE(c.sbytes > 0);
ATF_REQUIRE(SSL_get_error(c.srv, c.sbytes) == 0);
#if 0 /* see https://github.com/openssl/openssl/issues/29742 */
@@ -466,9 +472,7 @@ ATF_TC_BODY(eagain_vs_eof, tc)
/*
* Exercise second attempt on already full buffer.
*/
- sendme_locked(&c, 0, FSIZE, true);
- while (c.state != READY)
- ATF_REQUIRE(pthread_cond_wait(&c.cv, &c.mtx) == 0);
+ sendme_locked_wait(&c, 0, FSIZE, true);
ATF_REQUIRE(c.sbytes == -1);
ATF_REQUIRE(SSL_get_error(c.srv, c.sbytes) == SSL_ERROR_WANT_WRITE);
ATF_REQUIRE(BIO_should_retry(SSL_get_wbio(c.srv)));
@@ -489,9 +493,7 @@ ATF_TC_BODY(eagain_vs_eof, tc)
* legitimate one. This test just documents the existing behavior
* rather than asserts that this is a correct behavior.
*/
- sendme_locked(&c, FSIZE, 0, true);
- while (c.state != READY)
- ATF_REQUIRE(pthread_cond_wait(&c.cv, &c.mtx) == 0);
+ sendme_locked_wait(&c, FSIZE, 0, true);
ATF_REQUIRE(c.sbytes == 0);
ATF_REQUIRE(SSL_get_error(c.srv, c.sbytes) == SSL_ERROR_SYSCALL);
#if 0 /* see https://github.com/openssl/openssl/issues/29742 */
@@ -501,9 +503,7 @@ ATF_TC_BODY(eagain_vs_eof, tc)
/*
* Exercise short write due to end of file.
*/
- sendme_locked(&c, FSIZE - 100, 0, true);
- while (c.state != READY)
- ATF_REQUIRE(pthread_cond_wait(&c.cv, &c.mtx) == 0);
+ sendme_locked_wait(&c, FSIZE - 100, 0, true);
ATF_REQUIRE(c.sbytes == 100);
ATF_REQUIRE(SSL_get_error(c.srv, c.sbytes) == 0);
#if 0 /* see https://github.com/openssl/openssl/issues/29742 */