BUG/MEDIUM: task: make tasklets either local or shared but not both at once
authorWilly Tarreau <w@1wt.eu>
Fri, 18 Oct 2019 04:43:53 +0000 (06:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Oct 2019 07:04:55 +0000 (09:04 +0200)
commit8cdc167df8c05d709a373dfddafad4c508bd5772
tree38d2cf88b0eac1ecabc62ff451798a71b818117a
parentbbb5f1d6d2a9948409683aa5865c130801d193ad
BUG/MEDIUM: task: make tasklets either local or shared but not both at once

Tasklets may be woken up to run on the calling thread or by a specific thread
(the owner). But since we use a non-thread safe mechanism when the calling
thread is also the for the owner, there may sometimes be collisions when two
threads decide to wake the same tasklet up at the same time and one of them
is the owner.

This is more of a matter of usage than code, in that a tasklet usually is
designed to be woken up and executed on the calling thread only (most cases)
or on a specific thread. Thus it is a property of the tasklet itself as this
solely depends how the code is constructed around it.

This patch performs a small change to address this. By default tasklet_new()
creates a "local" tasklet, which will run on the calling thread, like in 2.0.
This is done by setting tl->tid to a negative value. If the caller wants the
tasklet to run exclusively on a specific thread, it just has to set tl->tid,
which is already what shared tasklet callers do anyway.

No backport is needed.
include/proto/task.h
include/types/task.h