summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-10-22Handling of timers with bias.Valentin Bartenev5-23/+30
Timers that don't require maximum precision (most of them, actually) can be triggered earlier or later within the bias interval. To reduce wakeups by timers, the expire function now triggers not only all timers that fall within the elapsed time, but also those whose bias falls within this interval.
2018-10-22Timers: separation of delete and insert operations on rbtree.Valentin Bartenev1-10/+20
Delete/insert operation complexity for a red-black tree is O(log n), where n is the total number of tree elements. If all delete operations are performed before all insert operations, the average number of tree elements during an operation will be lower than in the mixed-operations case.
2018-10-22Re-engineered timers.Valentin Bartenev3-97/+78
To optimize rbtree operations, all changes are stored in array and later processed in batches. The previous implementation of this mechanics had a number of design flaws. Each change was saved in a new array entry; until the changes were applied, the timer remained in an intermediate state (NXT_TIMER_CHANGING). This intermediate state didn't allow to identify if time was going to be disabled or enabled. However, the nxt_conn_io_read() function relied on this information; as a result, in some cases the read timeout wasn't set. Also, the nxt_timer_delete() function did not reliably track whether a timer was added to the work queue. It checked the NXT_TIMER_ENQUEUED state of a timer, but this state could be reset to NXT_TIMER_DISABLED by a nxt_timer_disable() call or another nxt_timer_delete() call. Now, instead of keeping the whole history of the timer's changes, the new implementation updates the timer state immediately, and only one operation is added to the array to add or delete timer in the rbtree according to its final state.
2018-10-22Compatibility with LibreSSL.Sergey Kandaurov1-1/+1
LibreSSL uses high OPENSSL_VERSION_NUMBER, but has no SSL_CTX_add0_chain_cert().
2018-10-09Renamed "go" application type to "external".Valentin Bartenev7-78/+81
There's nothing specific to Go language. This type of application object can be used to run any external application that utilizes libunit API.
2018-10-03Added Node.js support.Alexander Borisov10-0/+1500
2018-10-02Filling cmsghdr with 0 to pass Go 1.11 message validation.Max Romanov1-4/+5
2018-10-02Go: fixing typo in log messages.Max Romanov2-2/+2
2018-10-02Making port fd blocking on app side and non-blocking in Unit.Max Romanov2-1/+12
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-10-01Disabled chunked transfer encoding for 304 responses as well.Valentin Bartenev1-1/+1
According to RFC 7232: | A 304 response cannot contain a message-body; it is always terminated | by the first empty line after the header fields.
2018-10-01Allowing keep-alive connections after 204 responses.Valentin Bartenev1-5/+7
This was unintentionally disabled by 7b5026a0bdeb.
2018-10-01Fixed error log time caching resolution.Valentin Bartenev1-1/+1
Thanks to 洪志道 (Hong Zhi Dao).
2018-09-28Disabled chunked transfer encoding for 204 responses.Igor Sysoev2-1/+3
2018-09-28Fixed bug in socket write error handling.Igor Sysoev1-1/+3
The bug has been introduced in e3972a4a9c73.
2018-09-28Version bump.Valentin Bartenev1-2/+2
2018-09-20Resetting init->stream for ready process.Max Romanov1-0/+4
Router requests application start by sending port message with application parameters to master. In response router gets application port. Stream id used to link request and response. If application process terminates unexpectedly (e.g. before ready state), it is required to notify router about application start failure. For this purpose stream id is stored in process initialization parameters. Stream id sequentially incremented and starts from 1 in case of router resurrection. New router application start stream id may coincide with stream id of currently running/terminating application processes. In such cases router may receive REMOVE_PID message with same stream id as used in application start request and mistakenly reports application start failure. This commit tries to avoid such errors by resetting stream for processes in ready state.
2018-09-20Fixed building perl on Alpine Linux.Sergey Kandaurov1-0/+1
_GNU_SOURCE is required there to expose off64_t and other types.
2018-09-20Preventing port from release in asynchronous operations.Max Romanov1-0/+12
Router reconfiguration may lead to starting new application processes, opening listen ports etc. These actions are asynchronous and require message exchange with master process. Router stores reference for controller (response) port in structure associated with reconfiguration process (tmcf). The port used to provide reconfiguration response (either success or failed) to controller. This commit increases response port use counter to make sure port structure not freed while router waits for result of asynchronous operations.
2018-09-20Python: adjusted input.read(size) argument value interpretation.Valentin Bartenev1-3/+5
Previously, passing 0 resulted in reading the whole body and all negative values raised an exception. Now the behaviour is in consistentance with io.RawIOBase.read() interface, and passing 0 returns empty (byte) string, while -1 results in reading the whole body.
2018-09-20Preserving inherited engine memory pool in controller process.Max Romanov1-8/+0
The pool is inherited from master process since changeset 854a1a440616.
2018-09-20Controller: addressing of array elements in requests.Valentin Bartenev1-1/+20
2018-09-20Controller: certificates storage interface.Valentin Bartenev15-43/+2102
2018-09-20Deduplicated string value initializations.Valentin Bartenev2-64/+23
2018-09-20Added nginx error 497 response.Igor Sysoev2-0/+22
2018-09-20Added SSL/TLS support on connection level.Igor Sysoev18-588/+915
2018-09-19Initializing application structure with 0 to avoid crash.Max Romanov1-2/+7
Attribute 'application' is optional in listener object. This commit adds missing code to reset 'lscf' to avoid garbage and crash when the attribute is absent.
2018-09-19Initializing user_cred gids and ngroups for MacOS.Max Romanov1-0/+4
2018-09-18Fixed more typos.Valentin Bartenev2-2/+2
Thanks to 洪志道 (Hong Zhi Dao).
2018-09-17Fixed non-auto-reset timers.Igor Sysoev1-10/+5
2018-09-17Removed deprecated MacOSX OSSpinLockLock().Igor Sysoev2-57/+2
2018-09-17Fixed typo.Igor Sysoev1-1/+1
This closes #166 issue on GitHub. Thanks to 洪志道 (Hong Zhi Dao).
2018-09-17Fixed typo.Igor Sysoev1-1/+1
This closes #165 issue on GitHub. Thanks to 洪志道 (Hong Zhi Dao).
2018-09-07Misspelled variable names fixed.Max Romanov4-7/+7
2018-08-10Stopping all application processes if router process dies.Max Romanov3-3/+29
Unit master process restarts the router if the router accidentally dies. New router process receives the configuration from controller and starts configured applications. The information of running applications cannot be transferred to router because currently there is no persistent application identifier. To avoid orphan application processes started by died router, master process stops all currently running applications once it receives SIGCHLD for router process.
2018-08-10Introducing app joint to accurate app release.Max Romanov3-93/+168
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-08-08Perl: use of portable macro instead of an explicit declaration.Alexander Borisov1-2/+2
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-06Python: decoding unicode strings as Latin1.Max Romanov1-5/+6
According to PEP 3333, header names and values should be decoded as Latin1.
2018-08-06Unit application library.Max Romanov42-4336/+6493
Library now used in all language modules. Old 'nxt_app_*' code removed. See src/test/nxt_unit_app_test.c for usage sample.
2018-07-30Fixed segfault on listening socket close.Igor Sysoev2-13/+56
Now keep-alive connection sends 408 response if listening socket was closed while reconfiguration.
2018-07-30Sending 408 response on idle connection timeout.Igor Sysoev3-26/+127
2018-07-27Removed implicit call of nxt_thread() in nxt_thread_tid().Valentin Bartenev3-6/+2
Explicit is better than implicit © The Zen of Python. The nxt_thread_tid(NULL) call was used only twice in the code and such behaviour was specific to nxt_thread_tid() function.
2018-07-27Added OpenBSD 3.9 getthrid().Igor Sysoev1-0/+12
Prodded by David Carlier.
2018-07-27Refactored thread ID functions.Igor Sysoev3-174/+150
nxt_thread_tid() was moved to src/nxt_thread.c nxt_thread_get_tid() was moved to src/nxt_thread_id.h. src/nxt_thread_id.c was removed.
2018-07-16Added getentropy() support.Sergey Kandaurov2-0/+10
Prodded by David Carlier.
2018-07-16Version bump.Valentin Bartenev1-2/+2
2018-07-12Fixed socket write error handling.Igor Sysoev1-10/+17
2018-07-12Disabling keep-alive connection on errors.Igor Sysoev1-10/+17