? alcc-sluice ? alcc.diff ? gdb.core.trace Index: connhub.cpp =================================================================== RCS file: /cvsroot/alcc/alcc/connhub.cpp,v retrieving revision 1.18 diff -u -r1.18 connhub.cpp --- connhub.cpp 29 Oct 2006 05:01:42 -0000 1.18 +++ connhub.cpp 31 Oct 2006 23:04:38 -0000 @@ -67,7 +67,7 @@ ConnectionHub::monitor () { int fds_ready; - vector::iterator it; + vector::iterator it; map::iterator conn; for (;;) @@ -214,9 +214,9 @@ void ConnectionHub::registerConnection (Connection *conn, short how) { - pollfd pollStruct; + pollfd_x pollStruct; int connFD; - vector::iterator it; + vector::iterator it; connFD = conn->getFD (); @@ -292,8 +292,7 @@ ConnectionHub::unregisterConnection (Connection *conn) { map::iterator handleIter; - vector::iterator poolIter; - bool removed = false; // Error checking - see below + vector::iterator poolIter; // Remove the connection from the collection // (if it isn't registered, ignore silently) @@ -310,23 +309,8 @@ } // Remove the corresponding structure from the poll(2) pool - for (poolIter = pool.end () - 1; poolIter != pool.begin () - 1; - poolIter--) - { - if (poolIter->fd == conn->getFD ()) - { - if (removed) // It's not the first time - { - // TODO Log this -#ifdef DEBUG_CONNECTION - fprintf (stderr, "ConnectionHub::unregisterConnection(): " - "Removed a duplicate descriptor\n"); -#endif - } - pool.erase (poolIter); - removed = true; - } - } + pool.erase (remove (pool.begin (), pool.end (), conn->getFD ()), + pool.end ()); } /* Index: connhub.h =================================================================== RCS file: /cvsroot/alcc/alcc/connhub.h,v retrieving revision 1.8 diff -u -r1.8 connhub.h --- connhub.h 19 Oct 2006 00:02:03 -0000 1.8 +++ connhub.h 31 Oct 2006 23:04:38 -0000 @@ -30,6 +30,19 @@ class Module; class Connection; +struct pollfd_x : pollfd +{ + bool operator== (int x) + { + if (this->fd == x) + { + fprintf (stderr, "%d removed\n", x); + return true; + } + return false; + } +}; + class ConnectionHub { private: @@ -37,7 +50,7 @@ map connections; map handles; map modules; - vector pool; + vector pool; string moduleNames; pthread_mutex_t moduleMutex;