summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_port_memory.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2018-07-12 16:06:36 +0300
committerMax Romanov <max.romanov@nginx.com>2018-07-12 16:06:36 +0300
commit4d818a6f237a5da6c600d648158639edc7dda6f3 (patch)
tree72296a77901301f2979cb048e1aa6b370dac8a7d /src/nxt_port_memory.c
parente6cd1c4257945063473d12a1eeed8d07dfe05467 (diff)
downloadunit-4d818a6f237a5da6c600d648158639edc7dda6f3.tar.gz
unit-4d818a6f237a5da6c600d648158639edc7dda6f3.tar.bz2
Enabled body buffer shared memory segmentation.
Changeset #699 fixes shared memory allocation: continous buffer with requested size should be allocated or function failed. For body longer than 10 Mb, this allocation will definitely fails. For body buffer it is not required to send it in a single continous buffer, so, need to request minimum reasonable amount of shared memory and try to extend it, if possible or allocate next buffer.
Diffstat (limited to '')
-rw-r--r--src/nxt_port_memory.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/nxt_port_memory.c b/src/nxt_port_memory.c
index 0c10cdd2..e8af381f 100644
--- a/src/nxt_port_memory.c
+++ b/src/nxt_port_memory.c
@@ -255,11 +255,12 @@ fail:
static nxt_port_mmap_handler_t *
nxt_port_new_port_mmap(nxt_task_t *task, nxt_process_t *process,
- nxt_port_t *port, nxt_bool_t tracking)
+ nxt_port_t *port, nxt_int_t n, nxt_bool_t tracking)
{
void *mem;
u_char *p, name[64];
nxt_fd_t fd;
+ nxt_int_t i;
nxt_free_map_t *free_map;
nxt_port_mmap_t *port_mmap;
nxt_port_mmap_header_t *hdr;
@@ -366,7 +367,9 @@ nxt_port_new_port_mmap(nxt_task_t *task, nxt_process_t *process,
/* Mark first chunk as busy */
free_map = tracking ? hdr->free_tracking_map : hdr->free_map;
- nxt_port_mmap_set_chunk_busy(free_map, 0);
+ for (i = 0; i < n; i++) {
+ nxt_port_mmap_set_chunk_busy(free_map, i);
+ }
/* Mark as busy chunk followed the last available chunk. */
nxt_port_mmap_set_chunk_busy(hdr->free_map, PORT_MMAP_CHUNK_COUNT);
@@ -456,7 +459,7 @@ nxt_port_mmap_get(nxt_task_t *task, nxt_port_t *port, nxt_chunk_id_t *c,
/* TODO introduce port_mmap limit and release wait. */
*c = 0;
- mmap_handler = nxt_port_new_port_mmap(task, process, port, tracking);
+ mmap_handler = nxt_port_new_port_mmap(task, process, port, n, tracking);
unlock_return:
@@ -710,10 +713,7 @@ nxt_port_mmap_increase_buf(nxt_task_t *task, nxt_buf_t *b, size_t size,
size -= free_size;
- nchunks = size / PORT_MMAP_CHUNK_SIZE;
- if ((size % PORT_MMAP_CHUNK_SIZE) != 0 || nchunks == 0) {
- nchunks++;
- }
+ nchunks = (size + PORT_MMAP_CHUNK_SIZE - 1) / PORT_MMAP_CHUNK_SIZE;
c = start;