summaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2016-03-18 06:44:03 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2016-03-18 06:44:03 +0300
commit10c8c8d6a47db5e84825479438ce5848b2d1dda4 (patch)
tree138823fa36c8dd88561aa8da309fa062ec597eba /src/core
parentac78b26324a348ebdd108de0c022729b671549fb (diff)
downloadnginx-10c8c8d6a47db5e84825479438ce5848b2d1dda4.tar.gz
nginx-10c8c8d6a47db5e84825479438ce5848b2d1dda4.tar.bz2
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.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ngx_file.c9
-rw-r--r--src/core/ngx_file.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index 3ebd73d8b..2dc222865 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -124,6 +124,15 @@ ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
}
}
+#if (NGX_THREADS && NGX_HAVE_PWRITEV)
+
+ if (tf->thread_write) {
+ return ngx_thread_write_chain_to_file(&tf->file, chain, tf->offset,
+ tf->pool);
+ }
+
+#endif
+
return ngx_write_chain_to_file(&tf->file, chain, tf->offset, tf->pool);
}
diff --git a/src/core/ngx_file.h b/src/core/ngx_file.h
index aeb6c0cb2..5f8228b7b 100644
--- a/src/core/ngx_file.h
+++ b/src/core/ngx_file.h
@@ -78,6 +78,7 @@ typedef struct {
unsigned log_level:8;
unsigned persistent:1;
unsigned clean:1;
+ unsigned thread_write:1;
} ngx_temp_file_t;