Re: Re: [Prothon-commits] rev 149 - in trunk:include/prothon src

Ben Collins <[email protected]> Sat, 27 Mar 2004 22:40:32 -0500
Newsgroups gmane.comp.lang.prothon.devel
Message-ID <[email protected]>
> > +	if (main_argv_obj && list_len(ist, main_argv_obj)) {
> > +		new_thread_obj((apr_thread_start_t)main_thread, main_argv_obj);
> > +		/* Grab this lock, so we know main1 thread has started */
> > +		pr_lock(&thread_registry_lock); pr_unlock(&thread_registry_lock);
> >
> > +	}
> > +
> >  	threads = get_attr(ist, sys_argv_obj, sym(ist, "threads"));
> >  	if (threads) {
> >  		int i;
> >  		for (i = 0; i < list_len(ist, threads); i++)
> > -			start_new_thread((apr_thread_start_t)main_thread, list_item(ist,
> threads, i));
> > +			new_thread_obj((apr_thread_start_t)main_thread, list_item(ist,
> threads, i));
> >  	}

After you create the first new_thread_obk() for main args, you grab the
lock to make sure it completes startup. However you never release it
before calling new_thread_obj() again for the -t options. So the first
time you call new_thread_obj() for one, it will deadlock waiting for
thread_registry_lock to be released.

You should only grab that lock once you have started all the threads you
want to, and then release it.

-- 
Debian     - http://www.debian.org/
Linux 1394 - http://www.linux1394.org/
Subversion - http://subversion.tigris.org/
WatchGuard - http://www.watchguard.com/