Skip to content

Commit

Permalink
Final clean up of rescues from thread experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Saxby committed Feb 19, 2011
1 parent 17c3798 commit 6ac16bc
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions lib/fake_ftp/server.rb
Expand Up @@ -11,9 +11,7 @@ class Server

def initialize(port = 21)
self.port = port
if self.is_running?
raise "Port in use: #{port}"
end
raise("Port in use: #{port}") if self.is_running?
@connection = nil
self.directory = "#{Rails.root}/tmp/ftp" rescue '/tmp'
end
Expand All @@ -22,14 +20,12 @@ def start
@started = true
@server = ::TCPServer.new('127.0.0.1', port)
@thread = Thread.new do
begin
while @started
@client = @server.accept
respond_with('200 Can has FTP?')
@connection = Thread.new(@client) do |socket|
while !socket.nil? && !socket.closed?
parse(socket.gets)
end
while @started
@client = @server.accept
respond_with('200 Can has FTP?')
@connection = Thread.new(@client) do |socket|
while !socket.nil? && !socket.closed?
parse(socket.gets)
end
end
end
Expand Down

0 comments on commit 6ac16bc

Please sign in to comment.