From 4505f8ff4f0ef1d7ebf8aa55b92ee541527678f8 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 5 Feb 2022 01:00:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=85http=E5=8D=8F=E8=AE=AE=E5=BC=80?= =?UTF-8?q?=E5=90=AFsendfile=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpSession.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 0d3c6760..6cb17115 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -594,20 +594,20 @@ void HttpSession::sendResponse(int code, return; } - if (!body->sendFile(getSock()->rawFD())) { - //支持sendfile优化 + if (typeid(*this) == typeid(HttpSession) && !body->sendFile(getSock()->rawFD())) { + //http支持sendfile优化 return; } GET_CONFIG(uint32_t, sendBufSize, Http::kSendBufSize); - if(body->remainSize() > sendBufSize){ + if (body->remainSize() > sendBufSize) { //文件下载提升发送性能 setSocketFlags(); } //发送http body - AsyncSenderData::Ptr data = std::make_shared(shared_from_this(),body,bClose); - getSock()->setOnFlush([data](){ + AsyncSenderData::Ptr data = std::make_shared(shared_from_this(), body, bClose); + getSock()->setOnFlush([data]() { return AsyncSender::onSocketFlushed(data); }); AsyncSender::onSocketFlushed(data);