fix redis
This commit is contained in:
parent
eb793e913b
commit
17532cb729
@ -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}} ->
|
||||
|
||||
@ -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} ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user