pthreadpool: Undo put_job when returning error
authorChristof Schmitt <cs@samba.org>
Tue, 28 Nov 2017 17:59:06 +0000 (10:59 -0700)
committerChristof Schmitt <cs@samba.org>
Fri, 8 Dec 2017 08:43:12 +0000 (09:43 +0100)
commit065fb5d94d25d19fc85832bb85aa9e379e8551cc
tree64877730677840b247047d6489b4564ac1212d27
parent949ccc3ea9073a3d38bff28345f644d39177256f
pthreadpool: Undo put_job when returning error

When an error is returned to the caller of pthreadpool_add_job, the job
should not be kept in the internal job array. Otherwise the caller might
free the data structure and a later worker thread would still reference
it.

When it is not possible to create a single worker thread, the system
might be out of resources or hitting a configured limit. In this case
fall back to calling the job function synchronously instead of raising
the error to the caller and possibly back to the SMB client.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13170

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
lib/pthreadpool/pthreadpool.c