Permalink
Browse files

Fix bug in C main loop, fixed RPC issue for dead nodes, added test to…

… look

for regression of C main loop bug
  • Loading branch information...
1 parent ae6378c commit 9ab1c059bb92efc5f9894a41f00c074a66120201 Cyrus Hall committed Jun 25, 2007
Showing with 21 additions and 2 deletions.
  1. +3 −1 ext/event_queue/event_queue.c
  2. +1 −1 lib/gosim/rpc.rb
  3. +17 −0 test/simulation_test.rb
@@ -88,7 +88,8 @@ static VALUE run_main_loop(
VALUE self,
VALUE end_time)
{
- VALUE running = rb_ivar_get(self, rb_intern("@running"));
+ VALUE running_var_name = rb_intern("@running");
+ VALUE running = rb_ivar_get(self, running_var_name);
VALUE data_hash = rb_cvar_get(rb_simulation, data_hash_id);
Event *cur_event = fh_min(event_queue);
@@ -113,6 +114,7 @@ static VALUE run_main_loop(
free(cur_event);
cur_event = fh_min(event_queue);
+ running = rb_ivar_get(self, running_var_name);
}
return Qnil;
View
@@ -168,7 +168,7 @@ def handle_rpc_request(request)
end
#puts "top of request"
- if @topo.alive?(addr)
+ if @topo.alive?(@addr)
#puts "1 request...#{request.inspect}"
result = send(request.method, *request.args)
@@ -41,6 +41,15 @@ def new_item(event)
end
end
+class Stoper < GoSim::Entity
+ def initialize(time)
+ super()
+ set_timeout(time) do
+ @sim.stop
+ end
+ end
+end
+
class TimerOuter < GoSim::Entity
TIMEOUT_TIME = 10
@@ -135,4 +144,12 @@ def test_sim_run
assert_equal(3, sim_timer.timer_count)
end
+
+ # This was broken in the C version for awhile. Check for regression
+ def test_stop
+ sim_timer = Stoper.new(9)
+ timer = TimerOuter.new
+ @sim.run(300)
+ assert_equal(0, timer.timer_count)
+ end
end

0 comments on commit 9ab1c05

Please sign in to comment.