should't block when locked!!!!
see below code for detail:
Connection_T ConnectionPool_getConnection(T P) {
Connection_T con = NULL;
assert(P);
LOCK(P->mutex)
{
int size = Vector_size(P->pool);
for (int i = 0; i < size; i++) {
con = Vector_get(P->pool, i);
if (Connection_isAvailable(con) && Connection_ping(con)) {
Connection_setAvailable(con, false);
goto done;
}
}
con = NULL;
if (size < P->maxConnections) {
con = Connection_new(P, &P->error);
if (con) {
Connection_setAvailable(con, false);
Vector_push(P->pool, con);
} else {
DEBUG("Failed to create connection -- %s\n", P->error);
FREE(P->error);
}
}
}
done:
END_LOCK;
return con;
}