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.
This commit is contained in:
Max Romanov
2017-10-19 17:37:02 +03:00
parent 6532e46465
commit 6031c63225
3 changed files with 146 additions and 87 deletions

View File

@@ -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;