Welcome! Log In Create A New Profile

Advanced

[PATCH 3 of 4] SSL: SSL_sendfile(SF_NODISKIO) support

Maxim Dounin
November 10, 2021 11:26PM
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1636603895 -10800
# Thu Nov 11 07:11:35 2021 +0300
# Node ID 98d3beb63f32cbb68d1cdcec385614d32129cad0
# Parent 4a954e89b1ae8539bbe08c5afc1d5c9828d82d6f
SSL: SSL_sendfile(SF_NODISKIO) support.

diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -2942,7 +2942,7 @@ ngx_ssl_sendfile(ngx_connection_t *c, ng
{
#ifdef BIO_get_ktls_send

- int sslerr;
+ int sslerr, flags;
ssize_t n;
ngx_err_t err;

@@ -2954,8 +2954,14 @@ ngx_ssl_sendfile(ngx_connection_t *c, ng

ngx_set_errno(0);

+#if (NGX_HAVE_SENDFILE_NODISKIO)
+ flags = (c->busy_count <= 2) ? SF_NODISKIO : 0;
+#else
+ flags = 0;
+#endif
+
n = SSL_sendfile(c->ssl->connection, file->file->fd, file->file_pos,
- size, 0);
+ size, flags);

ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_sendfile: %d", n);

@@ -2974,6 +2980,10 @@ ngx_ssl_sendfile(ngx_connection_t *c, ng
ngx_post_event(c->read, &ngx_posted_events);
}

+#if (NGX_HAVE_SENDFILE_NODISKIO)
+ c->busy_count = 0;
+#endif
+
c->sent += n;

return n;
@@ -3038,6 +3048,23 @@ ngx_ssl_sendfile(ngx_connection_t *c, ng
ngx_post_event(c->read, &ngx_posted_events);
}

+#if (NGX_HAVE_SENDFILE_NODISKIO)
+
+ if (ngx_errno == EBUSY) {
+ c->busy_count++;
+
+ ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
+ "SSL_sendfile() busy, count:%d", c->busy_count);
+
+ if (c->write->posted) {
+ ngx_delete_posted_event(c->write);
+ }
+
+ ngx_post_event(c->write, &ngx_posted_next_events);
+ }
+
+#endif
+
c->write->ready = 0;
return NGX_AGAIN;
}

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 3 of 4] SSL: SSL_sendfile(SF_NODISKIO) support

Maxim Dounin 204 November 10, 2021 11:26PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 91
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready