From c92613ebf3c2e112bab2da62cc8d244d509bdda7 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sun, 9 Jun 2013 14:11:41 +0200 Subject: Fix fd and minor memory leak in threadengine_pthread on unload of m_mysql --- src/threadengines/threadengine_pthread.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/threadengines') diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp index c1b964430..e16e401f3 100644 --- a/src/threadengines/threadengine_pthread.cpp +++ b/src/threadengines/threadengine_pthread.cpp @@ -80,6 +80,8 @@ class ThreadSignalSocket : public EventHandler ~ThreadSignalSocket() { + ServerInstance->SE->DelFd(this); + ServerInstance->SE->Close(GetFd()); } void Notify() @@ -104,6 +106,7 @@ class ThreadSignalSocket : public EventHandler SocketThread::SocketThread() { + signal.sock = NULL; int fd = eventfd(0, EFD_NONBLOCK); if (fd < 0) throw new CoreException("Could not create pipe " + std::string(strerror(errno))); @@ -127,6 +130,8 @@ class ThreadSignalSocket : public EventHandler ~ThreadSignalSocket() { close(send_fd); + ServerInstance->SE->DelFd(this); + ServerInstance->SE->Close(GetFd()); } void Notify() @@ -152,6 +157,7 @@ class ThreadSignalSocket : public EventHandler SocketThread::SocketThread() { + signal.sock = NULL; int fds[2]; if (pipe(fds)) throw new CoreException("Could not create pipe " + std::string(strerror(errno))); @@ -166,4 +172,9 @@ void SocketThread::NotifyParent() SocketThread::~SocketThread() { + if (signal.sock) + { + signal.sock->cull(); + delete signal.sock; + } } -- cgit v1.2.3