summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-10-27Fixing Go program crash.Max Romanov1-2/+2
Go request registration should be removed before C request memory freed. C request address used as a key in Go map. Freed memory can be instantly reused for other request and older request registration should removed at this point to avoid collisions.
2017-10-25Checking the result of shared memory buffer allocation.Max Romanov1-0/+3
This closes #57 issue on GitHub.
2017-10-25Avoiding compilation on systems with no working shared memory.Valentin Bartenev1-0/+4
2017-10-20Version bump.Igor Sysoev1-2/+2
2017-10-19Fixing Go package build.Max Romanov5-14/+21
Go package build was broken by change 365:28b2a468be43.
2017-10-19Fixed controller restarting.Valentin Bartenev2-24/+38
Previously, stored configuration wasn't reread on controller process restart, which resulted in segmentation fault.
2017-10-19Keep application worker until response for all requests received.Max Romanov1-1/+4
2017-10-19Filtering process to keep connection.Max Romanov5-13/+58
- 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-19Introducing mmap_handler to count references to shared memory.Max Romanov3-87/+146
"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-19Supporting concurrent shared memory fd receive in router.Max Romanov6-104/+86
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-19Introducing src_pid for mmap header for accurate buf completion.Max Romanov3-16/+30
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-19Fixed matching of empty version.Valentin Bartenev1-0/+4
2017-10-19Fixed the bug introduced in the previous changeset.Igor Sysoev1-4/+9
2017-10-18Added the debug option to module compatibility vector.Igor Sysoev3-3/+3
2017-10-18Router: fixed segfault after configuration change.Igor Sysoev7-193/+258
2017-10-17Storing memory cache slot hint inside nxt_sockaddr_t.Igor Sysoev7-31/+27
2017-10-10Basic validation errors.Valentin Bartenev3-84/+258
2017-10-10Optimized application type handling.Valentin Bartenev6-58/+50
2017-10-05Fixed building with old GCC after the previous change.Valentin Bartenev1-2/+1
2017-10-05Improved applications versions handling.Valentin Bartenev6-16/+144
2017-10-04Added Linux 4.5 EPOLLEXCLUSIVE support.Igor Sysoev1-2/+10
2017-10-04Port message fragmentation supported.Max Romanov9-28/+273
- 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-04Optimized request<->app link allocation.Max Romanov1-36/+59
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-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-04Introducing process use counter.Max Romanov6-38/+52
This helps to decouple process removal from port memory pool cleanups.
2017-10-04Return error codes for port_hash operations.Max Romanov3-8/+30
2017-10-04Using port 'post' facility to proxy remove pid message to workers.Max Romanov4-86/+30
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-04Using request mem pool for req<->app link.Max Romanov2-3/+20
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-04Fixed error generation during request processing.Max Romanov1-40/+94
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-04Optimized send message allocations.Max Romanov2-42/+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 Romanov9-407/+682
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 Romanov7-16/+16
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-04Removing mem_pool from port_hash interface.Max Romanov5-45/+30
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-04Fixing memory leak when handling remove pid message.Max Romanov1-0/+2
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-02Version bump.Valentin Bartenev1-2/+2
2017-09-27Fixed building by modern GCC.Igor Sysoev1-6/+3
2017-09-27Event engine memory cache for nxt_sockaddr_t.Igor Sysoev8-20/+185
Introducing event engine memory cache and using the cache for nxt_sockaddr_t structures.
2017-09-27Fixed building with pthread_t defined as a pointer.Sergey Kandaurov2-2/+2
2017-09-25Style fixes.Igor Sysoev1-4/+5
2017-09-25Checking mallopt() during configure.Max Romanov1-1/+1
mallopt() is absent on Alpine musl.
2017-09-22Removed fibers from compilation.Valentin Bartenev6-5/+22
It's not used anyway, but breaks building with musl. This closes issue #5 on GitHub.
2017-09-18Fixing shared memory thread safety issue.Max Romanov4-2/+13
Do not reuse shared memory segment with different port until this segment successfully received and indexed on other side. However, segment can be used to transfer data via the port it was sent at any time.
2017-09-16Fixed memory leak caused by mempool related to request context.Valentin Bartenev1-7/+3
The previous attempt of fixing this in e5a65b58101f hasn't been really successful, because the actual memory leak was caused not by the request parse context itself, but its memory pool.
2017-09-15Go: Fixed a bug introduced in the previous changeset.Igor Sysoev1-1/+1
2017-09-15Introducing named port message handlers to avoid misprints.Max Romanov10-147/+135
2017-09-15Fixing memory leak of request parse context.Max Romanov3-19/+38
2017-09-15Introducing application timeout.Max Romanov13-326/+589
2017-09-15Fixed port handlers arrays.Valentin Bartenev2-0/+4
2017-09-15Router: more logical code order change.Igor Sysoev1-2/+2
Updating the router engines list before posting jobs to worker thread engines is more logical because worker threads may exit after the posting. However, the previous code was safe because an engine is freed by the router main thread after worker its thread has exited.
2017-09-14Router: fixed segmentation fault.Igor Sysoev2-10/+38
The router process exited abnormally on reconfiguration if number of worker threads had been decreased on the previous reconfiguration. Besides the list of router engines should be updated only after a new configuration joints have been prepared for all engines.