Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't call TCPConnection backpressure notifies incorrectly #1904

Merged
merged 1 commit into from
May 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions packages/net/tcp_connection.pony
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ actor TCPConnection
var _connected: Bool = false
var _readable: Bool = false
var _writeable: Bool = false
var _throttled: Bool = false
var _closed: Bool = false
var _shutdown: Bool = false
var _shutdown_peer: Bool = false
Expand Down Expand Up @@ -881,16 +882,22 @@ actor TCPConnection
try (_listen as TCPListener)._conn_closed() end

fun ref _apply_backpressure() =>
ifdef not windows then
_writeable = false
if not _throttled then
_throttled = true
ifdef not windows then
_writeable = false

// this is safe because asio thread isn't currently subscribed
// for a write event so will not be writing to the readable flag
@pony_asio_event_set_writeable(_event, false)
@pony_asio_event_resubscribe_write(_event)
end
// this is safe because asio thread isn't currently subscribed
// for a write event so will not be writing to the readable flag
@pony_asio_event_set_writeable(_event, false)
@pony_asio_event_resubscribe_write(_event)
end

_notify.throttled(this)
_notify.throttled(this)
end

fun ref _release_backpressure() =>
_notify.unthrottled(this)
if _throttled then
_throttled = false
_notify.unthrottled(this)
end