From nobody at rubyforge.org Thu Nov 15 04:47:57 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Thu, 15 Nov 2007 04:47:57 -0500 (EST) Subject: [Muby-submits] [258] trunk/lib/muby: made the connection connect in a non blocking manner. Message-ID: <20071115094757.CF876185856A@rubyforge.org> Revision: 258 Author: zond Date: 2007-11-15 04:47:57 -0500 (Thu, 15 Nov 2007) Log Message: ----------- made the connection connect in a non blocking manner. made this happen in a thread that rescues and displays exceptions. added a connect timeout conf var. added it to the help system. Modified Paths: -------------- trunk/lib/muby/configuration.rb trunk/lib/muby/connection.rb trunk/lib/muby/help.rb trunk/lib/muby/user_methods.rb Modified: trunk/lib/muby/configuration.rb =================================================================== --- trunk/lib/muby/configuration.rb 2007-10-22 20:19:39 UTC (rev 257) +++ trunk/lib/muby/configuration.rb 2007-11-15 09:47:57 UTC (rev 258) @@ -165,6 +165,8 @@ # miscellaneous options # # + @connect_timeout = 10 + @feed_completer_with_history = true @feed_completer_with_input = true Modified: trunk/lib/muby/connection.rb =================================================================== --- trunk/lib/muby/connection.rb 2007-10-22 20:19:39 UTC (rev 257) +++ trunk/lib/muby/connection.rb 2007-11-15 09:47:57 UTC (rev 258) @@ -19,7 +19,7 @@ status("Connecting to " + host.inspect + ":" + port.inspect) @host = host @port = port - @socket = TCPSocket.open(host, port) if host && port + connect! conf.connect_triggers.each do |command| @inputWindow.execute(command, @inputWindow, @outputWindow) end @@ -41,6 +41,25 @@ end # + # Almost ripped from the documentation: http://www.ruby-doc.org/core/classes/Socket.src/M002114.html + # + def connect! + @socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) + addr = Socket.sockaddr_in(@port, @host) + begin + @socket.connect_nonblock(addr) + rescue Errno::EINPROGRESS + IO.select(nil, [@socket], nil, conf.connect_timeout) + begin + @socket.connect_nonblock(addr) + rescue Errno::EISCONN + rescue Errno::EALREADY + raise "Connection timed out" + end + end + end + + # # Display a status message in the outputwindow if wanted (conf.connection_status) # def status(message) Modified: trunk/lib/muby/help.rb =================================================================== --- trunk/lib/muby/help.rb 2007-10-22 20:19:39 UTC (rev 257) +++ trunk/lib/muby/help.rb 2007-11-15 09:47:57 UTC (rev 258) @@ -3,6 +3,7 @@ module Help def self.configuration { + :connect_timeout => "The number of seconds we will try to connect before giving up.", :feed_completer_with_history => "If true, the completion command will use history to calculate possible completions.", :feed_completer_with_input => "If true, the completion command will use everything seen from the remote end to calculate possible completions.", :extra_completions => "Fill this array with words that you allways want to be able to complete to.", Modified: trunk/lib/muby/user_methods.rb =================================================================== --- trunk/lib/muby/user_methods.rb 2007-10-22 20:19:39 UTC (rev 257) +++ trunk/lib/muby/user_methods.rb 2007-11-15 09:47:57 UTC (rev 258) @@ -105,11 +105,26 @@ disconnect @last_host = host @last_port = port - @connection = Muby::Connection.new(self, Muby::OutputWindow.get_instance, host, port) + rescue_thread do + @connection = Muby::Connection.new(self, Muby::OutputWindow.get_instance, host, port) + end "Connecting" end # + # Do block in a thread that displays errors that happen. + # + def rescue_thread(&block) + Thread.new do + begin + yield + rescue Exception => e + exception(e) + end + end + end + + # # Make a fake connection for debug purposes # def fake_connect From nobody at rubyforge.org Thu Nov 15 04:48:59 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Thu, 15 Nov 2007 04:48:59 -0500 (EST) Subject: [Muby-submits] [259] trunk/lib/muby/configuration.rb: bumped the version number Message-ID: <20071115094900.E568418585BF@rubyforge.org> Revision: 259 Author: zond Date: 2007-11-15 04:48:45 -0500 (Thu, 15 Nov 2007) Log Message: ----------- bumped the version number Modified Paths: -------------- trunk/lib/muby/configuration.rb Modified: trunk/lib/muby/configuration.rb =================================================================== --- trunk/lib/muby/configuration.rb 2007-11-15 09:47:57 UTC (rev 258) +++ trunk/lib/muby/configuration.rb 2007-11-15 09:48:45 UTC (rev 259) @@ -4,7 +4,7 @@ module Muby - VERSION = "0.7.3" unless defined?(Muby::VERSION) + VERSION = "0.7.4" unless defined?(Muby::VERSION) # # The class that encapsulates all configuration. From nobody at rubyforge.org Thu Nov 15 04:49:44 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Thu, 15 Nov 2007 04:49:44 -0500 (EST) Subject: [Muby-submits] [260] tags/release_0_7_4/: made a tag for the new release Message-ID: <20071115094944.54EC51858571@rubyforge.org> Revision: 260 Author: zond Date: 2007-11-15 04:49:44 -0500 (Thu, 15 Nov 2007) Log Message: ----------- made a tag for the new release Added Paths: ----------- tags/release_0_7_4/ Copied: tags/release_0_7_4 (from rev 259, trunk)