summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_unit.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-04-06Fixing 'find & add' racing condition in connected ports hash.Max Romanov1-0/+3
Missing error log messages added.
2020-03-30Fixing application process infinite loop.Max Romanov1-21/+28
Main process exiting before app process init may have caused hanging.
2020-03-30Handling change file message in libunit.Max Romanov1-0/+10
This is required for proper log file rotation action.
2020-03-30Attributing libunit logging function for arguments validation.Max Romanov1-5/+7
2020-03-12Using disk file to store large request body.Max Romanov1-7/+119
This closes #386 on GitHub.
2020-03-12Introducing readline function in libunit.Max Romanov1-0/+38
Ruby and Java modules now use this function instead of own implementations.
2020-02-04Removing duplicate macro definitions.Max Romanov1-4/+0
This issue was introduced in 2c7f79bf0a1f.
2020-02-03Initializing local buffer ctx_impl field for correct release.Max Romanov1-0/+1
Uninitialized ctx_impl field may cause crash in application process. To reproduce the issue, need to trigger shared memory buffer send error on application side. In our case, send error caused by router process crash. This issue was introduced in 2c7f79bf0a1f.
2020-02-03Added missing stream argument to error message.Max Romanov1-1/+2
Found by Coverity (CID 353386).
2019-12-24Introducing port messages to notify about out of shared memory.Max Romanov1-68/+476
- 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-12-24Adding "limits/shm" configuration validation and parsing.Max Romanov1-8/+20
2019-12-24Renaming nxt_unit_mmap_buf_remove to nxt_unit_mmap_buf_unlink.Max Romanov1-7/+7
The function unchains the buffer from the buffer's linked list.
2019-12-24Using non-shared memory buffers for small messages.Max Romanov1-101/+203
Current shared memory buffer implementation uses fixed-size memory blocks, allocating at least 16384 bytes. When application sends data in a large number of small chunks, it makes sense to buffer them or use plain memory buffers to improve performance and reduce memory footprint. This patch introduces minimum size limit (1024 bytes) for shared memory buffers.
2019-11-11Fixing libunit 'off by 2' issue in library.Max Romanov1-2/+10
Name and value in each header are 0-terminated, so additional 2 bytes should be allocated for them. There were several attempts to add these 2 bytes to headers in language modules, but some modules weren't updated. Also, adding these 2 bytes is specific to the implementation which may be changed later, so extending this mechanics to modules may cause errors.
2019-10-10Style fixes.Igor Sysoev1-2/+4
2019-09-19Initial applications isolation support using Linux namespaces.Tiago de Bem Natel de Moura1-1/+1
2019-09-19Releasing WebSocket frame in case of buffer allocation failure.Max Romanov1-0/+2
Found by Coverity (CID 349456).
2019-09-18Fixing request release order to avoid crashes on exit.Max Romanov1-6/+10
Each request references the router process structure that owns all memory maps. The process structure has a reference counter; each request increases the counter to lock the structure in memory until request processing ends. Incoming and outgoing buffers reference memory maps that the process owns, so the process structure should be released only when all buffers are released to avoid invalid memory access and a crash. This describes the libunit library mechanism used for application processes. The background of this issue is as follows: The issue was found on buildbot when the router crashed during Java websocket tests. The Java application receives a notification from the master process; when the notification is processed, libunit deletes the process structure from its process hash and decrements the use counter; however, active websocket connections maintain their use counts on the process structure. After that, when the master process is stopping the application, libunit releases active websocket connections. At this point, it's important to release the connections' memory buffers before the corresponding process structure and all shared memory segments are released.
2019-09-18Reducing number of warning messages.Max Romanov1-6/+5
One alert per failed allocation is enough.
2019-09-18Protecting context structures with mutex.Max Romanov1-4/+63
By design, Unit context is created for the thread which reads messages from the router. However, Go request handlers are called in a separate goroutine that may be executed in a different thread. To avoid a racing condition, access to lists of free structures in the context should be serialized. This patch should fix random crashes in Go applications under high load. This is related to #253 and #309 issues on GitHub.
2019-08-20Introducing websocket support in router and libunit.Max Romanov1-271/+888
2019-03-11Style.Andrey Zelenkov1-2/+2
2019-02-28Various libunit fixes.Max Romanov1-8/+26
This patch contains various logging improvements and bugfixes found during Java module development.
2019-02-27Fixed processing of SERVER_NAME after 77aad2c142a0.Valentin Bartenev1-57/+0
Previously, the nxt_router_prepare_msg() function expected server host among other headers unmodified. It's not true anymore since normalization of the Host header has been introduced in 77aad2c142a0. The nxt_unit_split_host() function was removed. It didn't work correctly with IPv6 literals. Anyway, after 77aad2c142a0 the port splitting is done in router while Host header processing.
2019-02-21Initializing incoming buffer queue in a proper place.Sergey Kandaurov1-2/+2
In case nxt_unit_tracking_read() failed, execution would jump to the error path, where it could try to release buffers from uninitialized yet incoming_buf queue.
2018-10-31Node.js: added async request execution.Alexander Borisov1-2/+1
2018-10-02Filling cmsghdr with 0 to pass Go 1.11 message validation.Max Romanov1-4/+5
2018-10-02Making port fd blocking on app side and non-blocking in Unit.Max Romanov1-1/+10
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-08-07Removing non-required warning.Max Romanov1-5/+0
2018-08-07Improved 'invalid file descriptor' diagnostic.Max Romanov1-0/+14
Unit router process may send mmap file decritptor to the application process for further information exchange. During this process there may be various errors, which should be described in application error log. If file descriptor cannot be properly transferred with 'new mmap' message, fd variable will be assigned to -1 and further syscalls using this file descriptor will fail. For 'new port' message fd is checked in the same way. This commit adds early 'invalid file descriptor' diagnostic and write corresponding message to error log. Found by Coverity (CID 308515).
2018-08-07Fixed unit library mutex usage.Max Romanov1-0/+6
For the optimization purpose, function nxt_unit_remove_process() expects lib->mutex to be locked. The function then moves ports queue into temporary queue and releases mutex. In nxt_unit_done() there were two errors: mutex was not locked before nxt_unit_remove_process() call and mutex was not destroyed. It is hard to tell what was possible negative impact of this errors. Found by Coverity (CID 308517).
2018-08-06Unit application library.Max Romanov1-0/+3630
Library now used in all language modules. Old 'nxt_app_*' code removed. See src/test/nxt_unit_app_test.c for usage sample.