Skip to content

Commit 812ce9e

Browse files
committed
Don't kill the process_label entry on each request
1 parent 35b5cc6 commit 812ce9e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/bandit/http1/handler.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ defmodule Bandit.HTTP1.Handler do
4343

4444
defp clear_process_dict do
4545
Process.get_keys()
46-
|> Enum.each(&if &1 not in ~w[$ancestors $initial_call]a, do: Process.delete(&1))
46+
|> Enum.each(
47+
&if &1 not in ~w[$ancestors $initial_call $process_label]a, do: Process.delete(&1)
48+
)
4749
end
4850

4951
defp do_websocket_upgrade(upgrade_opts, state) do

test/bandit/http1/plug_test.exs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,19 @@ defmodule HTTP1PlugTest do
167167
client = SimpleHTTP1Client.tcp_client(context)
168168

169169
SimpleHTTP1Client.send(client, "GET", "/pdict", ["host: localhost"])
170-
assert {:ok, "200 OK", _headers, "[]"} = SimpleHTTP1Client.recv_reply(client)
170+
171+
# We should keep the process_label entry around
172+
assert {:ok, "200 OK", _headers,
173+
"[\"$process_label\": {:thousand_island, :connection, {Bandit.DelegatingHandler, {{127, 0, 0, 1}," <>
174+
_dynamic_port} =
175+
SimpleHTTP1Client.recv_reply(client)
171176

172177
SimpleHTTP1Client.send(client, "GET", "/pdict", ["host: localhost"])
173-
assert {:ok, "200 OK", _headers, "[]"} = SimpleHTTP1Client.recv_reply(client)
178+
179+
assert {:ok, "200 OK", _headers,
180+
"[\"$process_label\": {:thousand_island, :connection, {Bandit.DelegatingHandler, {{127, 0, 0, 1}," <>
181+
_dynamic_port} =
182+
SimpleHTTP1Client.recv_reply(client)
174183
end
175184

176185
def pdict(conn) do

0 commit comments

Comments
 (0)