mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* ext/-test-/popen_deadlock/infinite_loop_dlsym.c: new ext to call dlsym(3) infinitely without GVL, used in the above test. * ext/-test-/popen_deadlock/extconf.rb: extconf.rb for the above ext. Currently, only enabled on Solaris (main target) and Linux (as a reference platform and for debugging the ext). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
		
			
				
	
	
		
			50 lines
		
	
	
	
		
			829 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
	
		
			829 B
		
	
	
	
		
			C
		
	
	
	
	
	
#include "ruby/ruby.h"
 | 
						|
#include "ruby/thread.h"
 | 
						|
#include <dlfcn.h>
 | 
						|
 | 
						|
struct data_for_loop_dlsym {
 | 
						|
    const char *name;
 | 
						|
    volatile int stop;
 | 
						|
};
 | 
						|
 | 
						|
static void*
 | 
						|
native_loop_dlsym(void *data)
 | 
						|
{
 | 
						|
    struct data_for_loop_dlsym *s = data;
 | 
						|
 | 
						|
    while (!(s->stop)) {
 | 
						|
        dlsym(RTLD_DEFAULT, s->name);
 | 
						|
    }
 | 
						|
 | 
						|
    return NULL;
 | 
						|
}
 | 
						|
 | 
						|
static void
 | 
						|
ubf_for_loop_dlsym(void *data)
 | 
						|
{
 | 
						|
    struct data_for_loop_dlsym *s = data;
 | 
						|
 | 
						|
    s->stop = 1;
 | 
						|
 | 
						|
    return;
 | 
						|
}
 | 
						|
 | 
						|
static VALUE
 | 
						|
loop_dlsym(VALUE self, VALUE name)
 | 
						|
{
 | 
						|
    struct data_for_loop_dlsym d;
 | 
						|
 | 
						|
    d.stop = 0;
 | 
						|
    d.name = StringValuePtr(name);
 | 
						|
 | 
						|
    rb_thread_call_without_gvl(native_loop_dlsym, &d,
 | 
						|
                               ubf_for_loop_dlsym, &d);
 | 
						|
 | 
						|
    return self;
 | 
						|
}
 | 
						|
 | 
						|
void
 | 
						|
Init_infinite_loop_dlsym(void)
 | 
						|
{
 | 
						|
    rb_define_method(rb_cThread, "__infinite_loop_dlsym__", loop_dlsym, 1);
 | 
						|
}
 |