Destroy reference to taskmgr after all tasks are done

We were clearing the pointer to taskmgr as soon as isc_taskmgr_destroy()
would be called and before all tasks were finished.  Unfortunately, some
tasks would use global named_g_taskmgr objects from inside the events
and this would cause either a data race or NULL pointer dereference.

This commit fixes the data race by moving the destruction of the
referenced pointer to the time after all tasks are finished.
70 jobs for !5008 with ondrej/dereference-taskmgr-after-all-tasks-are-done in 10 minutes and 53 seconds (queued for 14 seconds)
latest detached
Status Job ID Name Coverage
  Autoconf
passed #1705692
amd64 linux
autoreconf

00:00:17

 
  Precheck
passed #1705694
amd64 linux
clang-format

00:00:17

passed #1705695
amd64 linux
coccinelle

00:04:13

passed #1705696
amd64 linux
danger

00:00:14

passed #1705693
amd64 linux
misc

00:00:22

passed #1705697
amd64 linux
tarball-create

00:01:30

 
  Build
passed #1705708
amd64 linux
clang:asan

00:02:03

passed #1705712
amd64 linux
clang:buster:amd64

00:01:06

passed #1705715
amd64 libvirt
clang:freebsd11:amd64

00:01:16

passed #1705716
amd64 libvirt
clang:freebsd12:amd64

00:01:17

passed #1705717
amd64 libvirt
clang:openbsd:amd64

00:02:28

passed #1705710
amd64 linux
clang:tsan

00:01:12

passed #1705698
amd64 linux
gcc:alpine3.13:amd64

00:01:00

passed #1705707
amd64 linux
gcc:asan

00:01:36

passed #1705702
amd64 linux
gcc:buster:amd64

00:00:42

passed #1705699
amd64 linux
gcc:centos7:amd64

00:00:58

passed #1705700
amd64 linux
gcc:centos8:amd64

00:01:00

passed #1705706
amd64 linux
gcc:focal:amd64

00:00:55

passed #1705711
amd64 linux
gcc:mutexatomics

00:00:46

passed #1705704
amd64 linux
gcc:out-of-tree

00:01:03

passed #1705703
amd64 linux
gcc:sid:amd64

00:01:09

passed #1705713
amd64 linux
gcc:softhsm2.4

00:00:48

passed #1705714
amd64 linux
gcc:softhsm2.6

00:01:00

passed #1705701
amd64 linux
gcc:stretch:amd64

00:01:00

passed #1705709
amd64 linux
gcc:tsan

00:01:08

passed #1705705
amd64 linux
gcc:tumbleweed:amd64

00:01:00

passed #1705718
amd64 windows
msvc:windows:amd64

00:00:54

 
  Unit
passed #1705728
amd64 linux
unit:clang:asan

00:02:10

passed #1705732
amd64 linux
unit:clang:buster:amd64

00:01:25

passed #1705735
amd64 libvirt
unit:clang:freebsd11:amd64

00:01:55

passed #1705736
amd64 libvirt
unit:clang:freebsd12:amd64

00:01:50

passed #1705737
amd64 libvirt
unit:clang:openbsd:amd64

00:03:47

passed #1705730
amd64 linux
unit:clang:tsan

00:03:54

passed #1705719
amd64 linux
unit:gcc:alpine3.13:amd64

00:01:30

passed #1705727
amd64 linux
unit:gcc:asan

00:01:50

passed #1705723
amd64 linux
unit:gcc:buster:amd64

00:02:23

passed #1705720
amd64 linux
unit:gcc:centos7:amd64

00:01:27

passed #1705721
amd64 linux
unit:gcc:centos8:amd64

00:01:22

passed #1705726
amd64 linux
unit:gcc:focal:amd64

00:01:26

passed #1705731
amd64 linux
unit:gcc:mutexatomics

00:01:28

passed #1705724
amd64 linux
unit:gcc:sid:amd64

00:01:24

passed #1705733
amd64 linux
unit:gcc:softhsm2.4

00:01:22

passed #1705734
amd64 linux
unit:gcc:softhsm2.6

00:01:24

passed #1705722
amd64 linux
unit:gcc:stretch:amd64

00:00:13

passed #1705729
amd64 linux
unit:gcc:tsan

00:04:37

passed #1705725
amd64 linux
unit:gcc:tumbleweed:amd64

00:01:19

 
  System
canceled #1705747
amd64 linux
system:clang:asan

00:08:18

canceled #1705751
amd64 linux
system:clang:buster:amd64

00:09:18

canceled #1705754
amd64 libvirt
system:clang:freebsd11:amd64

00:09:13

canceled #1705755
amd64 libvirt
system:clang:freebsd12:amd64

00:09:11

canceled #1705749
amd64 linux
system:clang:tsan

00:09:07

canceled #1705738
amd64 linux
system:gcc:alpine3.13:amd64

00:09:25

canceled #1705746
amd64 linux
system:gcc:asan

00:08:48

canceled #1705742
amd64 linux
system:gcc:buster:amd64

00:07:21

canceled #1705739
amd64 linux
system:gcc:centos7:amd64

00:09:28

canceled #1705740
amd64 linux
system:gcc:centos8:amd64

00:09:25

canceled #1705745
amd64 linux
system:gcc:focal:amd64

00:09:28

canceled #1705750
amd64 linux
system:gcc:mutexatomics

00:09:34

canceled #1705743
amd64 linux
system:gcc:sid:amd64

00:09:18

canceled #1705752
amd64 linux
system:gcc:softhsm2.4

00:09:43

canceled #1705753
amd64 linux
system:gcc:softhsm2.6

00:09:31

canceled #1705741
amd64 linux
system:gcc:stretch:amd64

00:09:25

canceled #1705748
amd64 linux
system:gcc:tsan

00:09:13

canceled #1705744
amd64 linux
system:gcc:tumbleweed:amd64

00:09:21

 
  Docs
passed #1705756
amd64 linux
docs

00:00:49

 
  Postcheck
passed #1705760
amd64 linux
cppcheck

00:00:47

passed #1705757
amd64 linux
flake8

00:00:21

canceled #1705761
amd64 linux
gcov

passed #1705758
amd64 linux
pylint

00:00:29

passed #1705759
amd64 linux
scan-build

00:04:22