diff src/core/ngx_output_chain.c @ 7987:b002ad258f1d

Support for sendfile(SF_NOCACHE). The SF_NOCACHE flag, introduced in FreeBSD 11 along with the new non-blocking sendfile() implementation by glebius@, makes it possible to use sendfile() along with the "directio" directive.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 27 Dec 2021 19:49:26 +0300
parents ec2e6893caaa
children
line wrap: on
line diff
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -256,10 +256,6 @@ ngx_output_chain_as_is(ngx_output_chain_
     }
 #endif
 
-    if (buf->in_file && buf->file->directio) {
-        return 0;
-    }
-
     sendfile = ctx->sendfile;
 
 #if (NGX_SENDFILE_LIMIT)
@@ -270,6 +266,19 @@ ngx_output_chain_as_is(ngx_output_chain_
 
 #endif
 
+#if !(NGX_HAVE_SENDFILE_NODISKIO)
+
+    /*
+     * With DIRECTIO, disable sendfile() unless sendfile(SF_NOCACHE)
+     * is available.
+     */
+
+    if (buf->in_file && buf->file->directio) {
+        sendfile = 0;
+    }
+
+#endif
+
     if (!sendfile) {
 
         if (!ngx_buf_in_memory(buf)) {