X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=sql%2Fpool.lisp;h=e4f4b608b6d429549ae2d868cd64dcce920b54d3;hp=38d32cdd21a125c543bcbd4471b087c7cd4ffd3b;hb=2847fad43e1aa15f934108ce8f5e8dbe1fb1962d;hpb=cb82710efa09d65dca65d8b8316c6f877129a22c diff --git a/sql/pool.lisp b/sql/pool.lisp index 38d32cd..e4f4b60 100644 --- a/sql/pool.lisp +++ b/sql/pool.lisp @@ -33,7 +33,7 @@ that should, on avg keep the free connections about this size.") :initform (make-process-lock "Connection pool")))) -(defun acquire-from-pool (connection-spec database-type &optional pool) +(defun acquire-from-pool (connection-spec database-type &optional pool encoding) "Try to find a working database connection in the pool or create a new one if needed. This performs 1 query against the DB to ensure it's still valid. When possible (postgres, mssql) that query will be a reset @@ -68,7 +68,8 @@ Disconnecting.~%" (let ((conn (connect (connection-spec pool) :database-type (pool-database-type pool) :if-exists :new - :make-default nil))) + :make-default nil + :encoding encoding))) (with-process-lock ((conn-pool-lock pool) "new conection") (push conn (all-connections pool)) (setf (conn-pool conn) pool)) @@ -85,8 +86,9 @@ chance to do cleanup." ;;not the list). Multiple threads getting to this test at the ;;same time might result in the free-connections getting ;;longer... meh. - ((>= (length (free-connections pool)) - *db-pool-max-free-connections*) + ((and *db-pool-max-free-connections* + (>= (length (free-connections pool)) + *db-pool-max-free-connections*)) (%pool-force-disconnect database) (with-process-lock ((conn-pool-lock pool) "Remove extra Conn") (setf (all-connections pool)