]> git.ipfire.org Git - thirdparty/asterisk.git/commit
sched: fix and test a double deref on delete of an executing call back
authorMike Bradeen <mbradeen@sangoma.com>
Wed, 8 Dec 2021 21:14:48 +0000 (14:14 -0700)
committerMichael Bradeen <mbradeen@sangoma.com>
Fri, 21 Jan 2022 16:05:48 +0000 (10:05 -0600)
commitac8988c9a3976000cf5236bece7d8b746c2f0e08
treee22c254b14521365429b34168c44d12296e58a25
parent6e8bbe4b3a95c9c2df776b174858f974983acda1
sched: fix and test a double deref on delete of an executing call back

sched: Avoid a double deref when AST_SCHED_DEL_UNREF is called on an
executing call-back. This is done by adding a new variable 'rescheduled'
to the struct sched which is set in ast_sched_runq and checked in
ast_sched_del_nonrunning. ast_sched_del_nonrunning is a replacement for
now deprecated ast_sched_del which returns a new possible value -2
if called on an executing call-back with rescheduled set. ast_sched_del
is modified to call ast_sched_del_nonrunning to maintain existing code.
AST_SCHED_DEL_UNREF is also updated to look for the -2 in which case it
will not throw a warning or invoke refcall.
test_sched: Add a new unit test sched_test_freebird that will check the
reference count in the resolved scenario.

ASTERISK-29698

Change-Id: Icfb16b3acbc29cf5b4cef74183f7531caaefe21d
include/asterisk/sched.h
main/sched.c
tests/test_sched.c