#1195: Socket#accept_nonblock blocks for Unix domain socket --------------------------------------+------------------------------------- Reporter: warpflyght@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: --------------------------------------+------------------------------------- Socket#accept_nonblock (and UNIXServer#accept_nonblock) appear to block. I haven't tried constructing a UDP or TCP socket with Socket, but I suspect this issue affects all Socket subclasses. Test programs: UNIXServer: {{{ #!ruby require 'socket' require 'fileutils' FileUtils.rm_f("/tmp/sock") serv = UNIXServer.new("/tmp/sock") begin warn "Accepting." sock = serv.accept_nonblock rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR warn "Would block; retrying." retry end warn "Have socket." }}} Socket: {{{ #!ruby require 'socket' require 'fileutils' FileUtils.rm_f("/tmp/sock") serv = Socket.new(Socket::AF_UNIX, Socket::SOCK_STREAM, 0) serv.bind(Socket.sockaddr_un("/tmp/sock")) serv.listen(1) begin warn "Accepting." sock, sockaddr = serv.accept_nonblock rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR warn "Would block; retrying." retry end warn "Have socket." }}} When run with Ruby 1.8.7 on my Snow Leopard machine, these print "Accepting" followed by "Would block; retrying" repeatedly, as expected. Under MacRuby r5278 on the same system, both programs just print "Accepting" and do nothing. Connecting to the socket immediately prints "Have socket" under both interpreters. I searched Trac for duplicates, but the closest I found was #554. In the case of IO#read_nonblock and IO#write_nonblock, the C functions are actually unimplemented; in this case, they are implemented, but don't work as documented. -- Ticket URL: <http://www.macruby.org/trac/ticket/1195> MacRuby <http://macruby.org/>