tevent in multithreaded programs

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Jan 30 13:19:03 MST 2015


On Fri, Jan 30, 2015 at 03:02:53PM -0500, Jeff Layton wrote:
> That's basically what Simo said too on IRC. His suggestion was:
> 
> - create a pipe, a list and a lock
> - dispatch the accept to a workqueue thread
> - once the accept is done, acquire the lock and add the new fd to the list
> - drop the lock and then write to the pipe
> - pipe event handler reads and discards all of the pipe data then
>   acquires the lock and adds all of the fds on the list to the tevent
>   context
> 
> ...I think that sounds pretty reasonable, and it's a lot simpler than
> locking across multiple threads. It also means that we can use
> tevent_wait too and avoid any locking in the event loop unless
> we're pulling entries off the list.

Can you give me a hint why you want to dispatch the accept?
Do you have to do significant work between the accept(2)
call and handing it back to the main loop?

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list