]> git.ipfire.org Git - thirdparty/bird.git/commit
Coroutine: use pthread_exit() instead of pthread_cancel()
authorJan Maria Matejka <mq@ucw.cz>
Wed, 5 Sep 2018 12:29:54 +0000 (14:29 +0200)
committerJan Maria Matejka <mq@ucw.cz>
Thu, 13 Sep 2018 09:10:27 +0000 (11:10 +0200)
commit2312622923d98cda9ec397815932d4658b3e79e1
tree761ea950151b0bbe7b406459da7d204087f035e2
parent4600e95fe46fd22c8f5e191f982783f85254942e
Coroutine: use pthread_exit() instead of pthread_cancel()

The coroutine itself may hold some resources when going across pthread
cancellable points. Now it is ensured (by semaphores) that either the
main process or the coroutine is running so the coroutine is always
cancelled inside coro_suspend() where everything is clean but it will
change in future.

Instead, we explicitly mark the coroutine freeze/cancel points by
yielding there -- calling coro_suspend() and checking whether the
master process has requested to stop.

Where pthread_cancel() was, we instead set a flag and resume that
thread to finish its work and exit itself.
lib/coroutine.h
sysdep/unix/coroutine.c