From 2b38b4528b1678098ad92734680e64db4c32c759 Mon Sep 17 00:00:00 2001 From: Dmitriy Ivolgin Date: Tue, 19 Aug 2014 11:33:10 -0400 Subject: [PATCH] When host/port process dies, ets table is not cleaned up, which breaks all subsequent connections to this host/port. --- src/ibrowse_lb.erl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ibrowse_lb.erl b/src/ibrowse_lb.erl index f5a9aef..aa381a4 100644 --- a/src/ibrowse_lb.erl +++ b/src/ibrowse_lb.erl @@ -216,7 +216,10 @@ handle_info(_Info, State) -> %% Description: Shutdown the server %% Returns: any (ignored by gen_server) %%-------------------------------------------------------------------- -terminate(_Reason, _State) -> +terminate(_Reason, #state{host = Host, port = Port}) -> + % Use delete_object instead of delete in case another process for this host/port + % has been spawned, in which case will be deleting the wrong record because pid won't match. + ets:delete_object(ibrowse_lb, #lb_pid{host_port = {Host, Port}, pid = self()}), ok. %%--------------------------------------------------------------------