rubinius/rubinius — pull request #2527 by iainbeeston (2013-08-04 06:29:04+00:00)
Title: Corrected call to BasicSocket.for_fd with wrong number of parameters

In UnixSocket#recv_io there's a call to IO#for_fd which passes two arguments. IO defines two or three parameters (depending on the ruby version), so that's fine. However, #recv_io allows the user to specify any Socket class to be used instead of IO. Unfortunately, although BasicSocket is a subclass of IO (and inherits the #for_fd method) it redefines the method signature to only take one argument, not two. So when a Socket is used (instead of IO) #recv_io crashes because it's passing the Socket two arguments when it only accepts one (for the #for_fd method).

My fix for this is to check what kind of socket is passed in, and if it's IO then to behave as before. But if it's a kind of BasicSocket, then only pass the first argument, not both.