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)
876
876
{
877
877
loop_->assertInLoopThread ();
878
878
#ifdef __linux__
879
- if (nodePtr->ifFile () && !tlsProviderPtr_)
879
+ if (nodePtr->isFile () && !tlsProviderPtr_)
880
880
{
881
881
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);
886
885
if (bytesSent < 0 )
887
886
{
888
887
if (errno != EAGAIN)
@@ -893,7 +892,7 @@ void TcpConnectionImpl::sendNodeInLoop(const BufferNodePtr &nodePtr)
893
892
}
894
893
return ;
895
894
}
896
- if (bytesSent < filePtr-> fileBytesToSend_ )
895
+ if (static_cast < size_t >( bytesSent) < toSend )
897
896
{
898
897
if (bytesSent == 0 )
899
898
{
@@ -902,7 +901,7 @@ void TcpConnectionImpl::sendNodeInLoop(const BufferNodePtr &nodePtr)
902
901
}
903
902
}
904
903
LOG_TRACE << " sendfile() " << bytesSent << " bytes sent" ;
905
- filePtr-> fileBytesToSend_ -= bytesSent;
904
+ nodePtr-> retrieve ( bytesSent) ;
906
905
if (!ioChannelPtr_->isWriting ())
907
906
{
908
907
ioChannelPtr_->enableWriting ();
You can’t perform that action at this time.
0 commit comments