Commit Graph

11 Commits

Author SHA1 Message Date
Andrew Clayton
4418f99cd4 Constified numerous function parameters.
As was pointed out by the cppcheck[0] static code analysis utility we
can mark numerous function parameters as 'const'. This acts as a hint to
the compiler about our intentions and the compiler will tell us when we
deviate from them.

[0]: https://cppcheck.sourceforge.io/
2022-06-22 00:30:44 +02:00
Max Romanov
b4540f0960 Removing unused tracking fields and functions.
The message tracking is unused since 1d84b9e4b459 commit.

This fixes the issue found by Coverity (CID 376263).
2022-06-07 13:59:45 +08:00
Max Romanov
6e31d6cd39 Changing router to application shared memory exchange protocol.
The application process needs to request the shared memory segment from the
router instead of the latter pushing the segment before sending a request to
the application.  This is required to simplify the communication between the
router and the application and to prepare the router for using the application
shared port and then the queue.
2020-08-11 19:20:13 +03:00
Max Romanov
df7caf4650 Introducing port messages to notify about out of shared memory.
- 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-24 18:04:13 +03:00
Max Romanov
4d818a6f23 Enabled body buffer shared memory segmentation.
Changeset #699 fixes shared memory allocation: continous buffer with
requested size should be allocated or function failed.  For body longer
than 10 Mb, this allocation will definitely fails.

For body buffer it is not required to send it in a single continous buffer,
so, need to request minimum reasonable amount of shared memory and try to
extend it, if possible or allocate next buffer.
2018-07-12 16:06:36 +03:00
Max Romanov
b1d7844449 Fixed allocation of multiple shared memory chunks.
Previously, one shared memory chunk was allocated under mutex and other
chunks (if required) were allocated using atomic operations.  So such
allocation is not guaranteed and the result buffer can be less than
requested.

This commit moves multiple chunks allocation under mutex and guarantees
the result buffer is large enough.
2018-06-20 19:11:27 +03:00
Max Romanov
89c0f7c5db Implementing the ability to cancel request before worker starts processing it. 2017-12-27 17:46:17 +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
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
Max Romanov
4f7e00ef34 Fixing shared memory thread safety issue.
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-18 17:35:24 +03:00
Max Romanov
0cd9521687 Store pointer to shared memory start in buf->parent.
nxt_port_mmap_t stored in arrays and it is unsafe to store
pointer to array element.

Shared memory structures and macros moved to separate header
file to be used by GO package.
2017-06-23 19:20:04 +03:00