1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

B #3182 Initialize number of connections

This commit is contained in:
Christian González 2019-04-15 17:10:07 +02:00 committed by Ruben S. Montero
parent e25e25ca6b
commit fa15207ae7

View File

@ -26,11 +26,13 @@
class ConnectionManager
{
public:
ConnectionManager(RequestManager *_rm, int mc):rm(_rm), max_connections(mc)
ConnectionManager(RequestManager *_rm, int mc):rm(_rm), connections(0),
max_connections(mc)
{
pthread_mutex_init(&mutex,0);
pthread_cond_init(&cond,0);
};
~ConnectionManager()
@ -46,12 +48,12 @@ public:
int add()
{
pthread_mutex_lock(&mutex);
++connections;
int temp_connections = ++connections;
pthread_mutex_unlock(&mutex);
return connections;
return temp_connections;
};
/**
@ -60,7 +62,7 @@ public:
void del()
{
pthread_mutex_lock(&mutex);
--connections;
pthread_cond_signal(&cond);