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