src: Retry write(2) if errno == EINTR
This commit is contained in:
parent
62423f5949
commit
61053653df
|
@ -1027,7 +1027,11 @@ void prepare_status_response(Stream *stream, Http2Handler *hd,
|
||||||
gzclose(write_fd);
|
gzclose(write_fd);
|
||||||
headers.emplace_back("content-encoding", "gzip");
|
headers.emplace_back("content-encoding", "gzip");
|
||||||
} else {
|
} else {
|
||||||
auto rv = write(pipefd[1], body.c_str(), body.size());
|
ssize_t rv;
|
||||||
|
|
||||||
|
while((rv = write(pipefd[1], body.c_str(), body.size())) == -1 &&
|
||||||
|
errno == EINTR);
|
||||||
|
|
||||||
if(rv != static_cast<ssize_t>(body.size())) {
|
if(rv != static_cast<ssize_t>(body.size())) {
|
||||||
std::cerr << "Could not write all response body: " << rv << std::endl;
|
std::cerr << "Could not write all response body: " << rv << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ Log::~Log()
|
||||||
|
|
||||||
auto nwrite = std::min(static_cast<size_t>(rv), sizeof(buf) - 1);
|
auto nwrite = std::min(static_cast<size_t>(rv), sizeof(buf) - 1);
|
||||||
|
|
||||||
write(worker_config.errorlog_fd, buf, nwrite);
|
while(write(worker_config.errorlog_fd, buf, nwrite) == -1 && errno == EINTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void upstream_accesslog(const std::string& client_ip, unsigned int status_code,
|
void upstream_accesslog(const std::string& client_ip, unsigned int status_code,
|
||||||
|
@ -208,7 +208,8 @@ void upstream_accesslog(const std::string& client_ip, unsigned int status_code,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
write(worker_config.accesslog_fd, buf, nwrite);
|
while(write(worker_config.accesslog_fd, buf, nwrite) == -1 &&
|
||||||
|
errno == EINTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
int reopen_log_files()
|
int reopen_log_files()
|
||||||
|
|
Loading…
Reference in New Issue