Deleted Added
1
2/*
3 * Copyright (C) Max Romanov
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

--- 144 unchanged lines hidden (view full) ---

153
154 } else {
155 p = b->mem.start;
156 c = nxt_port_mmap_chunk_id(hdr, p);
157 }
158
159 nxt_port_mmap_free_junk(p, b->mem.end - p);
160
161 nxt_debug(task, "mmap buf completion: %p [%p,%uz] (sent=%d), "
162 "%PI->%PI,%d,%d", b, b->mem.start, b->mem.end - b->mem.start,
163 b->is_port_mmap_sent, hdr->src_pid, hdr->dst_pid, hdr->id, c);
164
165 while (p < b->mem.end) {
166 nxt_port_mmap_set_chunk_free(hdr->free_map, c);
167
168 p += PORT_MMAP_CHUNK_SIZE;
169 c++;

--- 380 unchanged lines hidden (view full) ---

550 nxt_chunk_id_t c;
551 nxt_port_mmap_header_t *hdr;
552 nxt_port_mmap_handler_t *mmap_handler;
553 nxt_port_mmap_tracking_msg_t *tracking_msg;
554
555 b = msg->buf;
556
557 if (nxt_buf_used_size(b) < (int)sizeof(nxt_port_mmap_tracking_msg_t)) {
558 nxt_debug(task, "too small message %O", nxt_buf_used_size(b));
559 return 0;
560 }
561
562 tracking_msg = (nxt_port_mmap_tracking_msg_t *) b->mem.pos;
563
564 b->mem.pos += sizeof(nxt_port_mmap_tracking_msg_t);
565 mmap_handler = nxt_port_get_port_incoming_mmap(task, msg->port_msg.pid,
566 tracking_msg->mmap_id);

--- 57 unchanged lines hidden (view full) ---

624 b->mem.free = b->mem.start;
625 b->mem.end = b->mem.start + PORT_MMAP_CHUNK_SIZE;
626
627 nchunks = size / PORT_MMAP_CHUNK_SIZE;
628 if ((size % PORT_MMAP_CHUNK_SIZE) != 0 || nchunks == 0) {
629 nchunks++;
630 }
631
632 nxt_debug(task, "outgoing mmap buf allocation: %p [%p,%uz] %PI->%PI,%d,%d",
633 b, b->mem.start, b->mem.end - b->mem.start,
634 hdr->src_pid, hdr->dst_pid, hdr->id, c);
635
636 c++;
637 nchunks--;
638
639 /* Try to acquire as much chunks as required. */
640 while (nchunks > 0) {

--- 63 unchanged lines hidden (view full) ---

704 && min_size > free_size + PORT_MMAP_CHUNK_SIZE * (c - start))
705 {
706 c--;
707 while (c >= start) {
708 nxt_port_mmap_set_chunk_free(hdr->free_map, c);
709 c--;
710 }
711
712 nxt_debug(task, "failed to increase, %uz chunks busy", nchunks);
713
714 return NXT_ERROR;
715
716 } else {
717 b->mem.end += PORT_MMAP_CHUNK_SIZE * (c - start);
718
719 return NXT_OK;
720 }

--- 34 unchanged lines hidden (view full) ---

755 b->mem.start = nxt_port_mmap_chunk_start(hdr, mmap_msg->chunk_id);
756 b->mem.pos = b->mem.start;
757 b->mem.free = b->mem.start + mmap_msg->size;
758 b->mem.end = b->mem.start + nchunks * PORT_MMAP_CHUNK_SIZE;
759
760 b->parent = mmap_handler;
761 nxt_port_mmap_handler_use(mmap_handler, 1);
762
763 nxt_debug(task, "incoming mmap buf allocation: %p [%p,%uz] %PI->%PI,%d,%d",
764 b, b->mem.start, b->mem.end - b->mem.start,
765 hdr->src_pid, hdr->dst_pid, hdr->id, mmap_msg->chunk_id);
766
767 return b;
768}
769
770
771void

--- 157 unchanged lines hidden ---