diff options
author | Nick Vatamaniuc <vatamane@apache.org> | 2018-04-03 19:13:35 -0400 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2018-04-04 17:58:26 +0200 |
commit | 0e926881c2c41a557cac035a779e2a95d13168ca (patch) | |
tree | 318816c0c1e9c3489bb059eff9e9c99903af4478 | |
parent | 02c9429d738e21f5dc5a92c33059e491e551a2f7 (diff) | |
download | couchdb-0e926881c2c41a557cac035a779e2a95d13168ca.tar.gz |
Kill fabric attachment receiver when middleman times out
Attachment receiver process is started with a plain spawn. If middleman process
dies, receiver would hang forever waiting on receive. After a long enough time
quite a few of these receiver processes could accumulate on a server.
Fixes #1264
-rw-r--r-- | src/fabric/src/fabric_doc_attachments.erl | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/fabric/src/fabric_doc_attachments.erl b/src/fabric/src/fabric_doc_attachments.erl index 47854d189..7c6ba6610 100644 --- a/src/fabric/src/fabric_doc_attachments.erl +++ b/src/fabric/src/fabric_doc_attachments.erl @@ -105,13 +105,13 @@ middleman(Req, chunked) -> % take requests from the DB writers and get data from the receiver N = erlang:list_to_integer(config:get("cluster","n")), - Timeout = fabric_util:request_timeout(), + Timeout = fabric_util:attachments_timeout(), middleman_loop(Receiver, N, [], [], Timeout); middleman(Req, Length) -> Receiver = spawn(fun() -> receive_unchunked_attachment(Req, Length) end), N = erlang:list_to_integer(config:get("cluster","n")), - Timeout = fabric_util:request_timeout(), + Timeout = fabric_util:attachments_timeout(), middleman_loop(Receiver, N, [], [], Timeout). middleman_loop(Receiver, N, Counters0, ChunkList0, Timeout) -> @@ -153,5 +153,6 @@ middleman_loop(Receiver, N, Counters0, ChunkList0, Timeout) -> middleman_loop(Receiver, N, Counters3, ChunkList3, Timeout) after Timeout -> + exit(Receiver, kill), ok end. |