diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-10-19 17:37:02 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-10-19 17:37:02 +0300 |
commit | 6031c63225838d6bc266c4f015d9a1085f600324 (patch) | |
tree | 5cf5e63f69820d087a91ebdcc786c46cd5bc1be0 /src/nxt_port_memory_int.h | |
parent | 6532e46465276efcedae299ce290eb8dff0ece57 (diff) | |
download | unit-6031c63225838d6bc266c4f015d9a1085f600324.tar.gz unit-6031c63225838d6bc266c4f015d9a1085f600324.tar.bz2 |
Introducing mmap_handler to count references to shared memory.
"All problems in computer science can be
solved by another level of indirection"
Butler Lampson
Completion handlers for application response buffers executed after
sending the data to client. Application worker can be stopped right
after send response buffers to router. Worker stop causes removal
of all data structures for the worker.
To prevent shared memory segment unmap, need to count the number of
buffers which uses it. So instead of direct reference to shared
memory, need to reference to intermediate 'handler' structure with
use counter and pointer to shared memory.
Diffstat (limited to 'src/nxt_port_memory_int.h')
-rw-r--r-- | src/nxt_port_memory_int.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nxt_port_memory_int.h b/src/nxt_port_memory_int.h index 6ccc3d83..0168e1ae 100644 --- a/src/nxt_port_memory_int.h +++ b/src/nxt_port_memory_int.h @@ -55,12 +55,17 @@ struct nxt_port_mmap_header_s { }; +struct nxt_port_mmap_handler_s { + nxt_port_mmap_header_t *hdr; + nxt_atomic_t use_count; +}; + /* * Element of nxt_process_t.incoming/outgoing, shared memory segment * descriptor. */ struct nxt_port_mmap_s { - nxt_port_mmap_header_t *hdr; + nxt_port_mmap_handler_t *mmap_handler; }; typedef struct nxt_port_mmap_msg_s nxt_port_mmap_msg_t; |