rendered paste bodyIndex: connhub.cpp
===================================================================
RCS file: /cvsroot/alcc/alcc/connhub.cpp,v
retrieving revision 1.15
diff -u -r1.15 connhub.cpp
--- connhub.cpp 19 Oct 2006 00:02:03 -0000 1.15
+++ connhub.cpp 19 Oct 2006 16:40:00 -0000
@@ -224,7 +224,6 @@
"Registering %d as 0x%hx\n", connFD, how);
#endif
- pthread_mutex_lock (&poolAccessMutex);
if (!connections.count (connFD)) // Add a new connection
{
// The handle mechanism is there precisely to eliminate clone
@@ -243,7 +242,9 @@
pollStruct.events = how;
pollStruct.revents = 0;
+ pthread_mutex_lock (&poolAccessMutex);
pool.insert (pool.end (), pollStruct);
+ pthread_mutex_unlock (&poolAccessMutex);
if (conn->getHandle () != NULL)
{
@@ -253,12 +254,14 @@
}
else // Update the expected events
{
+ pthread_mutex_lock (&poolAccessMutex);
for (it = pool.begin (); it != pool.end (); it++)
{
if (it->fd == connFD)
{
it->events = how;
- break;
+ pthread_mutex_unlock (&poolAccessMutex);
+ return;
}
}
if (it == pool.end ())
@@ -269,8 +272,8 @@
"Could not find the descriptor for updating\n");
#endif
}
+ pthread_mutex_unlock (&poolAccessMutex);
}
- pthread_mutex_unlock (&poolAccessMutex);
}
/*