summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_port.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-08-11Introducing the shared application port.Max Romanov1-2/+0
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-03-09Refactor of process management.Tiago Natel de Moura1-1/+3
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-11-26Refactor of process init.Tiago Natel1-1/+1
Introduces the functions nxt_process_init_create() and nxt_process_init_creds_set().
2019-10-29Process port refactoring.Hong Zhi Dao1-17/+3
- Introduced nxt_runtime_process_port_create(). - Moved nxt_process_use() into nxt_process.c from nxt_runtime.c. - Renamed nxt_runtime_process_remove_pid() as nxt_runtime_process_remove(). - Some public functions transformed to static. This closes #327 issue on GitHub.
2019-09-18Fixing master process crash after failed fork.Max Romanov1-1/+1
This closes #312 issue on GitHub.
2019-08-20Introducing websocket support in router and libunit.Max Romanov1-0/+1
2019-03-11Style.Andrey Zelenkov1-1/+1
2018-10-02Making port fd blocking on app side and non-blocking in Unit.Max Romanov1-0/+2
This issue was introduced in libunit commit (e0f0cd7d244a). All port sockets in application should be in blocking mode whereas Unit itself operates non-blocking sockets. Having non-blocking sockets in application may cause send error during intensive response packets generation. See https://mailman.nginx.org/pipermail/unit/2018-October/000080.html.
2018-09-07Misspelled variable names fixed.Max Romanov1-1/+1
2018-08-10Introducing app joint to accurate app release.Max Romanov1-5/+1
For accurate app descriptor release, it is required to count the number of use counts. Use count increased when: - app linked to configuration app queue; - socket conf stores pointer to app; - request for start app process posted to router service thread; Application port has pointer to app, but it does not increase use count to avoid use count loop. Timer needs a pointer to nxt_timer_t which is stored in engine timers tree. nxt_timer_t now resides in nxt_app_joint_t and does not lock the application. Start process port RPC handlers is also linked to nxt_app_joint_t. App joint (nxt_app_joint_t) is a 'weak pointer': - single threaded; - use countable; - store pointer to nxt_app_t (which can be NULL); nxt_app_t has pointer to nxt_app_joint_t and update its pointer to app.
2018-06-18Fixed exit status on start failure.Igor Sysoev1-1/+1
This and previous commit close #131 issue on GitHub.
2018-06-18Removing Unix control socket on start failure.Igor Sysoev1-2/+0
The bug had appeared in 5cc5002a788e when process type has been converted to bitmask. This commit reverts the type back to a number. This commit is related to #131 issue on GitHub.
2018-03-21Triggering RPC error for all handlers on port close.Max Romanov1-0/+2
This is required to avoid crashes and memory leaks on Unit exit.
2018-03-05Reduced number of critical log levels.Valentin Bartenev1-2/+2
2018-02-20Removed unwanted assertions.Max Romanov1-1/+1
2018-01-29Introducing extended app process management.Max Romanov1-0/+1
- 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-28Changed nxt_mp_retain() and nxt_mp_release() interfaces.Igor Sysoev1-1/+1
2017-12-27Fixing application timeout.Max Romanov1-0/+1
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-11-20Fixing Coverity warnings.Max Romanov1-4/+3
CID 200496 CID 200494 CID 200490 CID 200489 CID 200483 CID 200482 CID 200472 CID 200465
2017-10-19Filtering process to keep connection.Max Romanov1-5/+2
- 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/+2
- 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-04Introducing process use counter.Max Romanov1-2/+9
This helps to decouple process removal from port memory pool cleanups.
2017-10-04Using port 'post' facility to proxy remove pid message to workers.Max Romanov1-1/+3
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-04Introducing use counters for port and app. Thread safe port write.Max Romanov1-13/+116
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-10-04Using engine memiory pool for port write allocations.Max Romanov1-2/+4
To allow use port from different threads, the first step is to avoid using port's memory pool for temporary allocations required to send data through the port. Including but not limited by: - buffers for data; - send message structures; - new mmap fd notifications; It is still safe to use port memory pool for incoming buffers allocations because recieve operation bound to single thread.
2017-09-15Introducing named port message handlers to avoid misprints.Max Romanov1-3/+3
2017-09-15Introducing application timeout.Max Romanov1-2/+1
2017-09-06Style fixes.Igor Sysoev1-13/+12
2017-08-29The master process has been renamed to the main process.Igor Sysoev1-2/+2
2017-08-02Added basic port error handler.Max Romanov1-3/+29
2017-08-02Runtime processes protected with mutex.Max Romanov1-28/+6
2017-08-02Implicit port read buffer completion.Max Romanov1-3/+0
To disable implicit completion, handler should reset msg->buf field.
2017-08-02Using port rpc in router->master start worker request.Max Romanov1-1/+7
2017-08-02Port RPC interface introduced.Max Romanov1-0/+3
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-07-18Request-app link introduced to prevent mp destroy for penging requests.Max Romanov1-0/+5
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-18Mem pool cleanup introduced.Max Romanov1-1/+1
Used for connection mem pool cleanup, which can be used by buffers. Used for port mem pool to safely destroy linked process.
2017-07-18Port allocation and destroy changed. Worker process stop introduced.Max Romanov1-13/+65
2017-07-12New process port exchange changed. READY message type introduced.Max Romanov1-17/+78
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-1/+21
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-07Redirecting buffer completion handler to specific engine.Max Romanov1-21/+1
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 basic HTTP request processing in router.Max Romanov1-2/+0
- request to connection mapping in engine; - requests queue in connection; - engine port creation; - connected ports hash for each process; - engine port data messages processing (app responses);
2017-06-23Extruded nxt_port_send_port() to send port to one process.Max Romanov1-26/+34
2017-06-23Store mem_pool in buf->data instead of port for consistency.Max Romanov1-5/+5
2017-06-23nxt_port_create() use task instead of thread.Max Romanov1-4/+3
Write socket close() call moved out from nxt_port_create().
2017-06-20Using new memory pool implementation.Igor Sysoev1-2/+2
2017-05-12Using shared memory to send data via nxt_port.Max Romanov1-50/+77
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-41/+59
The cycle has been renamed to the runtime.
2017-02-22Port changes.Igor Sysoev1-74/+77
2017-02-22I/O operations refactoring.Igor Sysoev1-1/+1
2017-02-01Process channels have been renamed to ports.Igor Sysoev1-0/+265