From: Young Hyun Date: 2010-01-05T11:17:39+09:00 Subject: [ruby-core:27406] Re: [ANN] openssl-nonblock 0.2.1: moving towards compatibility with Ruby 1.9.2 On Dec 15, 2009, at 11:04 PM, Tony Arcieri wrote: > I implement the following methods as part of OpenSSL::SSL::SSLSocket: > � connect_nonblock: connect to an SSL server > � accept_nonblock: accept an SSL connection > � read_nonblock(length): read up to the given length, but don�t block > � write_nonblock(data): write as much of the given data as possible > without blocking > I raise the following exceptions: > > � IO::WaitReadable: this means OpenSSL needs to read more data to > complete the > given request. You should wait until the underlying IO object becomes > readable again before retrying the request. > � IO::WaitWritable similar to above, except OpenSSL is trying to > write data to > the IO object, and the IO object is not presently writable. You > should wait > until the object becomes writable again before retrying the request. > Does this sound like I am properly matching what is available in > Ruby 1.9.2? I compared the behavior of openssl-nonblock to Ruby 1.9.2 (but not exhaustively), and the main issue I saw was the use of a different underlying exception object. Ruby 1.9.2 raises an SSLError while openssl-nonblock raises its own ReadAgain/WriteAgain object extended with IO::WaitReadable/IO::WaitWritable. Now, if all one cares about is being notified that the operation would block (that is, if one is just rescuing WaitReadable/WaitWritable), then openssl-nonblock and Ruby 1.9.2 are indistinguishable. However, it's possible for someone to rescue SSLError directly, and then the difference shows up. I tried creating a patch to make openssl-nonblock use SSLError just like Ruby 1.9.2, but that seemed like it was going to be more work than I expected (partly because somethings are defined static inside the OpenSSL extension). I'm not sure how important this difference is in practice, because it mainly affects a narrow use case--running a program written for Ruby 1.9.2 or later on an older Ruby (that is, backporting features). That's a different use case than supporting nonblocking OpenSSL I/O on older Ruby versions in a *forward* compatible manner (obviously, for portability, such code should not rescue ReadAgain/WriteAgain, only WaitReadable/WaitWritable). --Young