fix redis

This commit is contained in:
anlicheng 2026-02-28 22:35:24 +08:00
parent eb793e913b
commit 17532cb729
2 changed files with 4 additions and 2 deletions

View File

@ -29,12 +29,13 @@
%%--------------------------------------------------------------------
start(Socket) ->
spawn_link(?MODULE, loop, [#state{socket = Socket, command = #command{}}]).
spawn(?MODULE, loop, [#state{socket = Socket, command = #command{}}]).
loop(State=#state{socket = Socket, command = Command = #command{data = Data}}) ->
inet:setopts(Socket, [{active, once}]),
receive
{tcp, _, Packet} ->
logger:debug("channel rec: ~p", [Packet]),
NData = <<Data/binary, Packet/binary>>,
case parse(Command#command{data = NData}) of
{ok, #command{args = Args}} ->

View File

@ -32,8 +32,9 @@ init(Port) ->
accept_loop(LSocket) ->
case gen_tcp:accept(LSocket) of
{ok, Socket} ->
logger:debug("accept socket: ~p", [Socket]),
%%
Pid = spawn(fun() -> maxwell_redis_channel:start(Socket) end),
Pid = maxwell_redis_channel:start(Socket),
ok = gen_tcp:controlling_process(Socket, Pid),
accept_loop(LSocket);
{error, closed} ->