From a39ef8e25dc2450b9219da67e37cfe158bd4a3ec Mon Sep 17 00:00:00 2001 From: flamingcow Date: Sun, 12 May 2019 16:08:46 -0700 Subject: [PATCH] Don't leak eventfd --- server.cc | 4 ++++ server.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/server.cc b/server.cc index 18338c6..deca4cc 100644 --- a/server.cc +++ b/server.cc @@ -28,6 +28,10 @@ Server::Server(int port, const std::function& callback, int thre signal(SIGPIPE, SIG_IGN); } +Server::~Server() { + PCHECK(close(close_fd_) == 0); +} + void Server::Serve() { std::vector threads; for (int i = 0; i < threads_ - 1; ++i) { diff --git a/server.h b/server.h index 4959831..e79ef5d 100644 --- a/server.h +++ b/server.h @@ -11,6 +11,8 @@ namespace firecgi { class Server { public: Server(int port, const std::function& callback, int threads=1, int max_request_len=(16*1024)); + ~Server(); + void Serve(); void Shutdown(); void RegisterSignalHandlers();