- (if (zerop (length (free-connections pool)))
- (let ((conn (connect (connection-spec pool)
- :database-type (database-type pool) :if-exists :new)))
- (vector-push-extend conn (all-connections pool))
- (setf (conn-pool conn) pool)
- conn)
- (vector-pop (free-connections pool))))
+ (or (with-lock-held ((conn-pool-lock pool) "Acquire from pool")
+ (and (plusp (length (free-connections pool)))
+ (vector-pop (free-connections pool))))
+ (let ((conn (connect (connection-spec pool)
+ :database-type (database-type pool)
+ :if-exists :new)))
+ (with-lock-held ((conn-pool-lock pool) "Acquire from pool")
+ (vector-push-extend conn (all-connections pool))
+ (setf (conn-pool conn) pool))
+ conn)))