Resolve TSAN data race in zone_maintenance

Fix race between zone_maintenance and dns_zone_notifyreceive functions,
zone_maintenance was attempting to read a zone flag calling
DNS_ZONE_FLAG(zone, flag) while dns_zone_notifyreceive was updating
a flag in the same zone calling DNS_ZONE_SETFLAG(zone, ...).

The code reading the flag in zone_maintenance was not protected by the
zone's lock, to avoid a race the zone's lock is now being acquired
before an attempt to read the zone flag is made.
77 jobs for !4866 with 2582-threadsanitizer-data-race-lib-dns-zone-c-10272-7-in-zone_maintenance-v9_16 in 2 minutes and 16 seconds (queued for 8 seconds)
latest detached
Status Job ID Name Coverage
  Precheck
passed #1623396
linux amd64
autoreconf

00:00:16

passed #1623398
linux amd64
clang-format

00:00:25

canceled #1623399
linux amd64
coccinelle

00:02:11

passed #1623400
linux amd64
danger

00:00:16

passed #1623397
linux amd64
misc

00:00:15

 
  Build
canceled #1623413
linux amd64
clang:asan

canceled #1623417
linux amd64
clang:buster:amd64

00:01:43

canceled #1623420
amd64 libvirt
clang:freebsd11:amd64

00:01:49

canceled #1623421
amd64 libvirt
clang:freebsd12:amd64

00:00:31

canceled #1623422
amd64 libvirt
clang:openbsd:amd64

00:00:21

canceled #1623415
linux amd64
clang:tsan

canceled #1623401
linux amd64
gcc:alpine3.13:amd64

canceled #1623412
linux amd64
gcc:asan

passed #1623405
linux amd64
gcc:buster:amd64

00:01:37

passed #1623402
linux amd64
gcc:centos7:amd64

00:01:20

passed #1623403
linux amd64
gcc:centos8:amd64

00:01:43

canceled #1623411
linux amd64
gcc:focal:amd64

passed #1623416
linux amd64
gcc:mutexatomics

00:01:42

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

00:01:34

canceled #1623406
linux amd64
gcc:sid:amd64

00:01:44

canceled #1623408
linux i386
gcc:sid:i386

00:01:43

canceled #1623418
linux amd64
gcc:softhsm2.4

canceled #1623419
linux amd64
gcc:softhsm2.6

canceled #1623404
linux amd64
gcc:stretch:amd64

00:01:44

canceled #1623414
linux amd64
gcc:tsan

passed #1623409
linux amd64
gcc:tumbleweed:amd64

00:01:40

canceled #1623410
linux amd64
gcc:xenial:amd64

passed #1623424
amd64 windows
msvc:windows:amd64

00:00:59

canceled #1623423
linux amd64
nolibtool:sid:amd64

 
  Unit
canceled #1623436
linux amd64
unit:clang:asan

canceled #1623440
linux amd64
unit:clang:buster:amd64

canceled #1623443
amd64 libvirt
unit:clang:freebsd11:amd64

canceled #1623444
amd64 libvirt
unit:clang:freebsd12:amd64

canceled #1623438
linux amd64
unit:clang:tsan

canceled #1623425
linux amd64
unit:gcc:alpine3.13:amd64

canceled #1623435
linux amd64
unit:gcc:asan

canceled #1623429
linux amd64
unit:gcc:buster:amd64

canceled #1623426
linux amd64
unit:gcc:centos7:amd64

canceled #1623427
linux amd64
unit:gcc:centos8:amd64

canceled #1623434
linux amd64
unit:gcc:focal:amd64

canceled #1623439
linux amd64
unit:gcc:mutexatomics

canceled #1623430
linux amd64
unit:gcc:sid:amd64

canceled #1623431
linux i386
unit:gcc:sid:i386

canceled #1623441
linux amd64
unit:gcc:softhsm2.4

canceled #1623442
linux amd64
unit:gcc:softhsm2.6

canceled #1623428
linux amd64
unit:gcc:stretch:amd64

canceled #1623437
linux amd64
unit:gcc:tsan

canceled #1623432
linux amd64
unit:gcc:tumbleweed:amd64

canceled #1623433
linux amd64
unit:gcc:xenial:amd64

canceled #1623445
linux amd64
unit:nolibtool:sid:amd64

 
  System
canceled #1623457
linux amd64
system:clang:asan

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

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

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

canceled #1623459
linux amd64
system:clang:tsan

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

canceled #1623456
linux amd64
system:gcc:asan

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

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

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

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

canceled #1623460
linux amd64
system:gcc:mutexatomics

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

canceled #1623452
linux i386
system:gcc:sid:i386

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

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

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

canceled #1623458
linux amd64
system:gcc:tsan

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

canceled #1623454
linux amd64
system:gcc:xenial:amd64

canceled #1623466
linux amd64
system:nolibtool:sid:amd64

 
  Docs
canceled #1623467
linux amd64
docs

 
  Postcheck
canceled #1623471
linux amd64
cppcheck

canceled #1623468
linux amd64
flake8

canceled #1623472
linux amd64
gcov

canceled #1623469
linux amd64
pylint

canceled #1623470
linux amd64
scan-build