Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify state in Ace.HTTP.Server #70

Closed
CharlesOkwuagwu opened this issue Nov 12, 2017 · 3 comments
Closed

Clarify state in Ace.HTTP.Server #70

CharlesOkwuagwu opened this issue Nov 12, 2017 · 3 comments

Comments

@CharlesOkwuagwu
Copy link
Contributor

def handle_call({:accept, {:tcp, listen_socket}}, from, state) do
case :gen_tcp.accept(listen_socket) do
{:ok, socket} ->
:ok = :inet.setopts(socket, active: :once)
state = %{state | socket: socket}
{:ok, worker} = Supervisor.start_child(state.worker_supervisor, [:the_channel])
monitor = Process.monitor(worker)
state = %Ace.HTTP1.Endpoint{
status: {:request, :response},
socket: {:tcp, socket},
# Worker and channel could live on same key, there is no channel without a worker
channel: {:http1, self(), 1},
worker: worker
}
GenServer.reply(from, {:ok, self()})
:gen_server.enter_loop(Ace.HTTP1.Endpoint, [], {"", state})

Is the state from Line:51 the same state that's being overwritten on line on Line:59?

If yes, then line Line:55 is unnecessary ... same appears again further down.
This would also make :socket unnecessary in defstruct [:worker_supervisor, :settings, :socket]

@CharlesOkwuagwu CharlesOkwuagwu changed the title clarification of state in Ace.HTTP.Server Clarify state in Ace.HTTP.Server Nov 12, 2017
@CrowdHailer
Copy link
Owner

A cursory glance suggests line 55 is unnecessary. I can't explicitly remember typing that line. I would just delete it and check all the tests pass.

If doing so introduces a bug but no test fails then we discover a new test that needs writing

@CrowdHailer
Copy link
Owner

Did you try the tests with this line deleted

@CharlesOkwuagwu
Copy link
Contributor Author

Yes. It works the same with that line commented out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants