提交 ce5f9bb2 编写于 作者: T Tinco Andringa

fix race condition in websocket stream write

上级 49a881e0
......@@ -11,6 +11,7 @@ def initialize(event_loop, socket)
@stream_send = socket.env['stream.send']
@rack_hijack_io = nil
@write_lock = Mutex.new
end
def each(&callback)
......@@ -27,10 +28,13 @@ def shutdown
end
def write(data)
@write_lock.lock
return @rack_hijack_io.write(data) if @rack_hijack_io
return @stream_send.call(data) if @stream_send
rescue EOFError, Errno::ECONNRESET
@socket_object.client_gone
ensure
@write_lock.unlock
end
def receive(data)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册