lib/rmpd/connection.rb in rmpd-1.1.13 vs lib/rmpd/connection.rb in rmpd-1.1.15
- old
+ new
@@ -74,23 +74,29 @@
end
def send_command(command, *args)
tries = 0
- connect
- @socket_mu.lock
begin
- @socket.puts("#{command} #{quote(args).join(" ")}".strip)
+ connect
+ send_command_without_reconnect(command, *args)
rescue Errno::EPIPE, EOFError
- @socket.close
if (tries += 1) < MAX_RETRIES
retry
else
raise MpdError.new("Retry count exceeded")
end
- ensure
- @socket_mu.unlock
end
+ end
+
+ def send_command_without_reconnect(command, *args)
+ @socket_mu.lock
+ @socket.puts("#{command} #{quote(args).join(" ")}".strip)
+ rescue => e
+ @socket.close
+ raise e
+ ensure
+ @socket_mu.unlock
end
def read_response
response = []