This function (see below) can add *multiple* Conns to the pool
based on the same key. Why is this needed ? It may make more
sense to use dict_put_once() rather than dict_put() to
ensure that the Conns added to the pool are unique.
For this function to make sense, the opposite function should
randomly select a Conn from the returned list (conn_pool_get()).
It does'nt do this, instead it takes the first one that is still
alive.
The reason that this is an issue is that multiple Conns will hold
open resources on a server (notably socket descriptors) but will
never be used by the client. I have had a situation where the PPG
ran out of descriptors under a stress test from test_ppg.
Thanx,
static void conn_pool_put(Connection *conn, Octstr *host, int port)
{
Octstr *key;
List *list;
mutex_lock(conn_pool_lock);
key = conn_pool_key(host, port);
list = dict_get(conn_pool, key);
if (list == NULL) {
list = list_create();
dict_put(conn_pool, key, list);
}
list_append(list, conn);
octstr_destroy(key);
mutex_unlock(conn_pool_lock);
}