File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -876,13 +876,12 @@ void TcpConnectionImpl::sendNodeInLoop(const BufferNodePtr &nodePtr)
876876{
877877 loop_->assertInLoopThread ();
878878#ifdef __linux__
879- if (nodePtr->ifFile () && !tlsProviderPtr_)
879+ if (nodePtr->isFile () && !tlsProviderPtr_)
880880 {
881881 LOG_TRACE << " send file in loop using linux kernel sendfile()" ;
882- auto bytesSent = sendfile (socketPtr_->fd (),
883- nodePtr->getSendFd (),
884- &filePtr->offset_ ,
885- filePtr->fileBytesToSend_ );
882+ auto toSend = nodePtr->remainingBytes ();
883+ auto bytesSent =
884+ sendfile (socketPtr_->fd (), nodePtr->getFd (), nullptr , toSend);
886885 if (bytesSent < 0 )
887886 {
888887 if (errno != EAGAIN)
@@ -893,7 +892,7 @@ void TcpConnectionImpl::sendNodeInLoop(const BufferNodePtr &nodePtr)
893892 }
894893 return ;
895894 }
896- if (bytesSent < filePtr-> fileBytesToSend_ )
895+ if (static_cast < size_t >( bytesSent) < toSend )
897896 {
898897 if (bytesSent == 0 )
899898 {
@@ -902,7 +901,7 @@ void TcpConnectionImpl::sendNodeInLoop(const BufferNodePtr &nodePtr)
902901 }
903902 }
904903 LOG_TRACE << " sendfile() " << bytesSent << " bytes sent" ;
905- filePtr-> fileBytesToSend_ -= bytesSent;
904+ nodePtr-> retrieve ( bytesSent) ;
906905 if (!ioChannelPtr_->isWriting ())
907906 {
908907 ioChannelPtr_->enableWriting ();
You can’t perform that action at this time.
0 commit comments