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

Socket#connect_nonblock working? #1461

Closed
ioquatix opened this issue Nov 7, 2018 · 5 comments
Closed

Socket#connect_nonblock working? #1461

ioquatix opened this issue Nov 7, 2018 · 5 comments
Assignees
Labels
Milestone

Comments

@ioquatix
Copy link
Contributor

ioquatix commented Nov 7, 2018

I print out the status from

  def connect_nonblock(sockaddr, exception: true)
    fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK)

    if sockaddr.is_a?(Addrinfo)
      sockaddr = sockaddr.to_sockaddr
    end

    status = Truffle::Socket::Foreign.connect(descriptor, sockaddr)

    if status < 0
      if exception
        Truffle::Socket::Error.write_nonblock('connect(2)')
      else
        :wait_writable
      end
    else
      0
    end
  end

and it's always -1.

The exact same code works fine on MRI.

@ioquatix
Copy link
Contributor Author

ioquatix commented Nov 7, 2018

What's odd is that the server accepts the connection but it continues to return -1:

Server accepting...
Client connect...
status=-1
Server read...
status=-1
status=-1
status=-1
status=-1
status=-1
status=-1

@ioquatix
Copy link
Contributor Author

ioquatix commented Nov 7, 2018

Okay so I found out the problem. You are not correctly handling Errno::EISCONN.

@ioquatix
Copy link
Contributor Author

ioquatix commented Nov 7, 2018

Here is a monkey patch: socketry/async-io@3380a7d

@eregon
Copy link
Member

eregon commented Nov 13, 2018

Fixed by #1465.

@eregon eregon closed this as completed Nov 13, 2018
@eregon eregon self-assigned this Nov 13, 2018
@eregon eregon added the bug label Nov 13, 2018
@eregon eregon added this to the 1.0.0-rc10 milestone Nov 13, 2018
@ioquatix
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants