From f9ecb13f523bba4fe69331ea65bf762516e47544 Mon Sep 17 00:00:00 2001 From: Ben Greenman Date: Fri, 30 May 2025 16:26:02 -0400 Subject: [PATCH] tcp: deduplicate, move code before loop --- lib/tcp/handler_chor.ex | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/tcp/handler_chor.ex b/lib/tcp/handler_chor.ex index 1269ab3..3eda205 100644 --- a/lib/tcp/handler_chor.ex +++ b/lib/tcp/handler_chor.ex @@ -10,13 +10,11 @@ defmodule Tcp.HandlerChor do TcpClient.read(sock) ~> Handler.(msg) with Handler.({resp, new_state}) <- Handler.run(msg, state) do + Handler.fmt_reply(resp) ~> TcpClient.(resp) + TcpClient.send_over_socket(sock, resp) if Handler.continue?(resp, new_state) do - Handler.fmt_reply(resp) ~> TcpClient.(resp) - TcpClient.send_over_socket(sock, resp) loop(Handler.(new_state), TcpClient.(sock)) else - Handler.fmt_reply(resp) ~> TcpClient.(resp) - TcpClient.send_over_socket(sock, resp) TcpClient.shutdown(sock) Handler.ack_shutdown() end