Commit 09307476 authored by gerd's avatar gerd

fix TCP close


git-svn-id: https://gps.dynxs.de/private/svn/app-plasma/trunk@259 55289a75-7b90-4627-9e07-ffb4263930b2
parent f122ef42
......@@ -31,8 +31,13 @@
(** Implementation of [Nameslave] *)
type slavetrans =
{ trans : Nn_db.transaction;
conn_id : Rpc_server.connection_id
}
module Nn_db_transaction_var =
Netplex_cenv.Make_var_type(struct type t = Nn_db.transaction option end)
Netplex_cenv.Make_var_type(struct type t = slavetrans option end)
let get_trans() =
try
......@@ -60,7 +65,8 @@ let proc_begin_transaction conf sess (cname,exp_rev) emit =
Uq_engines.when_state
~is_done:(fun rev ->
if rev = exp_rev then (
set_trans t;
let conn_id = Rpc_server.get_connection_id sess in
set_trans { trans = t; conn_id = conn_id };
emit ()
)
else (
......@@ -86,7 +92,8 @@ let proc_prepare_commit sess () emit =
match get_trans() with
| None ->
failwith "Nameslave.prepare_commit: Not in a transaction"
| Some t ->
| Some st ->
let t = st.trans in
let e =
new Uq_engines.map_engine
~map_done:(fun () -> `Done true)
......@@ -112,7 +119,8 @@ let proc_commit sess () emit =
match get_trans() with
| None ->
failwith "Nameslave.commit: Not in a transaction"
| Some t ->
| Some st ->
let t = st.trans in
let e = t#commit() in
Uq_engines.when_state
~is_done:(fun () ->
......@@ -136,7 +144,8 @@ let push procname f sess emit =
match get_trans() with
| None ->
failwith ("Nameslave." ^ procname ^ ": Not in a transaction")
| Some t ->
| Some st ->
let t = st.trans in
let esys = (Netplex_cenv.self_cont()) # event_system in
let e =
f t#connection esys in
......@@ -254,11 +263,14 @@ let onclose_nameslave srv conn_id =
match get_trans() with
| None ->
()
| Some t ->
Netlog.logf `Info
"Rolling transaction back after TCP close";
unset_trans();
ignore(t#rollback())
| Some st ->
if st.conn_id = conn_id then (
let t = st.trans in
Netlog.logf `Info
"Rolling transaction back after TCP close";
unset_trans();
ignore(t#rollback())
)
(** Binding RPC servers: *)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment