log, for now as I've seen assertions failures suggesting a race, the

set of checked-out sockets at insert and remove time.
This commit is contained in:
Andy2 2010-09-23 06:34:18 -07:00
parent 40e1d29243
commit c44324a32a
2 changed files with 21 additions and 2 deletions

View file

@ -402,15 +402,18 @@ XWThreadPool::grab_elem_locked( QueuePr* prp )
deque<QueuePr>::iterator iter;
for ( iter = m_queue.begin(); !found && iter != m_queue.end(); ++iter ) {
int socket = iter->m_socket;
/* If NOT found */
if ( m_sockets_in_use.end() == m_sockets_in_use.find( socket ) ) {
*prp = *iter;
m_queue.erase( iter ); /* double-free! */
m_queue.erase( iter ); /* this was a double-free once! */
m_sockets_in_use.insert( socket );
found = true;
}
}
logf( XW_LOGINFO, "%s()=>%d", __func__, found );
print_in_use();
logf( XW_LOGINFO, "%s()=>%d", __func__, prp->m_socket );
} /* grab_elem_locked */
void
@ -422,4 +425,19 @@ XWThreadPool::release_socket_locked( int socket )
assert( iter != m_sockets_in_use.end() );
m_sockets_in_use.erase( iter );
}
print_in_use();
}
void
XWThreadPool::print_in_use( void )
{
char buf[32] = {0};
int len = 0;
set<int>::iterator iter;
for ( iter = m_sockets_in_use.begin();
iter != m_sockets_in_use.end(); ++iter ) {
len += snprintf( &buf[len], sizeof(buf)-len, "%d ", *iter );
}
logf( XW_LOGINFO, "%s: %s", __func__, buf );
}

View file

@ -62,6 +62,7 @@ class XWThreadPool {
void enqueue( int socket, QAction act = Q_READ );
void release_socket_locked( int socket );
void grab_elem_locked( QueuePr* qpp );
void print_in_use( void );
bool get_process_packet( int socket );
void interrupt_poll();