Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Connection#pause doesn't works with kqueue for read events #339

Open
timon opened this Issue · 0 comments

1 participant

@timon

Calling #pause on EM::Connection doesn't prevent reading from descriptor if EM.kqueue is set.

Here's adapted test code from #245

require 'eventmachine'

module PopenConnection
  def post_init
    @rec = 0
  end

  def receive_data(data)
    puts "receive_data: #{data.size}"
    @rec += data.size
    if !paused? && @rec > 500 * 1024
      puts "pausing"
      pause
      EM.add_timer(5) { puts "resuming"; @rec = 0; resume }
    end
  end

  def unbind
    puts "unbind"
  end
end

EM.kqueue = true if !ARGV[0] || ARGV[0] != 'select'
fork { exec "sleep 1; cat /dev/urandom | nc 127.0.0.1 7777" }
EM.run { EM.start_server '0.0.0.0', 7777, PopenConnection }

My investigation ended up in EventableDescriptor::_UpdateEvents calling EventMachine::ArmKqueueReader(), which differs from ArmKqueueWriter in not setting the EV_ONESHOT flag.
It looks like there should be code to remove corresponding read filter, but I'm not sure on how to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.