Slight interface simplification
This commit is contained in:
@@ -62,8 +62,9 @@ void FastCGIServer::Serve() {
|
||||
NewConn();
|
||||
} else {
|
||||
auto conn = static_cast<FastCGIConn*>(events[i].data.ptr);
|
||||
if (!conn->Read()) {
|
||||
PCHECK(epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, conn->Sock(), nullptr) == 0);
|
||||
auto fd = conn->Read();
|
||||
if (fd != -1) {
|
||||
PCHECK(epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, fd, nullptr) == 0);
|
||||
delete conn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ bool FastCGIConn::Write(const std::vector<iovec>& vecs) {
|
||||
return writev(sock_, vecs.data(), vecs.size()) == total_size;
|
||||
}
|
||||
|
||||
bool FastCGIConn::Read() {
|
||||
int FastCGIConn::Read() {
|
||||
if (!buf_.Refill()) {
|
||||
return false;
|
||||
return sock_;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
@@ -102,9 +102,5 @@ bool FastCGIConn::Read() {
|
||||
}
|
||||
|
||||
buf_.Consume();
|
||||
return true;
|
||||
}
|
||||
|
||||
int FastCGIConn::Sock() {
|
||||
return sock_;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -14,11 +14,9 @@ class FastCGIConn {
|
||||
FastCGIConn(int sock, const sockaddr_in6& client_addr, const std::function<void(std::unique_ptr<FastCGIRequest>)>& callback, const std::unordered_set<std::string_view>& headers);
|
||||
~FastCGIConn();
|
||||
|
||||
[[nodiscard]] bool Read();
|
||||
[[nodiscard]] int Read();
|
||||
[[nodiscard]] bool Write(const std::vector<iovec>& vecs);
|
||||
|
||||
[[nodiscard]] int Sock();
|
||||
|
||||
private:
|
||||
const int sock_;
|
||||
const std::function<void(std::unique_ptr<FastCGIRequest>)>& callback_;
|
||||
|
||||
Reference in New Issue
Block a user