YIHONG-JIN commented on code in PR #11890:
URL: https://github.com/apache/trafficserver/pull/11890#discussion_r1926365696


##########
src/iocore/net/UnixNetVConnection.cc:
##########
@@ -508,6 +508,81 @@ UnixNetVConnection::net_read_io(NetHandler *nh)
     read_disable(nh, this);
     return;
   }
+#if TS_USE_LINUX_SPLICE
+  // Check if the buffer is a PipeIOBuffer
+  PipeIOBuffer *pipe_buffer = dynamic_cast<PipeIOBuffer *>(buf.writer());
+  if (pipe_buffer) {
+    // Use splice_to to transfer data from socket directly to pipe with 
SPLICE_F_MORE hint
+    int64_t to_splice = std::min(ntodo, pipe_buffer->write_avail());
+    if (to_splice > 0) {
+      r = con.sock.splice_to(pipe_buffer->fd[1], to_splice, SPLICE_F_MOVE | 
SPLICE_F_NONBLOCK);
+
+      if (r <= 0) {
+        // Temporary Unavailable, Non-Blocking I/O
+        if (r == -EAGAIN || r == -ENOTCONN) {

Review Comment:
   It is actually impossible to get EAGAIN here **because the pipe is at 
capacity**. We will disable the read vio after each successful read and only 
reenable it when its corresponding pipe is empty again. 
   
   However, it is possible that we get EAGAIN because the socket is somehow 
unavailable. In that case, we wait for next epoll edge trigger same as the 
logic without zero copy



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to