fix(CgiHandler, CgiProcess): improve socket management by adding stderr socket handling
This commit is contained in:
parent
7eba0b38a2
commit
c148636b1e
@ -102,7 +102,7 @@ void CgiHandler::error()
|
||||
else if (bytesRead == 0)
|
||||
{
|
||||
Log::info("CGI process closed stderr, fd: " + std::to_string(cgiStdErr_->getFd()));
|
||||
request_.getClient().removeCgiSocket(cgiStdErr_.get());
|
||||
request_.getClient().removeSocket(cgiStdErr_.get());
|
||||
cgiStdErr_ = nullptr;
|
||||
return;
|
||||
}
|
||||
@ -126,6 +126,7 @@ void CgiHandler::setCgiSockets(std::unique_ptr<CgiSocket> cgiStdIn, std::unique_
|
||||
|
||||
request_.getClient().addSocket(cgiStdIn_.get());
|
||||
request_.getClient().addSocket(cgiStdOut_.get());
|
||||
request_.getClient().addSocket(cgiStdErr_.get());
|
||||
}
|
||||
|
||||
void CgiHandler::wait() noexcept
|
||||
|
||||
@ -84,6 +84,8 @@ void CgiProcess::spawn()
|
||||
// Parent process
|
||||
auto cgiStdIn = std::make_unique<CgiSocket>(pipeStdin[1], ASocket::IOState::WRITE);
|
||||
auto cgiStdOut = std::make_unique<CgiSocket>(pipeStdout[0], ASocket::IOState::READ);
|
||||
auto cgiStdErr = std::make_unique<CgiSocket>(pipeStderr[0], ASocket::IOState::READ);
|
||||
|
||||
close(pipeStdin[0]);
|
||||
close(pipeStdout[1]);
|
||||
close(pipeStderr[1]);
|
||||
@ -93,6 +95,7 @@ void CgiProcess::spawn()
|
||||
// request_.getClient().setCgiSockets(std::move(cgiStdIn), std::move(cgiStdOut)); // move the sockets to the
|
||||
// client
|
||||
handler_.setCgiSockets(std::move(cgiStdIn), std::move(cgiStdOut), std::move(cgiStdErr));
|
||||
|
||||
handler_.setPid(_pid);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user