Commit graph

374 commits

Author SHA1 Message Date
Andrei Belov
156877f3c9 Introduced deb packages building tools. 2017-10-19 18:23:32 +03:00
Andrei Belov
eabe25d98e Introduced rpm packages building tools. 2017-10-19 18:23:31 +03:00
Max Romanov
c8a8a7c212 Fixing Go package build.
Go package build was broken by change 365:28b2a468be43.
2017-10-19 18:20:08 +03:00
Igor Sysoev
f9f852008f Added version 0.2 CHANGES. 2017-10-19 17:54:29 +03:00
Andrei Belov
8ca14503b7 Added changelogs generation tools. 2017-10-19 17:48:58 +03:00
Valentin Bartenev
e7d81186b5 Fixed controller restarting.
Previously, stored configuration wasn't reread on controller
process restart, which resulted in segmentation fault.
2017-10-19 17:43:54 +03:00
Max Romanov
fc6520d722 Keep application worker until response for all requests received. 2017-10-19 17:37:26 +03:00
Max Romanov
b3aab8c66f Filtering process to keep connection.
- 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-19 17:37:19 +03:00
Max Romanov
6031c63225 Introducing mmap_handler to count references to shared memory.
"All problems in computer science can be
                           solved by another level of indirection"

                                                   Butler Lampson

Completion handlers for application response buffers executed after
sending the data to client.  Application worker can be stopped right
after send response buffers to router.  Worker stop causes removal
of all data structures for the worker.

To prevent shared memory segment unmap, need to count the number of
buffers which uses it.  So instead of direct reference to shared
memory, need to reference to intermediate 'handler' structure with
use counter and pointer to shared memory.
2017-10-19 17:37:02 +03:00
Max Romanov
6532e46465 Supporting concurrent shared memory fd receive in router.
Two different router threads may send different requests to single
application worker.  In this case shared memory fds from worker
to router will be send over 2 different router ports.  These fds
will be received and processed by different threads in any order.

This patch made possible to add incoming shared memory segments in
arbitrary order.  Additionally, array and memory pool are no longer
used to store segments because of pool's single threaded nature.

Custom array-like structure nxt_port_mmaps_t introduced.
2017-10-19 17:36:56 +03:00
Max Romanov
6fd465f9d2 Introducing src_pid for mmap header for accurate buf completion.
This allows to use shared memory to communicate with main process.

This patch changes shared memory segment format and breaks compatibility
with older modules.
2017-10-19 17:36:45 +03:00
Valentin Bartenev
39fd38a948 Fixed matching of empty version. 2017-10-19 17:26:56 +03:00
Igor Sysoev
0833074f30 Fixed the bug introduced in the previous changeset. 2017-10-19 17:22:33 +03:00
Igor Sysoev
3c6edead25 Added the debug option to module compatibility vector. 2017-10-18 18:05:51 +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
1c6d4d8cff Basic validation errors. 2017-10-10 19:46:58 +03:00
Valentin Bartenev
e4bea2c75c Optimized application type handling. 2017-10-10 19:15:08 +03:00
Valentin Bartenev
93438a0d9e Fixed building with old GCC after the previous change. 2017-10-05 17:31:41 +03:00
Valentin Bartenev
096562c0b1 Improved applications versions handling. 2017-10-05 16:46:18 +03:00
Igor Sysoev
653e985463 Added Linux 4.5 EPOLLEXCLUSIVE support. 2017-10-04 15:13:22 +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
439bf7df11 Breaking read loop by nxt_port_read_close().
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-04 15:02:32 +03:00
Max Romanov
e44401a0bb Introducing process use counter.
This helps to decouple process removal from port memory pool cleanups.
2017-10-04 15:02:11 +03:00
Max Romanov
f869bf1b02 Return error codes for port_hash operations. 2017-10-04 15:02:00 +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
ebbe89bd5c Optimized send message allocations.
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-04 14:59:35 +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
ba31199786 Removing mem_pool from port_hash interface.
Memory pool is not used by port_hash and it was a mistake to pass it into
'add' and 'remove' functions.  port_hash enrties are allocated from heap.
2017-10-04 14:57:56 +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
Valentin Bartenev
fcd141936c Version bump. 2017-10-02 17:10:12 +03:00
Igor Sysoev
9416a342b2 Fixed building by modern GCC. 2017-09-27 19:43:26 +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
Sergey Kandaurov
752038eea8 Fixed building with pthread_t defined as a pointer. 2017-09-27 18:34:24 +03:00
Sergey Kandaurov
9213299d1f Supported linking with -lrt on BSD systems.
OpenBSD lacks support of librt.
2017-09-27 18:34:23 +03:00
Sergey Kandaurov
aac0f06f3d Better checking for shm_open() during configure. 2017-09-27 18:34:23 +03:00
Igor Sysoev
4f4647e187 Fixed "make dist" broken in changeset b18c0fb60032. 2017-09-27 18:34:15 +03:00
Valentin Bartenev
d18113ab66 Changed "path" to "directory" in configure summary.
The "directory" is more specific term, similar to "file".
2017-09-26 17:53:21 +03:00
Igor Sysoev
5635c259f9 Added state directory creation in install procedure. 2017-09-25 20:15:34 +03:00
Igor Sysoev
d04f030d1a Added --bindir and --sbindir options to the summary page. 2017-09-25 20:15:33 +03:00
Igor Sysoev
6b0a3aed22 Style fixes. 2017-09-25 18:04:11 +03:00
Max Romanov
2ae0449262 Checking mallopt() during configure.
mallopt() is absent on Alpine musl.
2017-09-25 17:53:10 +03:00
Igor Sysoev
8e2fd89634 Fixed displaying "echo" program building failure. 2017-09-22 20:13:55 +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
Valentin Bartenev
6a78aedb7e README: added project name to the beginning.
Also, for prettier look in output of "cat" and "less" commands,
added an empty line at the end.
2017-09-19 19:05:03 +03:00
Valentin Bartenev
aa7eefe557 Simplified the README file.
Detailed documentation was moved to a separate repository
in order to keep the main repository clean from lots of
documentation edits.

See: http://hg.nginx.org/unit-docs
2017-09-19 18:12:26 +03:00