mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* backport r32597 from trunk.
* thread.c (set_trace_func, thread_set_trace_func_m): reset tracing state when set_trace_func hook is removed. This is workaround patch to force to reset tracing state that is broken by continuation call. a patch from James M. Lawrence. [Feature #4347] [ruby-core:34998] * test/ruby/test_continuation.rb (class TestContinuation): add a test for above. a patch from James M. Lawrence. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									f0353afdc1
								
							
						
					
					
						commit
						1d9cac36ea
					
				
					 3 changed files with 55 additions and 0 deletions
				
			
		
							
								
								
									
										10
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								ChangeLog
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,3 +1,13 @@
 | 
			
		|||
Thu Jul 21 20:02:11 2011  Yusuke Endoh  <mame@tsg.ne.jp>
 | 
			
		||||
 | 
			
		||||
	* thread.c (set_trace_func, thread_set_trace_func_m): reset tracing
 | 
			
		||||
	  state when set_trace_func hook is removed.  This is workaround patch
 | 
			
		||||
	  to force to reset tracing state that is broken by continuation call.
 | 
			
		||||
	  a patch from James M. Lawrence.  [Feature #4347] [ruby-core:34998]
 | 
			
		||||
 | 
			
		||||
	* test/ruby/test_continuation.rb (class TestContinuation): add a test
 | 
			
		||||
	  for above.  a patch from James M. Lawrence.
 | 
			
		||||
 | 
			
		||||
Thu Jul 21 20:59:59 2011  Tanaka Akira  <akr@fsij.org>
 | 
			
		||||
 | 
			
		||||
	* ext/socket/ancdata.c (discard_cmsg): workaround for MacOS X Lion.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,5 +77,48 @@ class TestContinuation < Test::Unit::TestCase
 | 
			
		|||
    }, '[ruby-dev:34802]'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def tracing_with_set_trace_func
 | 
			
		||||
    cont = nil
 | 
			
		||||
    func = lambda do |*args|
 | 
			
		||||
      @memo += 1
 | 
			
		||||
      cont.call(nil)
 | 
			
		||||
    end
 | 
			
		||||
    cont = callcc { |cc| cc }
 | 
			
		||||
    if cont
 | 
			
		||||
      set_trace_func(func)
 | 
			
		||||
    else
 | 
			
		||||
      set_trace_func(nil)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_tracing_with_set_trace_func
 | 
			
		||||
    @memo = 0
 | 
			
		||||
    tracing_with_set_trace_func
 | 
			
		||||
    tracing_with_set_trace_func
 | 
			
		||||
    tracing_with_set_trace_func
 | 
			
		||||
    assert_equal 3, @memo
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def tracing_with_thread_set_trace_func
 | 
			
		||||
    cont = nil
 | 
			
		||||
    func = lambda do |*args|
 | 
			
		||||
      @memo += 1
 | 
			
		||||
      cont.call(nil)
 | 
			
		||||
    end
 | 
			
		||||
    cont = callcc { |cc| cc }
 | 
			
		||||
    if cont
 | 
			
		||||
      Thread.current.set_trace_func(func)
 | 
			
		||||
    else
 | 
			
		||||
      Thread.current.set_trace_func(nil)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_tracing_with_thread_set_trace_func
 | 
			
		||||
    @memo = 0
 | 
			
		||||
    tracing_with_thread_set_trace_func
 | 
			
		||||
    tracing_with_thread_set_trace_func
 | 
			
		||||
    tracing_with_thread_set_trace_func
 | 
			
		||||
    assert_equal 3, @memo
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								thread.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								thread.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -4347,6 +4347,7 @@ set_trace_func(VALUE obj, VALUE trace)
 | 
			
		|||
    rb_remove_event_hook(call_trace_func);
 | 
			
		||||
 | 
			
		||||
    if (NIL_P(trace)) {
 | 
			
		||||
	GET_THREAD()->tracing = EVENT_RUNNING_NOTHING;
 | 
			
		||||
	return Qnil;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -4403,6 +4404,7 @@ thread_set_trace_func_m(VALUE obj, VALUE trace)
 | 
			
		|||
    rb_threadptr_remove_event_hook(th, call_trace_func);
 | 
			
		||||
 | 
			
		||||
    if (NIL_P(trace)) {
 | 
			
		||||
	th->tracing = EVENT_RUNNING_NOTHING;
 | 
			
		||||
	return Qnil;
 | 
			
		||||
    }
 | 
			
		||||
    thread_add_trace_func(th, trace);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue