From f3a1d7ea4bc13126996daf10031e89fd850c5945 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 26 Nov 2005 17:29:22 +0000 Subject: Added listening socket support for InspSocket git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1957 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/inspircd.cpp') diff --git a/src/inspircd.cpp b/src/inspircd.cpp index b9b9eb33e..0db94f5d4 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -2340,11 +2340,15 @@ int InspIRCd(char** argv, int argc) for (std::vector::iterator a = module_sockets.begin(); a < module_sockets.end(); a++) { InspSocket* s = (InspSocket*)*a; - if (!s->Poll()) + // Polling a listening socket class may result in the size of module_sockets increasing. + // This is still safe to do, however if the size of module_sockets is decreased, e.g. + // by a close or error, we cannot continue to use this iterator and must bail out asap. + if ((s) && (!s->Poll())) { + log(DEBUG,"Socket poll returned false, close and bail"); s->Close(); - delete s; module_sockets.erase(a); + delete s; break; } } -- cgit v1.2.3