Welcome! Log In Create A New Profile

Advanced

[nginx] Event pipe: do not set file's thread_handler if not needed.

Maxim Dounin
September 01, 2016 01:08PM
details: http://hg.nginx.org/nginx/rev/e4c1f5b32868
branches:
changeset: 6673:e4c1f5b32868
user: Maxim Dounin <mdounin@mdounin.ru>
date: Thu Sep 01 20:05:23 2016 +0300
description:
Event pipe: do not set file's thread_handler if not needed.

This fixes a problem with aio threads and sendfile with aio_write switched
off, as observed with range requests after fc72784b1f52 (1.9.13). Potential
problems with sendfile in threads were previously described in 9fd738b85fad,
and this seems to be one of them.

The problem occurred as file's thread_handler was set to NULL by event pipe
code after a sendfile thread task was scheduled. As a result, no sendfile
completion code was executed, and the same buffer was additionally sent
using non-threaded sendfile. Fix is to avoid modifying file's thread_handler
if aio_write is switched off.

Note that with "aio_write on" it is still possible that sendfile will use
thread_handler as set by event pipe. This is believed to be safe though,
as handlers used are compatible.

diffstat:

src/event/ngx_event_pipe.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)

diffs (20 lines):

diff --git a/src/event/ngx_event_pipe.c b/src/event/ngx_event_pipe.c
--- a/src/event/ngx_event_pipe.c
+++ b/src/event/ngx_event_pipe.c
@@ -815,10 +815,12 @@ ngx_event_pipe_write_chain_to_temp_file(
}

#if (NGX_THREADS)
- p->temp_file->thread_write = p->thread_handler ? 1 : 0;
- p->temp_file->file.thread_task = p->thread_task;
- p->temp_file->file.thread_handler = p->thread_handler;
- p->temp_file->file.thread_ctx = p->thread_ctx;
+ if (p->thread_handler) {
+ p->temp_file->thread_write = 1;
+ p->temp_file->file.thread_task = p->thread_task;
+ p->temp_file->file.thread_handler = p->thread_handler;
+ p->temp_file->file.thread_ctx = p->thread_ctx;
+ }
#endif

n = ngx_write_chain_to_temp_file(p->temp_file, out);

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

[nginx] Event pipe: do not set file's thread_handler if not needed.

Maxim Dounin 368 September 01, 2016 01:08PM



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

Online Users

Guests: 193
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready