summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_port.h (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-08-11Introducing application and port shared memory queues.Max Romanov1-5/+20
The goal is to minimize the number of syscalls needed to deliver a message.
2020-08-11Port message extended to transfer 2 file descriptors.Max Romanov1-0/+2
2020-08-11Introducing the shared application port.Max Romanov1-4/+7
This is the port shared between all application processes which use it to pass requests for processing. Using it significantly simplifies the request processing code in the router. The drawback is 2 more file descriptors per each configured application and more complex libunit message wait/read code.
2020-08-11Changing router to application shared memory exchange protocol.Max Romanov1-0/+7
The application process needs to request the shared memory segment from the router instead of the latter pushing the segment before sending a request to the application. This is required to simplify the communication between the router and the application and to prepare the router for using the application shared port and then the queue.
2020-08-11Changing router to application port exchange protocol.Max Romanov1-0/+9
The application process needs to request the port from the router instead of the latter pushing the port before sending a request to the application. This is required to simplify the communication between the router and the application and to prepare the router to use the application shared port and then the queue.
2020-03-09Refactor of process management.Tiago Natel de Moura1-70/+71
The process abstraction has changed to: setup(task, process) start(task, process_data) prefork(task, process, mp) The prefork() occurs in the main process right before fork. The file src/nxt_main_process.c is completely free of process specific logic. The creation of a process now supports a PROCESS_CREATED state. The The setup() function of each process can set its state to either created or ready. If created, a MSG_PROCESS_CREATED is sent to main process, where external setup can be done (required for rootfs under container). The core processes (discovery, controller and router) doesn't need external setup, then they all proceeds to their start() function straight away. In the case of applications, the load of the module happens at the process setup() time and The module's init() function has changed to be the start() of the process. The module API has changed to: setup(task, process, conf) start(task, data) As a direct benefit of the PROCESS_CREATED message, the clone(2) of processes using pid namespaces now doesn't need to create a pipe to make the child block until parent setup uid/gid mappings nor it needs to receive the child pid.
2019-12-24Introducing port messages to notify about out of shared memory.Max Romanov1-0/+9
- OOSM (out of shared memory). Sent by application process to router when application reaches the limit of allocated shared memory and needs more. - SHM_ACK. Sent by router to application when the application's shared memory is released and the OOSM flag is enabled for the segment. This implements blocking mode (the library waits for SHM_ACK in case of out of shared memory condition and retries allocating the required memory amount) and non-blocking mode (the library notifies the application that it's out of shared memory and returns control to the application module that sets up the output queue and puts SHM_ACK in the main message loop).
2019-11-26Refactor of process init.Tiago Natel1-1/+1
Introduces the functions nxt_process_init_create() and nxt_process_init_creds_set().
2019-08-20Introducing websocket support in router and libunit.Max Romanov1-0/+15
2019-08-16Fixing multi-thread port write racing conditions.Max Romanov1-6/+2
2018-09-20Controller: certificates storage interface.Valentin Bartenev1-0/+6
2018-04-11Initial access log support.Valentin Bartenev1-0/+3
2018-04-05Style.Valentin Bartenev1-8/+8
2018-01-29Introducing extended app process management.Max Romanov1-0/+3
- Pre-fork 'processes.spare' application processes; - fork more processes to keep 'processes.spare' idle processes; - fork on-demand up to 'processes.max' count; - scale down idle application processes above 'processes.spare' after 'processes.idle_timeout'; - number of concurrently started application processes also limited by 'processes.spare' (or 1, if spare is 0).
2017-12-27Fixing application timeout.Max Romanov1-0/+6
Application timeout limits maximum time of worker response in processing particular request. Not including the time required to start worker, time in request queue etc.
2017-12-27Changing worker selection precedence.Max Romanov1-1/+1
This patch increase precedence of non-started worker over busy worker. 1. idle worker; 2. start new worker; 3. busy worker, but can accept request in advance;
2017-12-27Implementing the ability to cancel request before worker starts processing it.Max Romanov1-4/+23
2017-11-02Fixing build on Solaris.Max Romanov1-1/+1
2017-10-19Filtering process to keep connection.Max Romanov1-2/+0
- Main process should be connected to all other processes. - Controller should be connected to Router. - Router should be connected to Controller and all Workers. - Workers should be connected to Router worker thread ports only. This filtering helps to avoid unnecessary communication and various errors during massive application workers stop / restart.
2017-10-04Port message fragmentation supported.Max Romanov1-0/+5
- Each sendmsg() transmits no more than port->max_size payload data. - Longer buffers are fragmented and send using multiple sendmsg() calls. - On receive side, buffers are connected in chain. - Number of handler calls is the same as number of nxt_port_socket_write() calls. - nxt_buf_make_plain() function introduced to make single plain buffer from the chain.
2017-10-04Using port 'post' facility to proxy remove pid message to workers.Max Romanov1-1/+5
Remove pid proxying to worker engines implementation was originally overcomplicated. Memory pool and 2 engine posts (there and back again) are optimized out and replaced with band new nxt_port_post() call.
2017-10-04Optimized send message allocations.Max Romanov1-2/+0
For empty write queue cases, it is possible to avoid allocation and enqueue send message structures. Send message initialized on stack and passed to write handler. If immediate write fails, send message allocated from engine pool and enqueued.
2017-10-04Introducing use counters for port and app. Thread safe port write.Max Romanov1-4/+13
Use counter helps to simplify logic around port and application free. Port 'post' function introduced to simplify post execution of particular function to original port engine's thread. Write message queue is protected by mutex which makes port write operation thread safe.
2017-09-15Introducing named port message handlers to avoid misprints.Max Romanov1-29/+73
2017-09-15Introducing application timeout.Max Romanov1-2/+1
2017-09-10Configuration persistence.Valentin Bartenev1-0/+2
Now configuration survives server reloads.
2017-08-17The new module configuration interface.Igor Sysoev1-0/+2
Configuration and building example: ./configure ./configure python ./configure php ./configure go make all or ./configure make nginext ./configure python make python ./configure php make php ./configure go make go Modules configuration options and building examples: ./configure python --module=python2 --config=python2.7-config make python2 ./configure php --module=php7 --config=php7.0-config --lib-path=/usr/local/php7.0 make php7 ./configure go --go=go1.6 --go-path=${HOME}/go1.6 make go1.6
2017-08-11Sync flag introduced for port type.Max Romanov1-1/+3
To avoid transfer mmap_msg before new mmap message.
2017-08-02Listening socket creation and binding operations are passedIgor Sysoev1-0/+2
to the master process.
2017-08-02Added basic port error handler.Max Romanov1-1/+4
2017-08-02Runtime processes protected with mutex.Max Romanov1-2/+0
2017-08-02Using port rpc in router->master start worker request.Max Romanov1-0/+3
2017-08-02Port RPC interface introduced.Max Romanov1-0/+9
Usage: 1. Register handlers in incoming port with nxt_port_rpc_register_handler(). 2. Use return value as a stream identifier for next nxt_port_socket_write().
2017-08-02Added bit flags to type parameter of nxt_port_socket_write().Max Romanov1-8/+24
NXT_PORT_MSG_LAST - mark message as last; NXT_PORT_MSG_CLOSE_FD - close fd right after send; Type constants altered to include last flag for single buffer messages. Last sign is critical for coming port RPC layer. Handlers unregistered on last message. Create sync buffer is not convenient, extra parameter is better.
2017-07-18Removed NXT_PACKED from port structures.Valentin Bartenev1-2/+2
That was added only to silence Valgrind, but it results in unaligned access (which breaks Unit on ARM architecture).
2017-07-18Request-app link introduced to prevent mp destroy for penging requests.Max Romanov1-0/+1
nxt_req_conn_link_t still used for lookup connection by request id. New nxt_req_app_link_t (ra) allocated from conn->mem_pool using mp_retain(). ra stored in app->requests if there is no free worker to process request.
2017-07-18Port allocation and destroy changed. Worker process stop introduced.Max Romanov1-0/+5
2017-07-12New process port exchange changed. READY message type introduced.Max Romanov1-8/+18
Application process start request DATA message from router to master. Master notifies router via NEW_PORT message after worker process become ready.
2017-07-07Process stop notification from master to all other processes.Max Romanov1-4/+5
New port message type introduced NXT_PORT_MSG_REMOVE_PID. Default handler removes process description from nxt_runtime_t with all ports, incoming and outgoing mmaps etc.
2017-07-07Cosmetic changes to remove some annoying valgrind messages.Max Romanov1-2/+2
2017-07-07Redirecting buffer completion handler to specific engine.Max Romanov1-1/+4
There is a case in router where we use port in router connection thread. Buffers are allocated within connection memory pool which can be used only in this router thread. sendmsg() can be postponed into main router thread and completion handler will compare current engine and post itself to correct engine.
2017-06-23Added mem_pool pointer member to nxt_port_send_msg_t.Max Romanov1-0/+1
To decouple nxt_port_send_msg_t from port.
2017-06-23Moved message size to nxt_port_recv_msg_t for convenience.Max Romanov1-0/+1
2017-06-23Extruded nxt_port_send_port() to send port to one process.Max Romanov1-0/+2
2017-06-23nxt_port_create() use task instead of thread.Max Romanov1-1/+1
Write socket close() call moved out from nxt_port_create().
2017-06-20Using new memory pool implementation.Igor Sysoev1-1/+1
2017-05-12Using shared memory to send data via nxt_port.Max Romanov1-17/+32
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);
2017-03-09Processes refactoring.Igor Sysoev1-12/+5
The cycle has been renamed to the runtime.
2017-02-22Port changes.Igor Sysoev1-35/+90
2017-02-01Process channels have been renamed to ports.Igor Sysoev1-0/+68