summaryrefslogtreecommitdiff
path: root/lib/net
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-21 23:05:41 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-21 23:05:41 +0000
commitf845a9ef76c0195254ded79c85c24332534f4057 (patch)
tree015ae2e6909fd287ac1b3b18e0675196e181fb0d /lib/net
parent8e4c8e96429e939f6b527919b276f6cd97380ebc (diff)
lib/*: remove closed checks
Follow r56795. Since Ruby 2.2, calling #close on a closed socket no longer raises exceptions. * lib/cgi/session.rb (update): remove closed? check * lib/net/http.rb (finish, transport_request): ditto * lib/net/imap.rb (disconnect): ditto * lib/net/pop.rb (do_start, do_finish): ditto * lib/net/smtp.rb (do_start, do_finish): ditto * lib/open3.rb (popen_run, pipeline_run): ditto * lib/pstore.rb (transaction): ditto * lib/shell/process-controller.rb (sfork): * lib/tempfile (_close, call, Tempfile.create): ditto * lib/webrick/httpauth/htdigest.rb (flush): ditto * lib/webrick/httpauth/htpasswd.rb (flush): ditto * lib/webrick/server.rb (start_thread, cleanup_shutdown_pipe): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/http.rb8
-rw-r--r--lib/net/imap.rb4
-rw-r--r--lib/net/pop.rb4
-rw-r--r--lib/net/smtp.rb4
4 files changed, 9 insertions, 11 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 71d3d0aced..5a22fc0015 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -978,7 +978,7 @@ module Net #:nodoc:
def do_finish
@started = false
- @socket.close if @socket and not @socket.closed?
+ @socket.close if @socket
@socket = nil
end
private :do_finish
@@ -1463,12 +1463,12 @@ module Net #:nodoc:
Timeout::Error => exception
if count == 0 && IDEMPOTENT_METHODS_.include?(req.method)
count += 1
- @socket.close if @socket and not @socket.closed?
+ @socket.close if @socket
D "Conn close because of error #{exception}, and retry"
retry
end
D "Conn close because of error #{exception}"
- @socket.close if @socket and not @socket.closed?
+ @socket.close if @socket
raise
end
@@ -1476,7 +1476,7 @@ module Net #:nodoc:
res
rescue => exception
D "Conn close because of error #{exception}"
- @socket.close if @socket and not @socket.closed?
+ @socket.close if @socket
raise exception
end
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 9895ed68ce..7a4d4da301 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -329,9 +329,7 @@ module Net
end
@receiver_thread.join
synchronize do
- unless @sock.closed?
- @sock.close
- end
+ @sock.close
end
raise e if e
end
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index 4a2dca2311..95d07652b6 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -570,7 +570,7 @@ module Net
ensure
# Authentication failed, clean up connection.
unless @started
- s.close if s and not s.closed?
+ s.close if s
@socket = nil
@command = nil
end
@@ -601,7 +601,7 @@ module Net
ensure
@started = false
@command = nil
- @socket.close if @socket and not @socket.closed?
+ @socket.close if @socket
@socket = nil
end
private :do_finish
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 359a0f9710..1302f3aa1d 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -567,7 +567,7 @@ module Net
ensure
unless @started
# authentication failed, cancel connection.
- s.close if s and not s.closed?
+ s.close if s
@socket = nil
end
end
@@ -613,7 +613,7 @@ module Net
ensure
@started = false
@error_occurred = false
- @socket.close if @socket and not @socket.closed?
+ @socket.close if @socket
@socket = nil
end