Commit 1dd3d6f1 by xiongziliang

忽略SIGPIPE信号

parent 0402646f
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
* may be found in the AUTHORS file in the root of the source tree. * may be found in the AUTHORS file in the root of the source tree.
*/ */
#include <csignal>
#include "HttpBody.h" #include "HttpBody.h"
#include "Util/util.h" #include "Util/util.h"
#include "Util/File.h" #include "Util/File.h"
#include "Util/uv_errno.h" #include "Util/uv_errno.h"
#include "Util/logger.h" #include "Util/logger.h"
#include "Util/onceToken.h"
#include "HttpClient.h" #include "HttpClient.h"
#ifndef _WIN32 #ifndef _WIN32
#include <sys/mman.h> #include <sys/mman.h>
...@@ -70,6 +72,9 @@ HttpFileBody::HttpFileBody(const std::shared_ptr<FILE> &fp, size_t offset, size_ ...@@ -70,6 +72,9 @@ HttpFileBody::HttpFileBody(const std::shared_ptr<FILE> &fp, size_t offset, size_
#endif #endif
int HttpFileBody::sendFile(int fd) { int HttpFileBody::sendFile(int fd) {
static onceToken s_token([]() {
signal(SIGPIPE, SIG_IGN);
});
#if defined(__linux__) || defined(__linux) #if defined(__linux__) || defined(__linux)
off_t off = _file_offset; off_t off = _file_offset;
return sendfile(fd, fileno(_fp.get()), &off, _max_size); return sendfile(fd, fileno(_fp.get()), &off, _max_size);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论