summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_port_socket.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-06-22Constified numerous function parameters.Andrew Clayton1-2/+2
As was pointed out by the cppcheck[0] static code analysis utility we can mark numerous function parameters as 'const'. This acts as a hint to the compiler about our intentions and the compiler will tell us when we deviate from them. [0]: https://cppcheck.sourceforge.io/
2021-11-09Introduced SCM_CREDENTIALS / SCM_CREDS in the socket control msgs.Tiago Natel de Moura1-27/+54
2021-07-01Deduplicating code for closing fds in nxt_port_send_msg_t.Max Romanov1-39/+25
2021-07-01Fixing memory and descriptor leakage in case of port send failure.Max Romanov1-0/+18
In rare cases, when the destination process had finished running but no notification of this was received yet, send could fail with an error, and the send message structure with file descriptors could leak. The leakage was periodically reproduced by respawn tests on FreeBSD 12.
2021-03-25Fixing shm buffer leakage when sending over the port queue.Max Romanov1-13/+84
When the shm buffer is sent over the port queue, it needs to be completed because it's sent over the port socket.
2020-08-12Fixing issues found by static analyzer.Max Romanov1-2/+4
2020-08-11Style fixes for 2 file descriptors transfer over port.Max Romanov1-37/+41
Two consecutive fd and fd2 fields replaced with array.
2020-08-11Introducing application and port shared memory queues.Max Romanov1-21/+250
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-1/+25
2020-05-28Closing unsent file descriptors from port queue.Max Romanov1-0/+6
After a process exits, all ports linked to it from other processes should be closed. All unsent file descriptors in port queue, marked as "close after send", should be closed to avoid resource leakage.
2019-11-14Introduced chained buffer completion handlers.Igor Sysoev1-6/+16
2019-08-16Fixing multi-thread port write racing conditions.Max Romanov1-149/+159
2019-06-28Fixing allocation alignment for port fragments.Max Romanov1-1/+1
All allocated blocks for lvlhash required to be aligned because lower address bits used for various extra information. Using unaligned blocks may cause invalid memory aceess. This was issue found on buildbot running large configuration tests.
2019-03-25Turning off port read event state after main process fork.Max Romanov1-0/+1
Master port stores two file descriptors and works as a read port on the master process side. After a fork, the port switches into write mode and the read socket closes, but the same event structure is used for the write socket. However, the inherited structure remained in read state, telling the epoll engine to use MOD operation instead of ADD. The patch resets read event state, so the engine may write using proper ADD operation.
2019-03-05Improving port message fragment recognition.Max Romanov1-16/+36
This is required to assemble fragmented messages correctly. Stream identifier is unique only for messages generated within a process, but the (stream, pid) pair should be enough to avoid collisions. Adding reply_port seems redundant because it's enough to add stream to a pid. This closes #199 issue on GitHub. Thanks to 洪志道 (Hong Zhi Dao).
2019-03-05Fixing EAGAIN processing for port message send.Max Romanov1-8/+26
Sending large plain (exceeding port's max_size, not in shared memory) messages causes message fragmentation. First message fragment is sent successfully, but the next fragment may fail with the EAGAIN error. In this case, the message has to be pushed back to queue head for additional processing. Related to #167 issue on GitHub.
2019-03-05Including port message header into message size limit.Max Romanov1-0/+2
Before this fix, large plain message (i.e. configuration) send may fail with the 'Message too big' error, because internal fragmentation implementation does not account for 16 byte message header. This closes #167 issue on GitHub.
2019-02-28Preserving message 'share' field when pushing to queue.Max Romanov1-0/+1
As far as I understand, this field is important to control the number of buffers send in a single write attempt. Furthermore, having uninitialized field is always bad. This closes #204 issue on GitHub. Thanks to 洪志道 (Hong Zhi Dao).
2019-02-28Reusing fragmented message buffers.Max Romanov1-1/+9
Fragmented message non-mmap buffer chain not freed nor reused before this fix. This closes #206 on GitHub. Thanks to 洪志道 (Hong Zhi Dao).
2018-04-05Style.Valentin Bartenev1-4/+4
2018-03-28nxt_port_buf_completion() and nxt_sendbuf_completion().Igor Sysoev1-1/+64
nxt_sendbuf_completion() has been renamed to nxt_port_buf_completion() and moved to src/nxt_port_socket.c. nxt_sendbuf_completion0() has been renamed to nxt_sendbuf_completion().
2018-03-05Reduced number of critical log levels.Valentin Bartenev1-12/+5
2018-02-20Removed unwanted assertions.Max Romanov1-3/+9
2018-02-07Style fixes.Andrey Zelenkov1-1/+1
2017-12-28Changed nxt_mp_retain() and nxt_mp_release() interfaces.Igor Sysoev1-3/+8
2017-12-28Removed unused variable assignment.Max Romanov1-1/+0
Found by Coverity (CID 215301).
2017-12-27Implementing the ability to cancel request before worker starts processing it.Max Romanov1-33/+71
2017-11-02Fixing build on Solaris.Max Romanov1-1/+1
2017-10-04Port message fragmentation supported.Max Romanov1-4/+179
- 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-04Breaking read loop by nxt_port_read_close().Max Romanov1-0/+1
Port message handler may perform fork() and then close port read file descriptor and enable write on same event fd. Next read attempt in this case may cause different errors in log file.
2017-10-04Optimized send message allocations.Max Romanov1-40/+102
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-34/+70
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/+3
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-06Style fixes.Igor Sysoev1-4/+4
2017-08-11Sync flag introduced for port type.Max Romanov1-3/+9
To avoid transfer mmap_msg before new mmap message.
2017-08-11Tiny mmap buffers completion fixed.Max Romanov1-1/+2
Small mmap buffers transferred in 'plain' mode and should be freed by sender.
2017-08-02Added basic port error handler.Max Romanov1-16/+38
2017-08-02Implicit port read buffer completion.Max Romanov1-7/+20
To disable implicit completion, handler should reset msg->buf field.
2017-08-02Added bit flags to type parameter of nxt_port_socket_write().Max Romanov1-3/+15
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-18Port allocation and destroy changed. Worker process stop introduced.Max Romanov1-20/+4
2017-07-12New process port exchange changed. READY message type introduced.Max Romanov1-3/+10
Application process start request DATA message from router to master. Master notifies router via NEW_PORT message after worker process become ready.
2017-07-07Work queue thread safety checks for DEBUG build.Max Romanov1-7/+5
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-07Redirecting buffer completion handler to specific engine.Max Romanov1-2/+44
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-23Increased size of iovec when data passed using shared memory.Max Romanov1-2/+4
Useful for tiny shared memory segment test case.
2017-06-23Added mem_pool pointer member to nxt_port_send_msg_t.Max Romanov1-1/+2
To decouple nxt_port_send_msg_t from port.
2017-06-23Moved message size to nxt_port_recv_msg_t for convenience.Max Romanov1-33/+12
2017-06-20Using new memory pool implementation.Igor Sysoev1-9/+8
2017-05-12Using shared memory to send data via nxt_port.Max Romanov1-40/+101
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-02-22Port changes.Igor Sysoev1-43/+29