From 571b8ceea1cce2f281a730c492c6396cf65642c9 Mon Sep 17 00:00:00 2001 From: Forrest L Norvell Date: Mon, 3 Jun 2013 22:14:28 -0700 Subject: [PATCH] Minimal hackitude to fix @gnarg's Erlang server. --- erlang/jon-simple/benchmark.erl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/erlang/jon-simple/benchmark.erl b/erlang/jon-simple/benchmark.erl index d26bc53..8abee27 100644 --- a/erlang/jon-simple/benchmark.erl +++ b/erlang/jon-simple/benchmark.erl @@ -3,17 +3,18 @@ start() -> crypto:start(), - {ok, Listen} = gen_tcp:listen(1337, [binary, - {reuseaddr, true}, - {backlog, 100}, - {active, false}]), - spawn(fun() -> connect(Listen) end). + spawn(fun() -> {ok, Listen} = gen_tcp:listen(1337, [binary, + {reuseaddr, true}, + {backlog, 100}, + {active, false}]), + connect(Listen) end). connect(Listen) -> {ok, Socket} = gen_tcp:accept(Listen), - spawn(fun() -> connect(Listen) end), - gen_tcp:send(Socket, "ok\n"), - handle(Socket). + Pid = spawn(fun() -> handle(Socket) end), + gen_tcp:controlling_process(Socket, Pid), + gen_tcp:send(Socket, "ok\n"), + connect(Listen). handle(Socket) -> inet:setopts(Socket, [{active, once}]),