From 6b798eb8b2f4edd3c6d1a02de6890f6ef1510785 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Wed, 14 Jul 2010 16:32:36 -0400 Subject: handle timeouts when using sync_reply --- src/fabric_rpc.erl | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/fabric_rpc.erl b/src/fabric_rpc.erl index 0a25948f..68733de6 100644 --- a/src/fabric_rpc.erl +++ b/src/fabric_rpc.erl @@ -250,7 +250,9 @@ view_fold(KV, OffsetReds, #view_acc{offset=nil, total_rows=Total} = Acc) -> ok -> view_fold(KV, OffsetReds, Acc#view_acc{offset=Offset}); stop -> - exit(normal) + exit(normal); + timeout -> + exit(timeout) end; view_fold(_KV, _Offset, #view_acc{limit=0} = Acc) -> % we scanned through limit+skip local rows @@ -272,13 +274,21 @@ view_fold({{Key,Id}, Value}, _Offset, Acc) -> couch_doc:to_json_obj(Doc0, []) end end, - rexi:sync_reply(#view_row{key=Key, id=Id, value=Value, doc=Doc}), - {ok, Acc#view_acc{limit=Limit-1}}. + case rexi:sync_reply(#view_row{key=Key, id=Id, value=Value, doc=Doc}) of + ok -> + {ok, Acc#view_acc{limit=Limit-1}}; + timeout -> + exit(timeout) + end. final_response(Total, nil) -> case rexi:sync_reply({total_and_offset, Total, Total}) of ok -> rexi:reply(complete); - stop -> ok end; + stop -> + ok; + timeout -> + exit(timeout) + end; final_response(_Total, _Offset) -> rexi:reply(complete). @@ -307,7 +317,9 @@ send(Key, Value, #view_acc{limit=Limit} = Acc) -> ok -> {ok, Acc#view_acc{limit=Limit-1}}; stop -> - exit(normal) + exit(normal); + timeout -> + exit(timeout) end. changes_enumerator(DocInfos, {Db, _Seq, Args}) -> -- cgit v1.2.3