From eae169ca67a21ceec86f505a36bf187a0ed0cb43 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Mon, 1 Aug 2022 10:55:16 +0200 Subject: [PATCH] refactor: move interrupt out of releasePool helper --- src/PostgREST/AppState.hs | 2 +- src/PostgREST/Unix.hs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/PostgREST/AppState.hs b/src/PostgREST/AppState.hs index c4da56fe8..b451312ac 100644 --- a/src/PostgREST/AppState.hs +++ b/src/PostgREST/AppState.hs @@ -97,7 +97,7 @@ getPool :: AppState -> SQL.Pool getPool = statePool releasePool :: AppState -> IO () -releasePool AppState{..} = SQL.release statePool >> throwTo stateMainThreadId UserInterrupt +releasePool AppState{..} = SQL.release statePool getPgVersion :: AppState -> IO PgVersion getPgVersion = readIORef . statePgVersion diff --git a/src/PostgREST/Unix.hs b/src/PostgREST/Unix.hs index e003ccb24..acc1256ff 100644 --- a/src/PostgREST/Unix.hs +++ b/src/PostgREST/Unix.hs @@ -45,8 +45,11 @@ installSignalHandlers :: AppState.AppState -> IO () installSignalHandlers appState = do -- Releases the connection pool whenever the program is terminated, -- see https://github.com/PostgREST/postgrest/issues/268 - install Signals.sigINT $ AppState.releasePool appState - install Signals.sigTERM $ AppState.releasePool appState + let interrupt = do + AppState.releasePool appState + throwTo (AppState.getMainThreadId appState) UserInterrupt + install Signals.sigINT interrupt + install Signals.sigTERM interrupt -- The SIGUSR1 signal updates the internal 'DbStructure' by running -- 'connectionWorker' exactly as before.