Restore locking in dns_resolver_shutdown and dns_resolver_attach

Although the struct dns_resolver.exiting member is protected by stdatomics, we
actually need to wait for whole dns_resolver_shutdown() to finish before
destroying the resolver object.  Otherwise, there would be a data race and some
fctx objects might not be destroyed yet at the time we tear down the
dns_resolver object.
48 jobs for !2163 with 1149-fix-crashes-during-resolver-shutdown in 18 minutes and 3 seconds (queued for 6 seconds)
detached
Status Job ID Name Coverage
  Precheck
passed #279799
amd64 linux
🐞:sid:amd64

00:00:38

passed #279797
amd64 linux
autoreconf:sid:amd64

00:00:33

passed #279798
amd64 linux
misc:sid:amd64

00:00:19

 
  Build
passed #279810
amd64 linux
asan:sid:amd64

00:02:29

passed #279813
amd64 linux
clang:stretch:amd64

00:03:06

passed #279814
i386 linux
clang:stretch:i386

00:02:17

passed #279800
amd64 linux
docs:sid:amd64

00:00:57

passed #279809
amd64 linux
gcc:bionic:amd64

00:01:21

passed #279801
amd64 linux
gcc:centos6:amd64

00:02:56

passed #279802
amd64 linux
gcc:centos7:amd64

00:02:47

passed #279807
amd64 linux
gcc:fedora29:amd64

00:02:11

passed #279803
amd64 linux
gcc:jessie:amd64

00:01:17

passed #279805
amd64 linux
gcc:sid:amd64

00:02:46

passed #279806
i386 linux
gcc:sid:i386

00:02:15

passed #279804
amd64 linux
gcc:stretch:amd64

00:02:14

passed #279808
amd64 linux
gcc:xenial:amd64

00:01:46

passed #279812
amd64 linux
mutexatomics:sid:amd64

00:02:54

passed #279816
amd64 linux
nolibtool:sid:amd64

00:01:48

passed #279815
amd64 linux
pkcs11:sid:amd64

00:02:09

passed #279811
amd64 linux
rwlock:sid:amd64

00:02:54

 
  Test
passed #279835
amd64 linux
system:asan:sid:amd64

00:08:28

passed #279833
amd64 linux
system:gcc:bionic:amd64

00:06:36

passed #279817
amd64 linux
system:gcc:centos6:amd64

00:06:57

passed #279819
amd64 linux
system:gcc:centos7:amd64

00:07:07

passed #279829
amd64 linux
system:gcc:fedora29:amd64

00:07:27

passed #279821
amd64 linux
system:gcc:jessie:amd64

00:06:53

passed #279825
amd64 linux
system:gcc:sid:amd64

00:07:16

passed #279844
i386 linux
system:gcc:sid:i386

00:06:17

passed #279823
amd64 linux
system:gcc:stretch:amd64

00:06:28

passed #279831
amd64 linux
system:gcc:xenial:amd64

00:06:32

passed #279842
amd64 linux
system:nolibtool:sid:amd64

00:07:40

passed #279840
amd64 linux
system:pkcs11:sid:amd64

00:07:04

passed #279837
amd64 linux
system:rwlock:sid:amd64

00:07:20

passed #279836
amd64 linux
unit:asan:sid:amd64

00:01:08

passed #279839
amd64 linux
unit:clang:stretch:amd64

00:00:45

passed #279834
amd64 linux
unit:gcc:bionic:amd64

00:00:47

passed #279818
amd64 linux
unit:gcc:centos6:amd64

00:00:57

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

00:00:56

passed #279830
amd64 linux
unit:gcc:fedora29:amd64

00:01:01

passed #279822
amd64 linux
unit:gcc:jessie:amd64

00:00:29

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

00:00:46

passed #279828
i386 linux
unit:gcc:sid:i386

00:00:52

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

00:00:44

passed #279832
amd64 linux
unit:gcc:xenial:amd64

00:00:56

passed #279843
amd64 linux
unit:nolibtool:sid:amd64

00:01:08

passed #279841
amd64 linux
unit:pkcs11:sid:amd64

00:00:55

passed #279838
amd64 linux
unit:rwlock:sid:amd64

00:00:45

failed #279827
i386 linux
system:gcc:sid:i386

00:07:55