summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_port_memory.h
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-05-12 20:32:41 +0300
committerMax Romanov <max.romanov@nginx.com>2017-05-12 20:32:41 +0300
commitf7b4bdfd892a0b479dc946896435a3ba7f9615dd (patch)
treea6f0c4ebaeed2d9f0fcb1c07178b52a684a53280 /src/nxt_port_memory.h
parent1782c771fab999b37a8c04ed72760e3528205be7 (diff)
downloadunit-f7b4bdfd892a0b479dc946896435a3ba7f9615dd.tar.gz
unit-f7b4bdfd892a0b479dc946896435a3ba7f9615dd.tar.bz2
Using shared memory to send data via nxt_port.
Usage: b = nxt_port_mmap_get_buf(task, port, size); b->mem.free = nxt_cpymem(b->mem.free, data, size); nxt_port_socket_write(task, port, NXT_PORT_MSG_DATA, -1, 0, b);
Diffstat (limited to 'src/nxt_port_memory.h')
-rw-r--r--src/nxt_port_memory.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/nxt_port_memory.h b/src/nxt_port_memory.h
new file mode 100644
index 00000000..9ad4e2a4
--- /dev/null
+++ b/src/nxt_port_memory.h
@@ -0,0 +1,50 @@
+
+#ifndef _NXT_PORT_MEMORY_H_INCLUDED_
+#define _NXT_PORT_MEMORY_H_INCLUDED_
+
+#define PORT_MMAP_MIN_SIZE (3 * sizeof(uint32_t))
+
+typedef struct nxt_port_mmap_header_s nxt_port_mmap_header_t;
+
+void
+nxt_port_mmap_destroy(nxt_port_mmap_t *port_mmap);
+
+/*
+ * Allocates nxt_but_t structure from port's mem_pool, assigns this buf 'mem'
+ * pointers to first available shared mem bucket(s). 'size' used as a hint to
+ * acquire several successive buckets if possible.
+ *
+ * This function assumes that current thread operates the 'port' exclusively.
+ */
+nxt_buf_t *
+nxt_port_mmap_get_buf(nxt_task_t *task, nxt_port_t *port, size_t size);
+
+nxt_port_mmap_t *
+nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process,
+ nxt_fd_t fd);
+
+void
+nxt_port_mmap_write(nxt_task_t *task, nxt_port_t *port,
+ nxt_port_send_msg_t *msg, nxt_sendbuf_coalesce_t *sb);
+
+nxt_inline void
+nxt_port_mmap_completion(nxt_task_t *task, nxt_work_queue_t *wq, nxt_buf_t *b) {
+ nxt_work_queue_add(wq, b->completion_handler, task, b, b->parent);
+}
+
+void
+nxt_port_mmap_read(nxt_task_t *task, nxt_port_t *port,
+ nxt_port_recv_msg_t *msg, size_t size);
+
+enum nxt_port_method_e {
+ NXT_PORT_METHOD_ANY = 0,
+ NXT_PORT_METHOD_PLAIN,
+ NXT_PORT_METHOD_MMAP
+};
+
+typedef enum nxt_port_method_e nxt_port_method_t;
+
+nxt_port_method_t
+nxt_port_mmap_get_method(nxt_task_t *task, nxt_port_t *port, nxt_buf_t *b);
+
+#endif /* _NXT_PORT_MEMORY_H_INCLUDED_ */