tevent in multithreaded programs
Jeff Layton
jlayton at samba.org
Fri Jan 30 10:30:27 MST 2015
Hi All!
I'm looking at using tevent in a multithreaded program, primarily to
handle socket descriptors. The basic idea is to have a tevent_wait loop
running in one thread that will handle events by dispatching them to a
workqueue (queue of jobs and a pile of threads to handle them).
So basically we'll open a listener socket, and set it up to be watched
by tevent and run that in one thread. When a connect request comes in,
I want to dispatch the accept to a workqueue, which will then add the
accept()ed fd to the event context.
Questions:
- is this legit? Can I add events in one thread while the event loop is
running in another?
- if so, do I need to serialize that somehow (with pthread mutexes or
something)? I assume so, since tevent is based on talloc and you need
to synchronize between threads when dealing with talloc contexts...
TIA!
--
Jeff Layton <jlayton at samba.org>
More information about the samba-technical
mailing list