From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pete Zaitcev Subject: Re: [Patch 1/1] tabled: Add replication daemon Date: Fri, 4 Dec 2009 14:30:42 -0700 Message-ID: <20091204143042.634b3ac0@redhat.com> References: <20091126193923.088ff34c@redhat.com> <4B174FD7.5090603@garzik.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4B174FD7.5090603@garzik.org> Sender: hail-devel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Jeff Garzik Cc: Project Hail List On Thu, 03 Dec 2009 00:42:47 -0500 Jeff Garzik wrote: > On 11/26/2009 09:39 PM, Pete Zaitcev wrote: > It seems to me you should > > a) leave current main-thread libevent code unchanged > > b) call event_base_new() for the new thread, passing that newly-created > event_base to replica thread events using event_base_set(). Isn't it exactly what I do right now? > event_reinit() seems more appropriate for forks than threads. tabled's > needs are simple -- you simply need to create an additional event_base > for the new thread. It wasn't obvious from the description and anyway, what's the harm? I thought it reopens some /dev/epoll or whatever may be necessary in the OS. > > + /* Statics are a silly way to pass arguments to threads, but oh well. */ > > + evbase = ev_base; > > + > > + scan_thread = g_thread_create(rep_thread_func, NULL, FALSE, &error); > > The second argument to g_thread_create() is a user-provided data > pointer, passed directly to the newly created thread. No need for a > static, AFAICS. Ignoring the comment for now, the problem is that evbase is needed in the "system context" of a thread, for things like passing it down to stor_open(). That's the main reason why it's static. Threads in Glib have something called "static private", which kinda-sorta works like what we need, but it's a pain. I guess I can try to use it... -- Pete