Commit Graph

28 Commits

Author SHA1 Message Date
Max Romanov
b59535b22c Removed unused variable assignment.
Found by Coverity (CID 215301).
2017-12-28 15:58:01 +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
ec411569e7 Fixing build on Solaris. 2017-11-02 15:32:46 +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
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
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
Igor Sysoev
58907888e5 Style fixes. 2017-09-06 02:30:55 +03:00
Max Romanov
e1e808bd94 Sync flag introduced for port type.
To avoid transfer mmap_msg before new mmap message.
2017-08-11 18:04:04 +03:00
Max Romanov
1b354421c3 Tiny mmap buffers completion fixed.
Small mmap buffers transferred in 'plain' mode and should be freed by sender.
2017-08-11 18:04:04 +03:00
Max Romanov
b150f07e80 Added basic port error handler. 2017-08-02 13:36:29 +03:00
Max Romanov
9367dd2bf8 Implicit port read buffer completion.
To disable implicit completion, handler should reset msg->buf field.
2017-08-02 13:21:32 +03:00
Max Romanov
3812ffd336 Added bit flags to type parameter of nxt_port_socket_write().
NXT_PORT_MSG_LAST     - mark message as last;
NXT_PORT_MSG_CLOSE_FD - close fd right after send;

Type constants altered to include last flag for single buffer messages.

Last sign is critical for coming port RPC layer. Handlers unregistered on last
message. Create sync buffer is not convenient, extra parameter is better.
2017-08-02 13:10:48 +03:00
Max Romanov
eb675f2d78 Port allocation and destroy changed. Worker process stop introduced. 2017-07-18 00:21:14 +03:00
Max Romanov
b0c1e740cf New process port exchange changed. READY message type introduced.
Application process start request DATA message from router to master.
Master notifies router via NEW_PORT message after worker process become ready.
2017-07-12 20:32:16 +03:00
Max Romanov
e15b975e9d Work queue thread safety checks for DEBUG build. 2017-07-07 16:01:34 +03:00
Max Romanov
74cda90e31 Process stop notification from master to all other processes.
New port message type introduced NXT_PORT_MSG_REMOVE_PID. Default handler
removes process description from nxt_runtime_t with all ports, incoming and
outgoing mmaps etc.
2017-07-07 16:01:34 +03:00
Max Romanov
f319220a6c Redirecting buffer completion handler to specific engine.
There is a case in router where we use port in router connection thread.
Buffers are allocated within connection memory pool which can be used only in
this router thread. sendmsg() can be postponed into main router thread and
completion handler will compare current engine and post itself to correct
engine.
2017-07-07 16:01:34 +03:00
Max Romanov
abe0d33329 Increased size of iovec when data passed using shared memory.
Useful for tiny shared memory segment test case.
2017-06-23 19:20:08 +03:00
Max Romanov
3b9aa27625 Added mem_pool pointer member to nxt_port_send_msg_t.
To decouple nxt_port_send_msg_t from port.
2017-06-23 19:20:08 +03:00
Max Romanov
eaf28db46e Moved message size to nxt_port_recv_msg_t for convenience. 2017-06-23 19:20:08 +03:00
Igor Sysoev
f888a5310c Using new memory pool implementation. 2017-06-20 19:49:17 +03:00
Max Romanov
f7b4bdfd89 Using shared memory to send data via nxt_port.
Usage:
    b = nxt_port_mmap_get_buf(task, port, size);
    b->mem.free = nxt_cpymem(b->mem.free, data, size);
    nxt_port_socket_write(task, port, NXT_PORT_MSG_DATA, -1, 0, b);
2017-05-12 20:32:41 +03:00
Igor Sysoev
b379dae85e Port changes. 2017-02-22 15:10:28 +03:00
Igor Sysoev
029942f4eb I/O operations refactoring. 2017-02-22 15:09:59 +03:00
Igor Sysoev
059a864289 Event engines refactoring. 2017-02-07 20:04:56 +03:00
Igor Sysoev
e57b95a923 Process channels have been renamed to ports. 2017-02-01 20:03:45 +03:00