summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_port_memory.h
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-10-19 17:37:02 +0300
committerMax Romanov <max.romanov@nginx.com>2017-10-19 17:37:02 +0300
commit6031c63225838d6bc266c4f015d9a1085f600324 (patch)
tree5cf5e63f69820d087a91ebdcc786c46cd5bc1be0 /src/nxt_port_memory.h
parent6532e46465276efcedae299ce290eb8dff0ece57 (diff)
downloadunit-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.h')
-rw-r--r--src/nxt_port_memory.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/nxt_port_memory.h b/src/nxt_port_memory.h
index 51c40411..d1f29df8 100644
--- a/src/nxt_port_memory.h
+++ b/src/nxt_port_memory.h
@@ -11,8 +11,9 @@
#define PORT_MMAP_MIN_SIZE (3 * sizeof(uint32_t))
typedef struct nxt_port_mmap_header_s nxt_port_mmap_header_t;
+typedef struct nxt_port_mmap_handler_s nxt_port_mmap_handler_t;
-void nxt_port_mmaps_destroy(nxt_port_mmaps_t *port_mmaps, nxt_bool_t free);
+void nxt_port_mmaps_destroy(nxt_port_mmaps_t *port_mmaps, nxt_bool_t free_elts);
/*
* Allocates nxt_but_t structure from port's mem_pool, assigns this buf 'mem'
@@ -27,7 +28,7 @@ nxt_port_mmap_get_buf(nxt_task_t *task, nxt_port_t *port, size_t size);
nxt_int_t nxt_port_mmap_increase_buf(nxt_task_t *task, nxt_buf_t *b,
size_t size, size_t min_size);
-nxt_port_mmap_header_t *
+nxt_port_mmap_handler_t *
nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process,
nxt_fd_t fd);