Commit Graph

174 Commits

Author SHA1 Message Date
Max Romanov
2f3b9d4583 Handling error return from application 'run()' function.
Server error response generated or connection closed.
2018-04-05 17:20:26 +03:00
Max Romanov
d748f74f2b Stopping timed out application process. 2018-04-05 17:19:25 +03:00
Igor Sysoev
fa04c05aa0 HTTP: using r->mem_pool retention counter for response buffers. 2018-04-03 16:28:26 +03:00
Igor Sysoev
cd340b09e6 Using more expressive name for field. 2018-03-28 19:09:56 +03:00
Alexander Borisov
37051b6c15 Added Ruby support. 2018-03-21 16:50:07 +03:00
Max Romanov
6da1207d95 Skipping idle state when port already closed. 2018-03-15 17:08:39 +03:00
Max Romanov
7958a22de0 Ignoring response for already terminated request.
Request can be terminated because of invalid response headers and content
should be ignored in this case.
2018-03-14 12:03:47 +03:00
Max Romanov
1ac9db4750 Releasing application on configuration failure. 2018-03-13 15:32:06 +03:00
Max Romanov
ee092b64eb Socket configuration should retain application.
This retains application during reconfiguration if an incoming connection
was already established before the reconfiguration, but no request was yet
created for the connection and thus no application was yet assigned to
the request.
2018-03-07 19:42:06 +03:00
Valentin Bartenev
912a49c609 Reduced number of critical log levels. 2018-03-05 17:32:50 +03:00
Max Romanov
babf67712e Removed unwanted assertions. 2018-02-20 19:00:30 +03:00
Valentin Bartenev
24d07cfdd2 Made nxt_assert() statements to be compiled only with debug. 2018-02-09 19:07:55 +03:00
Valentin Bartenev
fc496c19ac Changed the default number of spare processes to 0. 2018-02-09 19:06:53 +03:00
Igor Sysoev
11d5206866 Router: fixed freed memory access race condition. 2018-02-08 16:51:49 +03:00
Andrey Zelenkov
949ba262cc Style fixes. 2018-02-07 15:34:42 +03:00
Max Romanov
d2c85a2d9e Fixed processing of application response in router.
If the first buffer contained only header and there were other buffers in chain,
those buffers were not processed.  In particular, this broke Perl application
responses with empty body.
2018-02-07 13:47:04 +03:00
Alexander Borisov
960962ddce Added Perl support. 2018-01-31 15:47:00 +03:00
Max Romanov
9cd4fdbdb7 Introducing extended app process management.
- 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).
2018-01-29 16:17:36 +03:00
Sergey Kandaurov
771e9d3cc3 Fixed formatting in nxt_sprintf() and logging. 2018-01-24 15:16:33 +03:00
Sergey Kandaurov
67c64a99fb Using size_t for the field width type of the "%*s" specifier. 2018-01-24 15:16:32 +03:00
Igor Sysoev
ecba3d80f9 Fixing memory leak introduced in changeset 5817734dd9b9. 2017-12-28 20:08:15 +03:00
Igor Sysoev
9a6d3c5775 HTTP keep-alive connections support. 2017-12-28 16:01:06 +03:00
Igor Sysoev
497faf1b9a Changed nxt_mp_retain() and nxt_mp_release() interfaces. 2017-12-28 16:01:06 +03:00
Max Romanov
47bc1c53d6 Implementing worker stop after limits.requests. 2017-12-27 17:48:53 +03:00
Max Romanov
5196cf4d50 Rescheduling of pending request after configured timeout.
New optional configuration parameter introduced: limits.reschedule_timeout.
Default value 1 second.  In the case when request is written to the port
socket 'in advance', it is called 'pending'.

On every completed request, the head of pending request is checked against
reschedule timeout.  If this request waiting for execution longer than
timeout, it is cancelled, new port selected for this request.
2017-12-27 17:48:04 +03:00
Max Romanov
baa8c9387b Fixing code style. 2017-12-27 17:47:42 +03:00
Max Romanov
bef2ec483e Fixing application timeout.
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-27 17:47:18 +03:00
Max Romanov
ab138c9166 Changing worker selection precedence.
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-27 17:46:39 +03:00
Max Romanov
89c0f7c5db Implementing the ability to cancel request before worker starts processing it. 2017-12-27 17:46:17 +03:00
Valentin Bartenev
8830d73261 HTTP parser: reworked header fields handling. 2017-12-25 17:04:22 +03:00
Max Romanov
392abd03e5 Restoring apps in case of reconfiguration error. 2017-12-25 16:24:54 +03:00
Igor Sysoev
80e8ce8322 A number of engine connections is decreased on connection close. 2017-11-27 17:52:28 +03:00
Max Romanov
fc6520d722 Keep application worker until response for all requests received. 2017-10-19 17:37:26 +03:00
Igor Sysoev
0833074f30 Fixed the bug introduced in the previous changeset. 2017-10-19 17:22:33 +03:00
Igor Sysoev
67c066b026 Router: fixed segfault after configuration change. 2017-10-18 18:05:47 +03:00
Igor Sysoev
09ef66d39c Storing memory cache slot hint inside nxt_sockaddr_t. 2017-10-17 16:22:38 +03:00
Valentin Bartenev
e4bea2c75c Optimized application type handling. 2017-10-10 19:15:08 +03:00
Max Romanov
00ecf713e3 Port message fragmentation supported.
- 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-04 15:03:45 +03:00
Max Romanov
0faecee609 Optimized request<->app link allocation.
Only purpose of request<->app link instance is to be enqueued in application
requests queue.

It is possible to avoid request<->app link allocation from memory pool in
case when spare application port is available.  Instance from local stack
can be used to prepare and send message to application.
2017-10-04 15:03:03 +03:00
Max Romanov
85e485776b Using port 'post' facility to proxy remove pid message to workers.
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-04 15:01:15 +03:00
Max Romanov
730f5a9dd9 Using request mem pool for req<->app link.
Request <-> application link structure (nxt_req_app_link_t) used to register
the request in application request queue (nxt_app_t.requests) and generate
application-specific port message.

Now it is allocated from request pool.  This pool created for request parsing
and used to allocate and store information specific to this request.
2017-10-04 15:00:35 +03:00
Max Romanov
a4b5b5d45d Fixed error generation during request processing.
Request can be processed in thread different from the thread where the
connection originally handled.

Because of possible racing conditions, using original connection structures
is unsafe.  To solve this, error condition is registered in 'ra' (request <->
application link) and traversed back to original connection thread where
the error message can be generated and send back to client.
2017-10-04 15:00:05 +03:00
Max Romanov
6a64533fa3 Introducing use counters for port and app. Thread safe port write.
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-04 14:58:47 +03:00
Max Romanov
414d508e04 Using engine memiory pool for port write allocations.
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-10-04 14:58:13 +03:00
Max Romanov
4ae76249ed Fixing memory leak when handling remove pid message.
Worker threads ports need to receive 'remove pid' message to properly handle
application process exit case and finish requests processed by particular
application worker.  Main process send 'remove pid' notification to service
thread port only and this message must be 'proxied' to other running engines.

Separate memory pool created for this message.  For each engine structure
required to post message to engine allocate from the pool using 'retain'
allocation method.  After successfull post structure will be freed using
'release' method.  To completely destroy poll one more 'release' should be
called to release initial reference count.

I'm afraid this should be simplified using good old malloc() and free() calls.
2017-10-04 14:57:29 +03:00
Igor Sysoev
bfa808d689 Event engine memory cache for nxt_sockaddr_t.
Introducing event engine memory cache and using the cache for
nxt_sockaddr_t structures.
2017-09-27 19:22:59 +03:00
Valentin Bartenev
45c1d41f34 Removed fibers from compilation.
It's not used anyway, but breaks building with musl.

This closes issue #5 on GitHub.
2017-09-22 16:42:42 +03:00
Max Romanov
838d9946ac Introducing named port message handlers to avoid misprints. 2017-09-15 20:30:34 +03:00
Max Romanov
1449e27cb4 Fixing memory leak of request parse context. 2017-09-15 20:30:29 +03:00
Max Romanov
0bec14878e Introducing application timeout. 2017-09-15 20:30:24 +03:00