Skip to content

Commit f3bbdb3

Browse files
authored
Merge pull request #53 from hdbc/force-finalizers
Ensure connections are strictly finalized.
2 parents a1f238e + 78bb3a9 commit f3bbdb3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Database/HDBC/PostgreSQL/Connection.hsc

+6-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mkConn auto_transaction args conn = withConn conn $
7979
serverver <- pqserverVersion cconn
8080
let clientver = #{const_str PG_VERSION}
8181
let rconn = Impl.Connection {
82-
Impl.disconnect = fdisconnect children,
82+
Impl.disconnect = fdisconnect conn children,
8383
Impl.begin = if auto_transaction
8484
then return ()
8585
else begin_transaction conn children,
@@ -170,8 +170,11 @@ fdescribeSchemaTable o cl maybeSchema table =
170170
desccol x =
171171
error $ "Got unexpected result from pg_attribute: " ++ show x
172172

173-
fdisconnect :: ChildList -> IO ()
174-
fdisconnect = closeAllChildren
173+
fdisconnect :: Conn -> ChildList -> IO ()
174+
fdisconnect (lock, fptr) childList = do
175+
closeAllChildren childList
176+
modifyMVar_ lock $ \_ ->
177+
finalizeForeignPtr fptr
175178

176179
foreign import ccall safe "libpq-fe.h PQconnectdb"
177180
pqconnectdb :: CString -> IO (Ptr CConn)

0 commit comments

Comments
 (0)