diff --git a/spec/ruby/library/socket/fixtures/classes.rb b/spec/ruby/library/socket/fixtures/classes.rb index 4a590502ca1..dc4cadf02f8 100644 --- a/spec/ruby/library/socket/fixtures/classes.rb +++ b/spec/ruby/library/socket/fixtures/classes.rb @@ -118,14 +118,14 @@ def service(socket) socket.send data, 0 ensure - socket.close + socket.close unless socket.closed? end end def shutdown log "SpecTCPServer shutting down" + @server.close unless @server.closed? @thread.join - @server.close end def log(message) diff --git a/spec/ruby/library/socket/udpsocket/send_spec.rb b/spec/ruby/library/socket/udpsocket/send_spec.rb index 5d5de684afb..f1196378ade 100644 --- a/spec/ruby/library/socket/udpsocket/send_spec.rb +++ b/spec/ruby/library/socket/udpsocket/send_spec.rb @@ -16,13 +16,14 @@ retry end ensure - @server.close if !@server.closed? + @server.close unless @server.closed? end end Thread.pass while @server_thread.status and !@port end after :each do + @server.close unless @server.closed @server_thread.join end