| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Revactor
Revision: 130
Author: tarcieri
Date: 27 May 2008 19:59:45
Changes:Fix unclosed sockets when connections timeout
Files:| ... | ...@@ -141,11 +141,11 @@ | |
| 141 | 141 | def _spawn(*args, &block) |
| 142 | 142 | fiber = Fiber.new do |
| 143 | 143 | block.call(*args) |
| 144 | current.instance_eval { @dead = true } | |
| 144 | current.instance_variable_set :@dead, true | |
| 145 | 145 | end |
| 146 | 146 | |
| 147 | 147 | actor = new(fiber) |
| 148 | fiber.instance_eval { @_actor = actor } | |
| 148 | fiber.instance_variable_set :@_actor, actor | |
| 149 | 149 | end |
| 150 | 150 | end |
| 151 | 151 |
| ... | ...@@ -27,7 +27,7 @@ | |
| 27 | 27 | class << self |
| 28 | 28 | def connect(host, port = 80) |
| 29 | 29 | client = super |
| 30 | client.instance_eval { @receiver = Actor.current } | |
| 30 | client.instance_variable_set :@receiver, Actor.current | |
| 31 | 31 | client.attach Rev::Loop.default |
| 32 | 32 | |
| 33 | 33 | Actor.receive do |filter| |
| ... | ...@@ -45,6 +45,7 @@ | |
| 45 | 45 | end |
| 46 | 46 | |
| 47 | 47 | filter.after(TCP::CONNECT_TIMEOUT) do |
| 48 | client.close unless client.closed? | |
| 48 | 49 | raise TCP::ConnectError, "connection timed out" |
| 49 | 50 | end |
| 50 | 51 | end |
| ... | ...@@ -58,7 +58,7 @@ | |
| 58 | 58 | handle_exit(actor) if actor.dead? |
| 59 | 59 | rescue FiberError |
| 60 | 60 | # Handle Actors whose Fibers died after being scheduled |
| 61 | actor.instance_eval { @dead = true } | |
| 61 | actor.instance_variable_set :@dead, true | |
| 62 | 62 | handle_exit(actor) |
| 63 | 63 | rescue => ex |
| 64 | 64 | handle_exit(actor, ex) |