From e377a12bff690512a568b93c018ec42961ac2a48 Mon Sep 17 00:00:00 2001 From: aamine Date: Mon, 29 Sep 2003 18:12:20 +0000 Subject: * lib/net/http.rb (finish): revert to 1.93. * lib/net/pop.rb (finish): revert to 1.60. * lib/net/smtp.rb (finish): revert to 1.67. * lib/net/http.rb (do_start): ensure to close socket if failed to start session. * lib/net/pop.rb (do_start): ditto. * lib/net/smtp.rb (do_start): ditto. * lib/net/smtp.rb: SMTP#started? wrongly returned false always. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/smtp.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/net/smtp.rb') diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index b14d43832a..21c04812fe 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -331,7 +331,7 @@ module Net # :nodoc: do_start(helo, user, secret, authtype) return yield(self) ensure - finish + do_finish end else do_start(helo, user, secret, authtype) @@ -362,17 +362,28 @@ module Net # :nodoc: raise end authenticate user, secret, authtype if user + @started = true + ensure + @socket.close if not @started and @socket and not @socket.closed? end private :do_start # Finishes the SMTP session and closes TCP connection. + # Raises IOError if not started. def finish + raise IOError, 'not started yet' unless started? + do_finish + end + + def do_finish quit if @socket and not @socket.closed? and not @error_occured + ensure + @started = false + @error_occured = false @socket.close if @socket and not @socket.closed? @socket = nil - @error_occured = false - @started = false end + private :do_finish # # message send @@ -623,4 +634,3 @@ module Net # :nodoc: SMTPSession = SMTP end # module Net - -- cgit v1.2.3