make the main loop lists the children id instead of the pthread_id

This commit is contained in:
ps 2011-01-08 01:38:29 +00:00
parent 3b0c15ac6f
commit 1c5b70b2a6

View file

@ -60,7 +60,7 @@ LOGGER_CLASS hermes_log;
//print at the start of log messages //print at the start of log messages
__thread unsigned long connection_id; __thread unsigned long connection_id;
list<pthread_t> children; list<unsigned long> children;
#ifdef HAVE_SSL #ifdef HAVE_SSL
pthread_mutex_t ssl_locks[CRYPTO_NUM_LOCKS]={PTHREAD_MUTEX_INITIALIZER}; pthread_mutex_t ssl_locks[CRYPTO_NUM_LOCKS]={PTHREAD_MUTEX_INITIALIZER};
@ -223,7 +223,7 @@ main
{ {
LDEB("New thread created [" + Utils::ulongtostr(nconns) + "] thread_id: " + Utils::ulongtostr(thread)); LDEB("New thread created [" + Utils::ulongtostr(nconns) + "] thread_id: " + Utils::ulongtostr(thread));
pthread_mutex_lock(&childrenlist_mutex); pthread_mutex_lock(&childrenlist_mutex);
children.push_back(thread); children.push_back(nconns);
pthread_mutex_unlock(&childrenlist_mutex); pthread_mutex_unlock(&childrenlist_mutex);
} }
} }
@ -321,7 +321,7 @@ void *cleaner_thread_run(void *)
pthread_mutex_lock(&childrenlist_mutex); pthread_mutex_lock(&childrenlist_mutex);
ss << children.size() << " threads running: "; ss << children.size() << " threads running: ";
for(list<pthread_t>::iterator i=children.begin();i!=children.end();i++) for(list<unsigned long>::iterator i=children.begin();i!=children.end();i++)
ss << "[ " << *i << " ] "; ss << "[ " << *i << " ] ";
pthread_mutex_unlock(&childrenlist_mutex); pthread_mutex_unlock(&childrenlist_mutex);
ss << endl; ss << endl;
@ -364,7 +364,7 @@ void *thread_main(void *info_stack)
client.setFD(peerinfo.new_fd); client.setFD(peerinfo.new_fd);
p.setOutside(client); p.setOutside(client);
p.run(peerinfo.peer_address); p.run(peerinfo.peer_address);
remove_thread_from_list(pthread_self()); remove_thread_from_list(connection_id);
} }
catch(Exception &e) catch(Exception &e)
{ {