File tree Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Original file line number Diff line number Diff line change @@ -957,39 +957,36 @@ module Connection (Mutex : Mutex) = struct
957
957
let cancel_mtx = Mutex. create () in
958
958
let finished = ref false in
959
959
(* bool becomes true after deallocation *)
960
- let check_null () =
960
+ let check_finished () =
961
961
if ! finished then
962
- failwith " Postgresql.check_null : connection already finished"
962
+ failwith " Postgresql.check_finished : connection already finished"
963
963
in
964
964
let wrap_conn f =
965
965
Fun. protect
966
966
~finally: (fun _ -> Mutex. unlock conn_mtx)
967
967
(fun _ ->
968
968
Mutex. lock conn_mtx;
969
- check_null () ;
970
- (* Check again in case the world has changed *)
969
+ check_finished () ;
971
970
f my_conn)
972
971
in
973
972
let wrap_cancel f =
974
- protectx
975
- ~f: (fun _ ->
973
+ Fun. protect
974
+ ~finally: (fun _ -> Mutex. unlock cancel_mtx)
975
+ (fun _ ->
976
976
Mutex. lock cancel_mtx;
977
- check_null () ;
978
- (* Check again in case the world has changed *)
977
+ check_finished () ;
979
978
f my_conn)
980
- ~finally: (fun _ -> Mutex. unlock cancel_mtx)
981
979
in
982
980
let wrap_both f =
983
- protectx
984
- ~f: (fun _ ->
985
- Mutex. lock conn_mtx;
986
- Mutex. lock cancel_mtx;
987
- check_null () ;
988
- (* Check again in case the world has changed *)
989
- f my_conn)
981
+ Fun. protect
990
982
~finally: (fun _ ->
991
983
Mutex. unlock cancel_mtx;
992
984
Mutex. unlock conn_mtx)
985
+ (fun _ ->
986
+ Mutex. lock conn_mtx;
987
+ Mutex. lock cancel_mtx;
988
+ check_finished () ;
989
+ f my_conn)
993
990
in
994
991
let signal_error conn =
995
992
raise (Error (Connection_failure (Stub. error_message conn)))
You can’t perform that action at this time.
0 commit comments