diff options
author | Max Romanov <max.romanov@nginx.com> | 2020-10-28 00:01:46 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2020-10-28 00:01:46 +0300 |
commit | 00561a961f8c7727556271e424e1e425ac9a88ce (patch) | |
tree | 6eb8136a6f287a8b08d764dfd98cbb25f09c57f7 /src/nxt_unit.c | |
parent | 779b1131c56539ed74ab9db9a03f7bff71e203ba (diff) | |
download | unit-00561a961f8c7727556271e424e1e425ac9a88ce.tar.gz unit-00561a961f8c7727556271e424e1e425ac9a88ce.tar.bz2 |
Libunit: protecting the new mmap from being used in another thread.
Until the mmap is received by the router, only the creator thread may use this
mmap, so the "mmap not found" state in the router is avoided.
Diffstat (limited to 'src/nxt_unit.c')
-rw-r--r-- | src/nxt_unit.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nxt_unit.c b/src/nxt_unit.c index f75d61bc..65a76bee 100644 --- a/src/nxt_unit.c +++ b/src/nxt_unit.c @@ -314,6 +314,7 @@ struct nxt_unit_ctx_impl_s { struct nxt_unit_mmap_s { nxt_port_mmap_header_t *hdr; + pthread_t src_thread; /* of nxt_unit_read_buf_t */ nxt_queue_t awaiting_rbuf; @@ -3389,7 +3390,10 @@ retry: for (mm = lib->outgoing.elts; mm < mm_end; mm++) { hdr = mm->hdr; - if (hdr->sent_over != 0xFFFFu && hdr->sent_over != port->id.id) { + if (hdr->sent_over != 0xFFFFu + && (hdr->sent_over != port->id.id + || mm->src_thread != pthread_self())) + { continue; } @@ -3657,6 +3661,7 @@ nxt_unit_new_mmap(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port, int n) hdr->src_pid = lib->pid; hdr->dst_pid = port->id.pid; hdr->sent_over = port->id.id; + mm->src_thread = pthread_self(); /* Mark first n chunk(s) as busy */ for (i = 0; i < n; i++) { |