Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

server/dispatcher: improve a bit sending and disconnect

  • Loading branch information...
commit 25e254027955a2e63bffc17df24612715f7590e9 1 parent 1cf2670
@meh authored
View
2  lib/failirc/server.rb
@@ -36,7 +36,7 @@ class Server
attr_reader :options, :dispatcher, :created_on
- def_delegators :@dispatcher, :listen
+ def_delegators :@dispatcher, :listen, :running?
def_delegators :@events, :register, :dispatch, :observe, :fire, :hook
def_delegators :@workers, :do
def_delegators :@modules, :load
View
6 lib/failirc/server/dispatcher.rb
@@ -58,8 +58,12 @@ def stop
wakeup
end
+ def running?
+ @running
+ end
+
def loop
- while @running
+ while running?
self.do
end
end
View
14 lib/failirc/server/dispatcher/client.rb
@@ -79,8 +79,9 @@ def receive
def send (message)
dispatcher.server.dispatch :output, self, message
-
@output.push(message)
+
+ flush
end
def flush
@@ -121,8 +122,6 @@ def handle
server.do {
begin
server.dispatch :input, self, @input.pop
-
- flush
rescue Exception => e
IRC.debug e
end
@@ -143,12 +142,13 @@ def disconnect (message, options={})
connected_to.clients.delete(self)
dispatcher.wakeup reset: true
- @told = true
-
- unless disconnected?
+ begin
flush
- @socket.close
+ rescue; ensure
+ @socket.close rescue nil
end
+
+ @told = true
end
def disconnected?
View
8 lib/failirc/server/modules/base.rb
@@ -46,6 +46,8 @@
@servers = {}
Thread.new {
+ begin
+
while server.running?
@mutex.synchronize {
# time to ping non active users
@@ -59,7 +61,7 @@
# clear and refill the hash of clients to ping with all the connected clients
@to_ping.clear
- @to_ping.insert(-1, server.dispatcher.clients)
+ @to_ping.insert(-1, *server.dispatcher.clients)
}
sleep((options[:misc]['ping timeout'].to_f rescue 60))
@@ -73,6 +75,10 @@
@pinged_out.clear
}
end
+
+ rescue Exception => e
+ IRC.debug e
+ end
}
end
Please sign in to comment.
Something went wrong with that request. Please try again.