Mercurial > hg > nginx
comparison src/core/ngx_file.c @ 6442:6e10518f95d8
Threads: offloading of temp files writing to thread pools.
The ngx_thread_write_chain_to_file() function introduced, which
uses ngx_file_t thread_handler, thread_ctx and thread_task fields.
The task context structure (ngx_thread_file_ctx_t) is the same for
both reading and writing, and can be safely shared as long as
operations are serialized.
The task->handler field is now always set (and not only when task is
allocated), as the same task can be used with different handlers.
The thread_write flag is introduced in the ngx_temp_file_t structure
to explicitly enable use of ngx_thread_write_chain_to_file() in
ngx_write_chain_to_temp_file() when supported by caller.
In collaboration with Valentin Bartenev.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 18 Mar 2016 06:44:03 +0300 |
parents | 7bdd34cd2711 |
children | a5897d360977 |
comparison
equal
deleted
inserted
replaced
6441:9fd738b85fad | 6442:6e10518f95d8 |
---|---|
121 if (tf->log_level) { | 121 if (tf->log_level) { |
122 ngx_log_error(tf->log_level, tf->file.log, 0, "%s %V", | 122 ngx_log_error(tf->log_level, tf->file.log, 0, "%s %V", |
123 tf->warn, &tf->file.name); | 123 tf->warn, &tf->file.name); |
124 } | 124 } |
125 } | 125 } |
126 | |
127 #if (NGX_THREADS && NGX_HAVE_PWRITEV) | |
128 | |
129 if (tf->thread_write) { | |
130 return ngx_thread_write_chain_to_file(&tf->file, chain, tf->offset, | |
131 tf->pool); | |
132 } | |
133 | |
134 #endif | |
126 | 135 |
127 return ngx_write_chain_to_file(&tf->file, chain, tf->offset, tf->pool); | 136 return ngx_write_chain_to_file(&tf->file, chain, tf->offset, tf->pool); |
128 } | 137 } |
129 | 138 |
130 | 139 |