1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/openssl/ossl_ssl.c (ossl_ssl_read, ossl_ssl_write): should

call rb_sys_fail instead of rasing SSLError if SSL_ERROR_SYSCALL
  occured.

* ext/openssl/lib/openssl/buffering.rb (Buffering#fill_rbuff):
  should rescue Errno::EAGAIN.

* ext/openssl/lib/openssl/buffering.rb (Buffering#each): fix typo.
  suggested by Brian Ollenberger.

* ext/openssl/lib/openssl/ssl.rb: set non-blocking flag to the
  underlying IO.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2005-02-15 17:50:47 +00:00
parent e65affb360
commit a579d8bf68
4 changed files with 31 additions and 2 deletions

View file

@ -1,3 +1,18 @@
Wed Feb 16 02:47:45 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_ssl.c (ossl_ssl_read, ossl_ssl_write): should
call rb_sys_fail instead of rasing SSLError if SSL_ERROR_SYSCALL
occured.
* ext/openssl/lib/openssl/buffering.rb (Buffering#fill_rbuff):
should rescue Errno::EAGAIN.
* ext/openssl/lib/openssl/buffering.rb (Buffering#each): fix typo.
suggested by Brian Ollenberger.
* ext/openssl/lib/openssl/ssl.rb: set non-blocking flag to the
underlying IO.
Mon Feb 14 23:58:17 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/parser.rb (RSS::ListenerMixin::tag_end):

View file

@ -32,6 +32,8 @@ module Buffering
@rbuffer = "" unless defined? @rbuffer
begin
@rbuffer << self.sysread(BLOCK_SIZE)
rescue Errno::EAGAIN
retry
rescue EOFError
@eof = true
end
@ -84,7 +86,7 @@ module Buffering
end
def each(eol=$/)
while line = self.gets(eol?)
while line = self.gets(eol)
yield line
end
end

View file

@ -16,6 +16,7 @@
require "openssl"
require "openssl/buffering"
require "fcntl"
module OpenSSL
module SSL
@ -49,9 +50,18 @@ module OpenSSL
end
end
module Nonblock
def initialize(*args)
flag = @io.fcntl(Fcntl::F_GETFL) | File::NONBLOCK
@io.fcntl(Fcntl::F_SETFL, flag)
super
end
end
class SSLSocket
include Buffering
include SocketForwarder
include Nonblock
def post_connection_check(hostname)
check_common_name = true

View file

@ -517,7 +517,7 @@ ossl_ssl_read(int argc, VALUE *argv, VALUE self)
continue;
case SSL_ERROR_SYSCALL:
if(ERR_peek_error() == 0 && nread == 0) rb_eof_error();
ossl_raise(eSSLError, "SSL_read: %s", strerror(errno));
rb_sys_fail(0);
default:
ossl_raise(eSSLError, "SSL_read:");
}
@ -556,6 +556,8 @@ ossl_ssl_write(VALUE self, VALUE str)
case SSL_ERROR_WANT_READ:
rb_thread_schedule();
continue;
case SSL_ERROR_SYSCALL:
rb_eof_error();
default:
ossl_raise(eSSLError, "SSL_write:");
}