[/musicextras/musicextras: changeset 19 Zachary P. Landau **20040928012557 Added support for connection-down detection. Also fixed --clear-* options from quitting too early. ] { hunk ./lib/musicextras/dataaccessor.rb 172 - + hunk ./lib/musicextras/dataaccessor.rb 174 + hunk ./lib/musicextras/dataaccessor.rb 176 - tmp_data = a.run(self) - mutex.synchronize do - if ( (data == NO_DATA) && (tmp_data) ) - data = tmp_data + begin + Thread.current[:connection_error] = nil + tmp_data = a.run(self) + mutex.synchronize do + if ( (data == NO_DATA) && (tmp_data) ) + data = tmp_data + end hunk ./lib/musicextras/dataaccessor.rb 184 + rescue SocketError => e + Thread.current[:connection_error] = e hunk ./lib/musicextras/dataaccessor.rb 188 + hunk ./lib/musicextras/dataaccessor.rb 194 + hunk ./lib/musicextras/dataaccessor.rb 196 + + error = false hunk ./lib/musicextras/dataaccessor.rb 206 + # See if they all got connection errors + error = true + threads.each { |t| error = false if t[:connection_error] == nil } + if error + raise threads[0][:connection_error] + end hunk ./lib/musicextras/musicsite.rb 246 + rescue SocketError => error + if error.message =~ /^getaddrinfo/ + raise + end hunk ./lib/musicextras/pusher.rb 90 + + if @options.quit_after_parse == true + exit 0 + end hunk ./lib/musicextras/pusher.rb 109 - xml_header() - retrieve_data() - xml_footer() + begin + xml_header() + retrieve_data() + xml_footer() + rescue => e + STDERR.puts "Connection error on all attempts: #{e.message}" + exit 6 + end + hunk ./lib/musicextras/pusher.rb 150 + @options.quit_after_parse = false hunk ./lib/musicextras/pusher.rb 243 + puts "Clearing greylist..." hunk ./lib/musicextras/pusher.rb 246 + @options.quit_after_parse = true hunk ./lib/musicextras/pusher.rb 249 + puts "Clearing cache..." hunk ./lib/musicextras/pusher.rb 252 + @options.quit_after_parse = true hunk ./lib/musicextras/pusher.rb 255 + puts "Clearing webcache..." hunk ./lib/musicextras/pusher.rb 258 - exit 0 + @options.quit_after_parse = true hunk ./lib/musicextras/pusher.rb 260 - }