aboutsummaryrefslogtreecommitdiffstats
path: root/src/cow_ws.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-10-03 23:32:25 +0200
committerLoïc Hoguin <[email protected]>2016-10-03 23:32:25 +0200
commitd53cd5297e1b8baffaf5a649f2c6a9763800c569 (patch)
tree6027c10dc1181797ca451cc721e27abe3529545d /src/cow_ws.erl
parent25185cf0140abe6414574ee0a16082d28330e880 (diff)
downloadcowlib-d53cd5297e1b8baffaf5a649f2c6a9763800c569.tar.gz
cowlib-d53cd5297e1b8baffaf5a649f2c6a9763800c569.tar.bz2
cowlib-d53cd5297e1b8baffaf5a649f2c6a9763800c569.zip
Add owner option to set owner of Websocket compression contexts
Required by Cowboy 2 because it initializes the contexts in a different process than where they are used.
Diffstat (limited to 'src/cow_ws.erl')
-rw-r--r--src/cow_ws.erl10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/cow_ws.erl b/src/cow_ws.erl
index 6551cbc..24917bb 100644
--- a/src/cow_ws.erl
+++ b/src/cow_ws.erl
@@ -149,6 +149,16 @@ init_permessage_deflate(InflateWindowBits, DeflateWindowBits, Opts) ->
-DeflateWindowBits2,
maps:get(mem_level, Opts, 8),
maps:get(strategy, Opts, default)),
+ %% Set the owner pid of the zlib contexts if requested.
+ _ = case Opts of
+ #{owner := Pid} ->
+ true = erlang:port_connect(Inflate, Pid),
+ true = unlink(Inflate),
+ true = erlang:port_connect(Deflate, Pid),
+ unlink(Deflate);
+ _ ->
+ true
+ end,
{Inflate, Deflate}.
%% @doc Negotiate the x-webkit-deflate-frame extension.