File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -957,39 +957,36 @@ module Connection (Mutex : Mutex) = struct
957957 let cancel_mtx = Mutex. create () in
958958 let finished = ref false in
959959 (* bool becomes true after deallocation *)
960- let check_null () =
960+ let check_finished () =
961961 if ! finished then
962- failwith " Postgresql.check_null : connection already finished"
962+ failwith " Postgresql.check_finished : connection already finished"
963963 in
964964 let wrap_conn f =
965965 Fun. protect
966966 ~finally: (fun _ -> Mutex. unlock conn_mtx)
967967 (fun _ ->
968968 Mutex. lock conn_mtx;
969- check_null () ;
970- (* Check again in case the world has changed *)
969+ check_finished () ;
971970 f my_conn)
972971 in
973972 let wrap_cancel f =
974- protectx
975- ~f: (fun _ ->
973+ Fun. protect
974+ ~finally: (fun _ -> Mutex. unlock cancel_mtx)
975+ (fun _ ->
976976 Mutex. lock cancel_mtx;
977- check_null () ;
978- (* Check again in case the world has changed *)
977+ check_finished () ;
979978 f my_conn)
980- ~finally: (fun _ -> Mutex. unlock cancel_mtx)
981979 in
982980 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
990982 ~finally: (fun _ ->
991983 Mutex. unlock cancel_mtx;
992984 Mutex. unlock conn_mtx)
985+ (fun _ ->
986+ Mutex. lock conn_mtx;
987+ Mutex. lock cancel_mtx;
988+ check_finished () ;
989+ f my_conn)
993990 in
994991 let signal_error conn =
995992 raise (Error (Connection_failure (Stub. error_message conn)))
You can’t perform that action at this time.
0 commit comments