pthreadpool: maintain a list of job_states on each pthreadpool_tevent_glue
authorStefan Metzmacher <metze@samba.org>
Fri, 22 Jun 2018 15:14:31 +0000 (17:14 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 24 Jul 2018 15:38:27 +0000 (17:38 +0200)
commitaa9b64eccfd037941512bad108c4e3946714a502
treedb5eb943dbd1bd040e84f9716987b1675c0fe54d
parent9b73fda926eb8493e80012794483039be66d4e6c
pthreadpool: maintain a list of job_states on each pthreadpool_tevent_glue

We should avoid traversing a linked list within a thread without holding
a mutex!

Using a mutex would be very tricky as we'll likely deadlock with
the mutexes at the raw pthreadpool layer.

So we use somekind of spinlock using atomic_thread_fence in order to
protect the access to job->state->glue->{tctx,ev} in
pthreadpool_tevent_job_signal().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/pthreadpool/pthreadpool_tevent.c