mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Make websocket send put back pressure on c2s process
Previously c2s was free to generate data to send in unlimited manner, and just generate queue of messages that are waiting to be send. This could lead to hitting timouts in stream management ack handling (if c2s generate lot of packages, after which <r> request was sent, client could even not receive it before timeout was triggered on server waiting for corresponding <a>). This changes makes c2s process wait for data being sent to tcp socket associated with websocket connection, which should help with this problem.
This commit is contained in:
parent
73f8aded17
commit
b95d67aefb
@ -364,5 +364,8 @@ parsed_items(List) ->
|
||||
|
||||
-spec route_text(pid(), binary()) -> ok.
|
||||
route_text(Pid, Data) ->
|
||||
Pid ! {text, Data},
|
||||
ok.
|
||||
Pid ! {text_with_reply, Data, self()},
|
||||
receive
|
||||
{text_reply, Pid} ->
|
||||
ok
|
||||
end.
|
||||
|
@ -225,6 +225,16 @@ ws_loop(FrameInfo, Socket, WsHandleLoopPid, SocketMode, Shaper) ->
|
||||
end,
|
||||
erlang:demonitor(Ref),
|
||||
websocket_close(Socket, WsHandleLoopPid, SocketMode, Code);
|
||||
{text_with_reply, Data, Sender} ->
|
||||
SocketMode:send(Socket, encode_frame(Data, 1)),
|
||||
Sender ! {text_reply, self()},
|
||||
ws_loop(FrameInfo, Socket, WsHandleLoopPid,
|
||||
SocketMode, Shaper);
|
||||
{data_with_reply, Data, Sender} ->
|
||||
SocketMode:send(Socket, encode_frame(Data, 2)),
|
||||
Sender ! {data_reply, self()},
|
||||
ws_loop(FrameInfo, Socket, WsHandleLoopPid,
|
||||
SocketMode, Shaper);
|
||||
{text, Data} ->
|
||||
SocketMode:send(Socket, encode_frame(Data, 1)),
|
||||
ws_loop(FrameInfo, Socket, WsHandleLoopPid,
|
||||
|
Loading…
Reference in New Issue
Block a user