summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--ext/openssl/lib/openssl/buffering.rb4
-rw-r--r--ext/openssl/lib/openssl/ssl.rb10
-rw-r--r--ext/openssl/ossl_ssl.c4
4 files changed, 31 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5392b80a43..fb31298acf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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):
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb
index 31dcdf1f9a..7ad12d7203 100644
--- a/ext/openssl/lib/openssl/buffering.rb
+++ b/ext/openssl/lib/openssl/buffering.rb
@@ -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
diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb
index 9c31fa73cd..7f61fc2a62 100644
--- a/ext/openssl/lib/openssl/ssl.rb
+++ b/ext/openssl/lib/openssl/ssl.rb
@@ -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
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 89c4ec1c6c..e85430e859 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -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:");
}