chiark / gitweb /
make _qf_owner work if _qf_search not specified, and test it (oops!)
authorian <ian>
Wed, 28 Jul 1999 23:59:31 +0000 (23:59 +0000)
committerian <ian>
Wed, 28 Jul 1999 23:59:31 +0000 (23:59 +0000)
changelog
regress/case-owner.out
regress/case-owner.sys
src/internal.h
src/query.c
src/reply.c

index 59c1e8712c8224cc148796ebbd4b2f13dc81c70e..07f437193e1e3cbc9b45f0f6d3f4966c46d47c2a 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,9 +1,10 @@
 adns (0.4) unstable; urgency=low
 
   Bugfixes:
 adns (0.4) unstable; urgency=low
 
   Bugfixes:
-  * adns_s_systemfail is in table of errors (for eg adns_strerror).
+  * make _qf_owner work if _qf_search not specified, and test it (oops!)
   * timercmp(,,<=) doesn't work - use !timercmp(,,>).
   * ads->configerrno now initialised (in setup.c).
   * timercmp(,,<=) doesn't work - use !timercmp(,,>).
   * ads->configerrno now initialised (in setup.c).
+  * adns_s_systemfail is in table of errors (for eg adns_strerror).
   * Improvements to install instructions, TODO, etc.
 
  --
   * Improvements to install instructions, TODO, etc.
 
  --
index 6953cea6d403782eb8aaf90506c47ce7aa29439c..c76f8f2a68345b8fa14bff8b70815d3b83d4d0bd 100644 (file)
@@ -1,5 +1,36 @@
 adns debug: using nameserver 172.18.45.6
 adns debug: using nameserver 172.18.45.6
-chiark.greenend.org.uk flags 0 type 1 A(-) submitted
-chiark.greenend.org.uk flags 0 type A(-): OK; nrrs=1; cname=$; owner=$; ttl=86400
+chiark.greenend.org.uk flags 4 type 1 A(-) submitted
+chiark.greenend.org.uk flags 4 type 2 NS(raw) submitted
+chiark.greenend.org.uk flags 4 type 5 CNAME(-) submitted
+chiark.greenend.org.uk flags 4 type 6 SOA(raw) submitted
+chiark.greenend.org.uk flags 4 type 12 PTR(raw) submitted
+chiark.greenend.org.uk flags 4 type 13 HINFO(-) submitted
+chiark.greenend.org.uk flags 4 type 15 MX(raw) submitted
+chiark.greenend.org.uk flags 4 type 16 TXT(-) submitted
+chiark.greenend.org.uk flags 4 type 17 RP(raw) submitted
+chiark.greenend.org.uk flags 4 type 65537 A(addr) submitted
+chiark.greenend.org.uk flags 4 type 65538 NS(+addr) submitted
+chiark.greenend.org.uk flags 4 type 65548 PTR(checked) submitted
+chiark.greenend.org.uk flags 4 type 65551 MX(+addr) submitted
+chiark.greenend.org.uk flags 4 type 131078 SOA(822) submitted
+chiark.greenend.org.uk flags 4 type 131089 RP(822) submitted
+chiark.greenend.org.uk flags 4 type A(-): OK; nrrs=1; cname=$; owner=chiark.greenend.org.uk; ttl=86400
  195.224.76.132
  195.224.76.132
+chiark.greenend.org.uk flags 4 type NS(raw): No such data; nrrs=0; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+chiark.greenend.org.uk flags 4 type CNAME(-): No such data; nrrs=0; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+chiark.greenend.org.uk flags 4 type SOA(raw): No such data; nrrs=0; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+chiark.greenend.org.uk flags 4 type PTR(raw): No such data; nrrs=0; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+chiark.greenend.org.uk flags 4 type HINFO(-): No such data; nrrs=0; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+chiark.greenend.org.uk flags 4 type MX(raw): OK; nrrs=1; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+ 5 "permutation-city.greenend.org.uk"
+chiark.greenend.org.uk flags 4 type TXT(-): No such data; nrrs=0; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+chiark.greenend.org.uk flags 4 type RP(raw): No such data; nrrs=0; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+chiark.greenend.org.uk flags 4 type A(addr): OK; nrrs=1; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+ AF_INET 195.224.76.132
+chiark.greenend.org.uk flags 4 type NS(+addr): No such data; nrrs=0; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+chiark.greenend.org.uk flags 4 type PTR(checked): No such data; nrrs=0; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+chiark.greenend.org.uk flags 4 type MX(+addr): OK; nrrs=1; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+ 5 "permutation-city.greenend.org.uk": AF_INET 195.224.76.134
+chiark.greenend.org.uk flags 4 type SOA(822): No such data; nrrs=0; cname=$; owner=chiark.greenend.org.uk; ttl=86400
+chiark.greenend.org.uk flags 4 type RP(822): No such data; nrrs=0; cname=$; owner=chiark.greenend.org.uk; ttl=86400
 rc=0
 rc=0
index acc360eb833c64ae3a30c5d3168af16209fb4765..5e2c3356f3e4958766c4be38bc47bc74420f386b 100644 (file)
@@ -1,23 +1,93 @@
 default
 default
-:1 chiark.greenend.org.uk
- start 924360510.895567
+4/chiark.greenend.org.uk
+ start 933206012.504679
  socket type=SOCK_DGRAM
  socket=4
  socket type=SOCK_DGRAM
  socket=4
- +0.000363
+ +0.000275
  fcntl fd=4 cmd=F_GETFL
  fcntl=~O_NONBLOCK&...
  fcntl fd=4 cmd=F_GETFL
  fcntl=~O_NONBLOCK&...
- +0.000092
+ +0.000094
  fcntl fd=4 cmd=F_SETFL O_NONBLOCK|...
  fcntl=OK
  fcntl fd=4 cmd=F_SETFL O_NONBLOCK|...
  fcntl=OK
- +0.000067
+ +0.000073
  sendto fd=4 addr=172.18.45.6:53
      311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
      02756b00 00010001.
  sendto=40
  sendto fd=4 addr=172.18.45.6:53
      311f0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
      02756b00 00010001.
  sendto=40
- +0.001845
- select max=5 rfds=[4] wfds=[] efds=[] to=1.998155
+ +0.001715
+ sendto fd=4 addr=172.18.45.6:53
+     31200100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00020001.
+ sendto=40
+ +0.001142
+ sendto fd=4 addr=172.18.45.6:53
+     31210100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00050001.
+ sendto=40
+ +0.001143
+ sendto fd=4 addr=172.18.45.6:53
+     31220100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00060001.
+ sendto=40
+ +0.001213
+ sendto fd=4 addr=172.18.45.6:53
+     31230100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 000c0001.
+ sendto=40
+ +0.001183
+ sendto fd=4 addr=172.18.45.6:53
+     31240100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 000d0001.
+ sendto=40
+ +0.001273
+ sendto fd=4 addr=172.18.45.6:53
+     31250100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 000f0001.
+ sendto=40
+ +0.001188
+ sendto fd=4 addr=172.18.45.6:53
+     31260100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00100001.
+ sendto=40
+ +0.001185
+ sendto fd=4 addr=172.18.45.6:53
+     31270100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00110001.
+ sendto=40
+ +0.001192
+ sendto fd=4 addr=172.18.45.6:53
+     31280100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001.
+ sendto=40
+ +0.001315
+ sendto fd=4 addr=172.18.45.6:53
+     31290100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00020001.
+ sendto=40
+ +0.001206
+ sendto fd=4 addr=172.18.45.6:53
+     312a0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 000c0001.
+ sendto=40
+ +0.001199
+ sendto fd=4 addr=172.18.45.6:53
+     312b0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 000f0001.
+ sendto=40
+ +0.001162
+ sendto fd=4 addr=172.18.45.6:53
+     312c0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00060001.
+ sendto=40
+ +0.001234
+ sendto fd=4 addr=172.18.45.6:53
+     312d0100 00010000 00000000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00110001.
+ sendto=40
+ +0.001320
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.981330
  select=1 rfds=[4] wfds=[] efds=[]
  select=1 rfds=[4] wfds=[] efds=[]
- +0.005511
+ +0.000364
  recvfrom fd=4 buflen=512 *addrlen=16
  recvfrom=OK addr=172.18.45.6:53
      311f8580 00010001 00020002 06636869 61726b08 67726565 6e656e64 036f7267
  recvfrom fd=4 buflen=512 *addrlen=16
  recvfrom=OK addr=172.18.45.6:53
      311f8580 00010001 00020002 06636869 61726b08 67726565 6e656e64 036f7267
@@ -25,10 +95,191 @@ default
      64036f72 6702756b 00000200 01000151 80001103 6e73300a 72656c61 74697669
      7479c038 c0380002 00010001 51800006 036e7331 c057c053 00010001 00015180
      0004ac12 2d06c070 00010001 00015180 0004ac12 2d41.
      64036f72 6702756b 00000200 01000151 80001103 6e73300a 72656c61 74697669
      7479c038 c0380002 00010001 51800006 036e7331 c057c053 00010001 00015180
      0004ac12 2d06c070 00010001 00015180 0004ac12 2d41.
- +0.000881
+ +0.001489
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31208580 00010000 00010000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00020001 08677265 656e656e 64036f72 6702756b 00000600 01000151
+     80002602 6e73c00c 0a686f73 746d6173 746572c0 2877276a 9c000070 8000001c
+     2000093a 80000151 80.
+ +0.001437
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000394
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.980503
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.001013
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31218580 00010000 00010000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00050001 08677265 656e656e 64036f72 6702756b 00000600 01000151
+     80002602 6e73c00c 0a686f73 746d6173 746572c0 2877276a 9c000070 8000001c
+     2000093a 80000151 80.
+ +0.000770
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000496
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.979367
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.001726
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31228580 00010000 00010000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00060001 08677265 656e656e 64036f72 6702756b 00000600 01000151
+     80002602 6e73c00c 0a686f73 746d6173 746572c0 2877276a 9c000070 8000001c
+     2000093a 80000151 80.
+ +0.000812
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000408
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.977634
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.002560
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31238580 00010000 00010000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 000c0001 08677265 656e656e 64036f72 6702756b 00000600 01000151
+     80002602 6e73c00c 0a686f73 746d6173 746572c0 2877276a 9c000070 8000001c
+     2000093a 80000151 80.
+ +0.000777
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000403
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.975077
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.002559
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31248580 00010000 00010000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 000d0001 08677265 656e656e 64036f72 6702756b 00000600 01000151
+     80002602 6e73c00c 0a686f73 746d6173 746572c0 2877276a 9c000070 8000001c
+     2000093a 80000151 80.
+ +0.000960
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000412
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.972419
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.004697
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31258580 00010001 00020003 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 000f0001 c00c000f 00010001 51800024 00051070 65726d75 74617469
+     6f6e2d63 69747908 67726565 6e656e64 036f7267 02756b00 c0470002 00010001
+     51800011 036e7330 0a72656c 61746976 697479c0 47c04700 02000100 01518000
+     06036e73 31c068c0 36000100 01000151 800004c3 e04c86c0 64000100 01000151
+     800004ac 122d06c0 81000100 01000151 800004ac 122d41.
+ +0.001256
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000769
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.966885
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.001768
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31268580 00010000 00010000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00100001 08677265 656e656e 64036f72 6702756b 00000600 01000151
+     80002602 6e73c00c 0a686f73 746d6173 746572c0 2877276a 9c000070 8000001c
+     2000093a 80000151 80.
+ +0.001528
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000443
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.964331
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.001739
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31278580 00010000 00010000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00110001 08677265 656e656e 64036f72 6702756b 00000600 01000151
+     80002602 6e73c00c 0a686f73 746d6173 746572c0 2877276a 9c000070 8000001c
+     2000093a 80000151 80.
+ +0.000776
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000429
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.962579
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.004212
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31288580 00010001 00020002 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00010001 c00c0001 00010001 51800004 c3e04c84 08677265 656e656e
+     64036f72 6702756b 00000200 01000151 80001103 6e73300a 72656c61 74697669
+     7479c038 c0380002 00010001 51800006 036e7331 c057c053 00010001 00015180
+     0004ac12 2d06c070 00010001 00015180 0004ac12 2d41.
+ +0.001050
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000589
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.958043
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.002059
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     31298580 00010000 00010000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00020001 08677265 656e656e 64036f72 6702756b 00000600 01000151
+     80002602 6e73c00c 0a686f73 746d6173 746572c0 2877276a 9c000070 8000001c
+     2000093a 80000151 80.
+ +0.000776
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000435
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.955979
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.002598
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     312a8580 00010000 00010000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 000c0001 08677265 656e656e 64036f72 6702756b 00000600 01000151
+     80002602 6e73c00c 0a686f73 746d6173 746572c0 2877276a 9c000070 8000001c
+     2000093a 80000151 80.
+ +0.000777
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000396
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.953407
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.004872
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     312b8580 00010001 00020003 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 000f0001 c00c000f 00010001 51800024 00051070 65726d75 74617469
+     6f6e2d63 69747908 67726565 6e656e64 036f7267 02756b00 c0470002 00010001
+     51800011 036e7330 0a72656c 61746976 697479c0 47c04700 02000100 01518000
+     06036e73 31c068c0 36000100 01000151 800004c3 e04c86c0 64000100 01000151
+     800004ac 122d06c0 81000100 01000151 800004ac 122d41.
+ +0.001252
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000950
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.947495
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.001580
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     312c8580 00010000 00010000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00060001 08677265 656e656e 64036f72 6702756b 00000600 01000151
+     80002602 6e73c00c 0a686f73 746d6173 746572c0 2877276a 9c000070 8000001c
+     2000093a 80000151 80.
+ +0.000780
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=EAGAIN
+ +0.000401
+ select max=5 rfds=[4] wfds=[] efds=[] to=1.945968
+ select=1 rfds=[4] wfds=[] efds=[]
+ +0.002592
+ recvfrom fd=4 buflen=512 *addrlen=16
+ recvfrom=OK addr=172.18.45.6:53
+     312d8580 00010000 00010000 06636869 61726b08 67726565 6e656e64 036f7267
+     02756b00 00110001 08677265 656e656e 64036f72 6702756b 00000600 01000151
+     80002602 6e73c00c 0a686f73 746d6173 746572c0 2877276a 9c000070 8000001c
+     2000093a 80000151 80.
+ +0.000794
  recvfrom fd=4 buflen=512 *addrlen=16
  recvfrom=EAGAIN
  +0.000441
  close fd=4
  close=OK
  recvfrom fd=4 buflen=512 *addrlen=16
  recvfrom=EAGAIN
  +0.000441
  close fd=4
  close=OK
- +0.000218
+ +0.000387
index e6b16aaa9c4bd6eb62bab47f739ba05355309668..a287d065ebcf3c787d4a264c1ca16cf6af62ca0a 100644 (file)
@@ -156,7 +156,7 @@ struct adns__query {
   struct { adns_query head, tail; } children;
   struct { adns_query back, next; } siblings;
   struct { allocnode *head, *tail; } allocations;
   struct { adns_query head, tail; } children;
   struct { adns_query back, next; } siblings;
   struct { allocnode *head, *tail; } allocations;
-  int interim_allocd;
+  int interim_allocd, preserved_allocd;
   void *final_allocspace;
 
   const typeinfo *typei;
   void *final_allocspace;
 
   const typeinfo *typei;
@@ -409,20 +409,27 @@ void adns__search_next(adns_state ads, adns_query qu, struct timeval now);
  */
 
 void *adns__alloc_interim(adns_query qu, size_t sz);
  */
 
 void *adns__alloc_interim(adns_query qu, size_t sz);
+void *adns__alloc_preserved(adns_query qu, size_t sz);
 /* Allocates some memory, and records which query it came from
  * and how much there was.
  *
 /* Allocates some memory, and records which query it came from
  * and how much there was.
  *
- * If an error occurs in the query, all its memory is simply freed.
- *
- * If the query succeeds, one large buffer will be made which is
- * big enough for all these allocations, and then adns__alloc_final
- * will get memory from this buffer.
+ * If an error occurs in the query, all the memory from _interim is
+ * simply freed.  If the query succeeds, one large buffer will be made
+ * which is big enough for all these allocations, and then
+ * adns__alloc_final will get memory from this buffer.
  *
  * _alloc_interim can fail (and return 0).
  * The caller must ensure that the query is failed.
  *
  *
  * _alloc_interim can fail (and return 0).
  * The caller must ensure that the query is failed.
  *
- * adns__alloc_interim_{only,fail}(qu,0) will not return 0,
- * but it will not necessarily return a distinct pointer each time.
+ * The memory from _preserved is is kept and transferred into the
+ * larger buffer - unless we run out of memory, in which case it too
+ * is freed.  When you use _preserved you have to add code to the
+ * x_nomem error exit case in adns__makefinal_query to clear out the
+ * pointers you made to those allocations, because that's when they're
+ * thrown away; you should also make a note in the declaration of
+ * those pointer variables, to note that they are _preserved rather
+ * than _interim.  If they're in the answer, note it here:
+ *  answer->cname and answer->owner are _preserved.
  */
 
 void adns__transfer_interim(adns_query from, adns_query to, void *block, size_t sz);
  */
 
 void adns__transfer_interim(adns_query from, adns_query to, void *block, size_t sz);
@@ -452,12 +459,12 @@ void *adns__alloc_final(adns_query qu, size_t sz);
 void adns__makefinal_block(adns_query qu, void **blpp, size_t sz);
 void adns__makefinal_str(adns_query qu, char **strp);
 
 void adns__makefinal_block(adns_query qu, void **blpp, size_t sz);
 void adns__makefinal_str(adns_query qu, char **strp);
 
-void adns__reset_cnameonly(adns_query qu);
-/* Resets all of the memory management stuff etc. to
- * take account of only the CNAME.  Used when we find an error somewhere
- * and want to just report the error (with perhaps CNAME info), and also
- * when we're halfway through RRs in a datagram and discover that we
- * need to retry the query.
+void adns__reset_preserved(adns_query qu);
+/* Resets all of the memory management stuff etc. to take account of
+ * only the _preserved stuff from _alloc_preserved.  Used when we find
+ * an error somewhere and want to just report the error (with perhaps
+ * CNAME, owner, etc. info), and also when we're halfway through RRs
+ * in a datagram and discover that we need to retry the query.
  */
 
 void adns__query_done(adns_query qu);
  */
 
 void adns__query_done(adns_query qu);
index b9860bf0ab7d1cc295cd85915cc59382d9ce3598..b02abda87fc02e201bd4659a79a48c994f6253a0 100644 (file)
@@ -48,6 +48,7 @@ static adns_query query_alloc(adns_state ads, const typeinfo *typei,
   LINK_INIT(qu->siblings);
   LIST_INIT(qu->allocations);
   qu->interim_allocd= 0;
   LINK_INIT(qu->siblings);
   LIST_INIT(qu->allocations);
   qu->interim_allocd= 0;
+  qu->preserved_allocd= 0;
   qu->final_allocspace= 0;
 
   qu->typei= typei;
   qu->final_allocspace= 0;
 
   qu->typei= typei;
@@ -181,7 +182,7 @@ static int save_owner(adns_query qu, const char *owner, int ol) {
   ans= qu->answer;
   assert(!ans->owner);
 
   ans= qu->answer;
   assert(!ans->owner);
 
-  ans->owner= adns__alloc_interim(qu,ol+1);  if (!ans->owner) return 0;
+  ans->owner= adns__alloc_preserved(qu,ol+1);  if (!ans->owner) return 0;
 
   memcpy(ans->owner,owner,ol);
   ans->owner[ol]= 0;
 
   memcpy(ans->owner,owner,ol);
   ans->owner[ol]= 0;
@@ -277,9 +278,23 @@ static void *alloc_common(adns_query qu, size_t sz) {
 }
 
 void *adns__alloc_interim(adns_query qu, size_t sz) {
 }
 
 void *adns__alloc_interim(adns_query qu, size_t sz) {
+  void *rv;
+  
   sz= MEM_ROUND(sz);
   sz= MEM_ROUND(sz);
+  rv= alloc_common(qu,sz);
+  if (!rv) return 0;
   qu->interim_allocd += sz;
   qu->interim_allocd += sz;
-  return alloc_common(qu,sz);
+  return rv;
+}
+
+void *adns__alloc_preserved(adns_query qu, size_t sz) {
+  void *rv;
+  
+  sz= MEM_ROUND(sz);
+  rv= adns__alloc_interim(qu,sz);
+  if (!rv) return 0;
+  qu->preserved_allocd += sz;
+  return rv;
 }
 
 void *adns__alloc_mine(adns_query qu, size_t sz) {
 }
 
 void *adns__alloc_mine(adns_query qu, size_t sz) {
@@ -330,12 +345,12 @@ static void cancel_children(adns_query qu) {
   LIST_INIT(qu->children);
 }
 
   LIST_INIT(qu->children);
 }
 
-void adns__reset_cnameonly(adns_query qu) {
+void adns__reset_preserved(adns_query qu) {
   assert(!qu->final_allocspace);
   cancel_children(qu);
   qu->answer->nrrs= 0;
   qu->answer->rrs.untyped= 0;
   assert(!qu->final_allocspace);
   cancel_children(qu);
   qu->answer->nrrs= 0;
   qu->answer->rrs.untyped= 0;
-  qu->interim_allocd= qu->answer->cname ? MEM_ROUND(strlen(qu->answer->cname)+1) : 0;
+  qu->interim_allocd= qu->preserved_allocd;
 }
 
 static void free_query_allocs(adns_query qu) {
 }
 
 static void free_query_allocs(adns_query qu) {
@@ -401,9 +416,12 @@ static void makefinal_query(adns_query qu) {
   return;
   
  x_nomem:
   return;
   
  x_nomem:
-  qu->answer->status= adns_s_nomemory;
+  qu->preserved_allocd= 0;
   qu->answer->cname= 0;
   qu->answer->cname= 0;
-  adns__reset_cnameonly(qu);
+  qu->answer->owner= 0;
+  adns__reset_preserved(qu); /* (but we just threw away the preserved stuff) */
+
+  qu->answer->status= adns_s_nomemory;
   free_query_allocs(qu);
 }
 
   free_query_allocs(qu);
 }
 
@@ -448,7 +466,7 @@ void adns__query_done(adns_query qu) {
 }
 
 void adns__query_fail(adns_query qu, adns_status stat) {
 }
 
 void adns__query_fail(adns_query qu, adns_status stat) {
-  adns__reset_cnameonly(qu);
+  adns__reset_preserved(qu);
   qu->answer->status= stat;
   adns__query_done(qu);
 }
   qu->answer->status= stat;
   adns__query_done(qu);
 }
index ab7c8ff4aadbc37c6cdb589baf43b49aa384cc88..0ee134a4f9956b0a3067d56e358ee6e85105c58a 100644 (file)
@@ -170,7 +170,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
        if (!qu->vb.used) goto x_truncated;
        if (st) { adns__query_fail(qu,st); return; }
        l= strlen(qu->vb.buf)+1;
        if (!qu->vb.used) goto x_truncated;
        if (st) { adns__query_fail(qu,st); return; }
        l= strlen(qu->vb.buf)+1;
-       qu->answer->cname= adns__alloc_interim(qu,l);
+       qu->answer->cname= adns__alloc_preserved(qu,l);
        if (!qu->answer->cname) { adns__query_fail(qu,adns_s_nomemory); return; }
 
        qu->cname_dgram= adns__alloc_mine(qu,dglen);
        if (!qu->answer->cname) { adns__query_fail(qu,adns_s_nomemory); return; }
 
        qu->cname_dgram= adns__alloc_mine(qu,dglen);
@@ -336,6 +336,6 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
     memcpy(newquery,qu->vb.buf,qu->vb.used);
   }
   
     memcpy(newquery,qu->vb.buf,qu->vb.used);
   }
   
-  adns__reset_cnameonly(qu);
+  adns__reset_preserved(qu);
   adns__query_udp(qu,now);
 }
   adns__query_udp(qu,now);
 }