diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-28 10:02:54 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-28 10:02:54 +0000 |
commit | cbd370f669e74ca3e1953da94d4e780b7ddea391 (patch) | |
tree | 553cd6c289fe6b95eebc4d61d1aa7cc3a354be48 /test/net | |
parent | 02afafb42ae4ae98140f2c79c67b948e1e6bc577 (diff) | |
download | ruby-cbd370f669e74ca3e1953da94d4e780b7ddea391.tar.gz |
* lib/net/imap.rb (Net::IMAP#initialize): Close the opened socket when
any exception occur.
This fixes a fd leak by IMAPTest#test_imaps_post_connection_check
which start_tls_session() raises an exception.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net')
-rw-r--r-- | test/net/imap/test_imap.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb index 4abb7b48f3..ecec2a5d5e 100644 --- a/test/net/imap/test_imap.rb +++ b/test/net/imap/test_imap.rb @@ -505,19 +505,20 @@ class IMAPTest < Test::Unit::TestCase ths = Thread.start do begin sock = server.accept - sock.print("* OK test server\r\n") - sock.gets - sock.print("RUBY0001 OK completed\r\n") - ctx = OpenSSL::SSL::SSLContext.new - ctx.ca_file = CA_FILE - ctx.key = File.open(SERVER_KEY) { |f| - OpenSSL::PKey::RSA.new(f) - } - ctx.cert = File.open(SERVER_CERT) { |f| - OpenSSL::X509::Certificate.new(f) - } - sock = OpenSSL::SSL::SSLSocket.new(sock, ctx) begin + sock.print("* OK test server\r\n") + sock.gets + sock.print("RUBY0001 OK completed\r\n") + ctx = OpenSSL::SSL::SSLContext.new + ctx.ca_file = CA_FILE + ctx.key = File.open(SERVER_KEY) { |f| + OpenSSL::PKey::RSA.new(f) + } + ctx.cert = File.open(SERVER_CERT) { |f| + OpenSSL::X509::Certificate.new(f) + } + sock = OpenSSL::SSL::SSLSocket.new(sock, ctx) + sock.sync_close = true sock.accept sock.gets sock.print("* BYE terminating connection\r\n") |