About pthreadpool_tevent

Volker Lendecke vl at samba.org
Sun Feb 5 08:59:04 UTC 2017


On Fri, Feb 03, 2017 at 04:47:02PM -0800, Matthieu Patou wrote:
> If the structure is shared across threads is the API taking care of
> locking/unlocking access to the memory ?
> Quick glance seems to indicate that it's not but I wanted to confirm
> this, or maybe you highly recommend to use non shared memory to avoid
> issues.

The idea is that by calling pthreadpool_tevent_job_send, ownership of
"fn" and "private_data" is taken out of the main thread's control into
the thread's control. Ownership has returned to once the tevent_req
callback is called from the pthreadpool engine.

I would like to point out that when using pthreadpool_tevent, I take a
lot of effort to put as much has possible into the main thread. If you
look at vfs_pread_do, all it does beyond pure bookkeeping is the pread
call as such. Everything else is done outside of the job. I'd like to
keep it that way. Just do the pure getaddrinfo call in the thread, all
setup of arguments and analysis of results should be done in the main
thread.

Volker



More information about the samba-technical mailing list