All pastes #231664 Raw Edit

Anonymous

public cpp v1 · immutable
#231664 ·published 2006-10-31 23:05 UTC
rendered paste body
? alcc-sluice? alcc.diff? gdb.core.traceIndex: connhub.cpp===================================================================RCS file: /cvsroot/alcc/alcc/connhub.cpp,vretrieving revision 1.18diff -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<pollfd>::iterator it;+    vector<pollfd_x>::iterator it;     map<int, Connection *>::iterator conn;      for (;;)@@ -214,9 +214,9 @@ void ConnectionHub::registerConnection (Connection *conn, short how) {-    pollfd          pollStruct;+    pollfd_x        pollStruct;     int             connFD;-    vector<pollfd>::iterator it;+    vector<pollfd_x>::iterator it;      connFD = conn->getFD (); @@ -292,8 +292,7 @@ ConnectionHub::unregisterConnection (Connection *conn) {     map<string, Connection *>::iterator handleIter;-    vector<pollfd>::iterator poolIter;-    bool            removed = false;            // Error checking - see below+    vector<pollfd_x>::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,vretrieving revision 1.8diff -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<int, Connection *> connections;     map<string, Connection *> handles;     map<string, Module *> modules;-    vector<pollfd>  pool;+    vector<pollfd_x>  pool;     string          moduleNames;      pthread_mutex_t moduleMutex;