Browse Source

Plan 9 from Bell Labs 2007-03-07

David du Colombier 14 years ago
parent
commit
6bc0d48062

+ 18 - 18
dist/replica/_plan9.db

@@ -340,10 +340,10 @@
 386/bin/ndb - 20000000775 sys sys 985743147 0
 386/bin/ndb/cs - 775 sys sys 1169612028 150911
 386/bin/ndb/csquery - 775 sys sys 1168402337 61702
-386/bin/ndb/dns - 775 sys sys 1173125808 254849
-386/bin/ndb/dnsdebug - 775 sys sys 1173125809 229017
+386/bin/ndb/dns - 775 sys sys 1173212578 255076
+386/bin/ndb/dnsdebug - 775 sys sys 1173212578 229223
 386/bin/ndb/dnsquery - 775 sys sys 1173113879 63870
-386/bin/ndb/dnstcp - 775 sys sys 1173125810 227919
+386/bin/ndb/dnstcp - 775 sys sys 1173212579 228125
 386/bin/ndb/ipquery - 775 sys sys 1169612031 96994
 386/bin/ndb/mkdb - 775 sys sys 1168402340 64211
 386/bin/ndb/mkhash - 775 sys sys 1168402340 84780
@@ -405,7 +405,7 @@
 386/bin/snap - 775 sys sys 1136346852 313627
 386/bin/snapfs - 775 sys sys 1134389876 388292
 386/bin/sniffer - 775 sys sys 1038443185 99028
-386/bin/snoopy - 775 sys sys 1169612032 183527
+386/bin/snoopy - 775 sys sys 1173212580 192338
 386/bin/sort - 775 sys sys 1168402349 82523
 386/bin/spin - 775 sys sys 1134151359 758520
 386/bin/split - 775 sys sys 1168402349 75886
@@ -7504,7 +7504,7 @@ sys/man/2/hypot - 664 sys sys 944959693 302
 sys/man/2/intmap - 664 sys sys 1015091523 2622
 sys/man/2/ioproc - 664 sys sys 1159419768 3060
 sys/man/2/iounit - 664 sys sys 1015091523 1001
-sys/man/2/ip - 664 sys sys 1162102153 7209
+sys/man/2/ip - 664 sys sys 1173239323 7249
 sys/man/2/isalpharune - 664 sys sys 1015091523 1059
 sys/man/2/keyboard - 664 sys sys 950892860 2065
 sys/man/2/lock - 664 sys sys 1172959628 4693
@@ -7519,7 +7519,7 @@ sys/man/2/mouse - 664 sys sys 1140900146 4952
 sys/man/2/mp - 664 sys sys 1140106703 10762
 sys/man/2/muldiv - 664 sys sys 984709633 639
 sys/man/2/nan - 664 sys sys 975084242 937
-sys/man/2/ndb - 664 sys sys 1161207554 9603
+sys/man/2/ndb - 664 sys sys 1173239303 9603
 sys/man/2/notify - 664 sys sys 1032058674 6376
 sys/man/2/object - 664 sys sys 944959695 3864
 sys/man/2/open - 664 sys sys 1015091524 3404
@@ -7975,7 +7975,7 @@ sys/src/9/pc/devlm78.c - 664 sys sys 1128255048 6291
 sys/src/9/pc/devlml.c - 664 sys sys 1132448361 7502
 sys/src/9/pc/devlml.h - 664 sys sys 1026847636 2948
 sys/src/9/pc/devlpt.c - 664 sys sys 1015014514 4420
-sys/src/9/pc/devpccard.c - 664 sys sys 1162222267 39301
+sys/src/9/pc/devpccard.c - 664 sys sys 1173225108 39296
 sys/src/9/pc/devrtc.c - 664 sys sys 1015014515 7167
 sys/src/9/pc/devtv.c - 664 sys sys 1131290299 45676
 sys/src/9/pc/devusb.c - 664 sys sys 1168305372 18752
@@ -12664,27 +12664,27 @@ sys/src/cmd/mug.c - 664 sys sys 1157143847 24888
 sys/src/cmd/mv.c - 664 sys sys 1163029439 4682
 sys/src/cmd/ndb - 20000000775 sys sys 1080135004 0
 sys/src/cmd/ndb/convDNS2M.c - 664 sys sys 1173059857 6856
-sys/src/cmd/ndb/convM2DNS.c - 664 sys sys 1173118920 10483
+sys/src/cmd/ndb/convM2DNS.c - 664 sys sys 1173161431 10636
 sys/src/cmd/ndb/cs.c - 664 sys sys 1163208617 33080
 sys/src/cmd/ndb/csquery.c - 664 sys sys 1014926159 1062
-sys/src/cmd/ndb/dblookup.c - 664 sys sys 1173060354 18199
-sys/src/cmd/ndb/dn.c - 664 sys sys 1173060793 31773
+sys/src/cmd/ndb/dblookup.c - 664 sys sys 1173238983 18199
+sys/src/cmd/ndb/dn.c - 664 sys sys 1173239201 32107
 sys/src/cmd/ndb/dnarea.c - 664 sys sys 1173059947 2517
-sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1173059885 3155
+sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1173238959 3158
 sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1173061785 16701
-sys/src/cmd/ndb/dns.c - 664 sys sys 1173075040 15645
-sys/src/cmd/ndb/dns.h - 664 sys sys 1173059802 9841
-sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1173060595 8633
+sys/src/cmd/ndb/dns.c - 664 sys sys 1173239144 15721
+sys/src/cmd/ndb/dns.h - 664 sys sys 1173238977 9967
+sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1173239028 8629
 sys/src/cmd/ndb/dnserver.c - 664 sys sys 1173060400 4449
 sys/src/cmd/ndb/dnsquery.c - 664 sys sys 1120564714 2198
-sys/src/cmd/ndb/dnstcp.c - 664 sys sys 1173061127 7677
-sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1173061278 5659
+sys/src/cmd/ndb/dnstcp.c - 664 sys sys 1173239020 7698
+sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1173239157 5693
 sys/src/cmd/ndb/ipquery.c - 664 sys sys 1124711426 773
 sys/src/cmd/ndb/mkdb.c - 664 sys sys 957402054 2886
 sys/src/cmd/ndb/mkfile - 664 sys sys 1173059600 1984
 sys/src/cmd/ndb/mkhash.c - 664 sys sys 1014926160 2899
 sys/src/cmd/ndb/mkhosts.c - 664 sys sys 957402054 4294
-sys/src/cmd/ndb/query.c - 664 sys sys 1078840016 1120
+sys/src/cmd/ndb/query.c - 664 sys sys 1173239042 1137
 sys/src/cmd/netstat.c - 664 sys sys 1128255434 4086
 sys/src/cmd/news.c - 664 sys sys 1014926614 3778
 sys/src/cmd/nfs.c - 664 sys sys 1050068720 31096
@@ -15680,4 +15680,4 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
-386/bin/snoopy - 775 sys sys 1173153677 192206
+sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1173240424 20672

+ 18 - 18
dist/replica/plan9.db

@@ -340,10 +340,10 @@
 386/bin/ndb - 20000000775 sys sys 985743147 0
 386/bin/ndb/cs - 775 sys sys 1169612028 150911
 386/bin/ndb/csquery - 775 sys sys 1168402337 61702
-386/bin/ndb/dns - 775 sys sys 1173125808 254849
-386/bin/ndb/dnsdebug - 775 sys sys 1173125809 229017
+386/bin/ndb/dns - 775 sys sys 1173212578 255076
+386/bin/ndb/dnsdebug - 775 sys sys 1173212578 229223
 386/bin/ndb/dnsquery - 775 sys sys 1173113879 63870
-386/bin/ndb/dnstcp - 775 sys sys 1173125810 227919
+386/bin/ndb/dnstcp - 775 sys sys 1173212579 228125
 386/bin/ndb/ipquery - 775 sys sys 1169612031 96994
 386/bin/ndb/mkdb - 775 sys sys 1168402340 64211
 386/bin/ndb/mkhash - 775 sys sys 1168402340 84780
@@ -405,7 +405,7 @@
 386/bin/snap - 775 sys sys 1136346852 313627
 386/bin/snapfs - 775 sys sys 1134389876 388292
 386/bin/sniffer - 775 sys sys 1038443185 99028
-386/bin/snoopy - 775 sys sys 1173153677 192206
+386/bin/snoopy - 775 sys sys 1173212580 192338
 386/bin/sort - 775 sys sys 1168402349 82523
 386/bin/spin - 775 sys sys 1134151359 758520
 386/bin/split - 775 sys sys 1168402349 75886
@@ -7504,7 +7504,7 @@ sys/man/2/hypot - 664 sys sys 944959693 302
 sys/man/2/intmap - 664 sys sys 1015091523 2622
 sys/man/2/ioproc - 664 sys sys 1159419768 3060
 sys/man/2/iounit - 664 sys sys 1015091523 1001
-sys/man/2/ip - 664 sys sys 1162102153 7209
+sys/man/2/ip - 664 sys sys 1173239323 7249
 sys/man/2/isalpharune - 664 sys sys 1015091523 1059
 sys/man/2/keyboard - 664 sys sys 950892860 2065
 sys/man/2/lock - 664 sys sys 1172959628 4693
@@ -7519,7 +7519,7 @@ sys/man/2/mouse - 664 sys sys 1140900146 4952
 sys/man/2/mp - 664 sys sys 1140106703 10762
 sys/man/2/muldiv - 664 sys sys 984709633 639
 sys/man/2/nan - 664 sys sys 975084242 937
-sys/man/2/ndb - 664 sys sys 1161207554 9603
+sys/man/2/ndb - 664 sys sys 1173239303 9603
 sys/man/2/notify - 664 sys sys 1032058674 6376
 sys/man/2/object - 664 sys sys 944959695 3864
 sys/man/2/open - 664 sys sys 1015091524 3404
@@ -7975,7 +7975,7 @@ sys/src/9/pc/devlm78.c - 664 sys sys 1128255048 6291
 sys/src/9/pc/devlml.c - 664 sys sys 1132448361 7502
 sys/src/9/pc/devlml.h - 664 sys sys 1026847636 2948
 sys/src/9/pc/devlpt.c - 664 sys sys 1015014514 4420
-sys/src/9/pc/devpccard.c - 664 sys sys 1162222267 39301
+sys/src/9/pc/devpccard.c - 664 sys sys 1173225108 39296
 sys/src/9/pc/devrtc.c - 664 sys sys 1015014515 7167
 sys/src/9/pc/devtv.c - 664 sys sys 1131290299 45676
 sys/src/9/pc/devusb.c - 664 sys sys 1168305372 18752
@@ -12664,27 +12664,27 @@ sys/src/cmd/mug.c - 664 sys sys 1157143847 24888
 sys/src/cmd/mv.c - 664 sys sys 1163029439 4682
 sys/src/cmd/ndb - 20000000775 sys sys 1080135004 0
 sys/src/cmd/ndb/convDNS2M.c - 664 sys sys 1173059857 6856
-sys/src/cmd/ndb/convM2DNS.c - 664 sys sys 1173118920 10483
+sys/src/cmd/ndb/convM2DNS.c - 664 sys sys 1173161431 10636
 sys/src/cmd/ndb/cs.c - 664 sys sys 1163208617 33080
 sys/src/cmd/ndb/csquery.c - 664 sys sys 1014926159 1062
-sys/src/cmd/ndb/dblookup.c - 664 sys sys 1173060354 18199
-sys/src/cmd/ndb/dn.c - 664 sys sys 1173060793 31773
+sys/src/cmd/ndb/dblookup.c - 664 sys sys 1173238983 18199
+sys/src/cmd/ndb/dn.c - 664 sys sys 1173239201 32107
 sys/src/cmd/ndb/dnarea.c - 664 sys sys 1173059947 2517
-sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1173059885 3155
-sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1173061785 16701
-sys/src/cmd/ndb/dns.c - 664 sys sys 1173075040 15645
-sys/src/cmd/ndb/dns.h - 664 sys sys 1173059802 9841
-sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1173060595 8633
+sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1173238959 3158
+sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1173240424 20672
+sys/src/cmd/ndb/dns.c - 664 sys sys 1173239144 15721
+sys/src/cmd/ndb/dns.h - 664 sys sys 1173238977 9967
+sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1173239028 8629
 sys/src/cmd/ndb/dnserver.c - 664 sys sys 1173060400 4449
 sys/src/cmd/ndb/dnsquery.c - 664 sys sys 1120564714 2198
-sys/src/cmd/ndb/dnstcp.c - 664 sys sys 1173061127 7677
-sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1173061278 5659
+sys/src/cmd/ndb/dnstcp.c - 664 sys sys 1173239020 7698
+sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1173239157 5693
 sys/src/cmd/ndb/ipquery.c - 664 sys sys 1124711426 773
 sys/src/cmd/ndb/mkdb.c - 664 sys sys 957402054 2886
 sys/src/cmd/ndb/mkfile - 664 sys sys 1173059600 1984
 sys/src/cmd/ndb/mkhash.c - 664 sys sys 1014926160 2899
 sys/src/cmd/ndb/mkhosts.c - 664 sys sys 957402054 4294
-sys/src/cmd/ndb/query.c - 664 sys sys 1078840016 1120
+sys/src/cmd/ndb/query.c - 664 sys sys 1173239042 1137
 sys/src/cmd/netstat.c - 664 sys sys 1128255434 4086
 sys/src/cmd/news.c - 664 sys sys 1014926614 3778
 sys/src/cmd/nfs.c - 664 sys sys 1050068720 31096

+ 18 - 0
dist/replica/plan9.log

@@ -47686,3 +47686,21 @@
 1173132007 0 c sys/src/cmd/ip/snoopy/dns.c - 664 sys sys 1173130870 7867
 1173132007 1 c sys/src/cmd/ip/snoopy/mkfile - 664 sys sys 1173130906 985
 1173155406 0 c 386/bin/snoopy - 775 sys sys 1173153677 192206
+1173162606 0 c sys/src/cmd/ndb/convM2DNS.c - 664 sys sys 1173161431 10636
+1173213006 0 c 386/bin/snoopy - 775 sys sys 1173212580 192338
+1173213006 1 c 386/bin/ndb/dns - 775 sys sys 1173212578 255076
+1173213006 2 c 386/bin/ndb/dnsdebug - 775 sys sys 1173212578 229223
+1173213006 3 c 386/bin/ndb/dnstcp - 775 sys sys 1173212579 228125
+1173225606 0 c sys/src/9/pc/devpccard.c - 664 sys sys 1173225108 39296
+1173240006 0 c sys/man/2/ip - 664 sys sys 1173239323 7249
+1173240006 1 c sys/man/2/ndb - 664 sys sys 1173239303 9603
+1173240006 2 c sys/src/cmd/ndb/dblookup.c - 664 sys sys 1173238983 18199
+1173240006 3 c sys/src/cmd/ndb/dn.c - 664 sys sys 1173239201 32107
+1173240006 4 c sys/src/cmd/ndb/dnnotify.c - 664 sys sys 1173238959 3158
+1173240006 5 c sys/src/cmd/ndb/dns.c - 664 sys sys 1173239144 15721
+1173240006 6 c sys/src/cmd/ndb/dns.h - 664 sys sys 1173238977 9967
+1173240006 7 c sys/src/cmd/ndb/dnsdebug.c - 664 sys sys 1173239028 8629
+1173240006 8 c sys/src/cmd/ndb/dnstcp.c - 664 sys sys 1173239020 7698
+1173240006 9 c sys/src/cmd/ndb/dnudpserver.c - 664 sys sys 1173239157 5693
+1173240006 10 c sys/src/cmd/ndb/query.c - 664 sys sys 1173239042 1137
+1173241806 0 c sys/src/cmd/ndb/dnresolve.c - 664 sys sys 1173240424 20672

+ 27 - 14
sys/man/2/ip

@@ -233,35 +233,47 @@ are used to store 16-bit, 32-bit, and 64-bit integers, respectively, into IP big
 .I nhgetl
 and
 .I nhgetv
-convert big-endian 2, 4 and 8 byte quantities into integers (or uvlongs).
+convert big-endian 2, 4 and 8 byte quantities into integers (or
+.IR uvlong s).
 .PP
 .I Pctlbsum
 returns the one's complement checksum used in IP protocols, typically invoked as
+.IP
 .EX
 hnputs(hdr->cksum, ~ptclbsum(data, len) & 0xffff);
 .EE
 .PP
-A number of standard IP addresses in V6 format are also defined.  They
-are:
-.IP \f5IPv4bcast
+A number of standard IP addresses in V6 format are also defined.  They are:
+.TF IPv4allrouter
+.TP
+.B IPv4bcast
 the V4 broadcast address
-.IP \f5IPv4allsys
+.TP
+.B IPv4allsys
 the V4 all systems multicast address
-.IP \f5IPv4allrouter
+.TP
+.B IPv4allrouter
 the V4 all routers multicast address
-.IP \f5IPallbits
+.TP
+.B IPallbits
 the V6 all bits on address
-.IP \f5IPnoaddr
+.TP
+.B IPnoaddr
 the V6 null address, all zeros
-.IP \f5v4prefix
+.TP
+.B v4prefix
 the IP V6 prefix to all embedded V4 addresses
+.PD
 .PP
 .I Readipifc
 returns information about
-a particular interface  (\fIindex\fP >= 0)
-or all IP interfaces (\fIindex\fP < 0)
-configured under a
-mount point
+a particular interface
+.RI ( index
+>= 0)
+or all IP interfaces
+.RI ( index
+< 0)
+configured under a mount point
 .IR net ,
 default
 .BR /net .
@@ -348,4 +360,5 @@ point to point.
 .SH SOURCE
 .B /sys/src/libip
 .SH SEE ALSO
-.IR print (2)
+.IR print (2),
+.IR ip (3)

+ 19 - 19
sys/man/2/ndb

@@ -39,8 +39,9 @@ char*	ndbgetvalue(Ndb *db, Ndbs *s, char *attr, char *val,
 		char *rattr, Ndbtuple **tp)
 .PP
 .B
-char*	csgetvalue(char *netroot, char *attr, char *val, char *rattr,
-		Ndbtuple **tp)
+char*	csgetvalue(char *netroot, char *attr, char *val,
+.B
+		char *rattr, Ndbtuple **tp)
 .PP
 .B
 char*	ipattr(char *name)
@@ -54,9 +55,9 @@ Ndbtuple*	ndbipinfo(Ndb *db, char *attr, char *val, char **attrs,
 .B		int nattr)
 .PP
 .B
-Ndbtuple*	csipinfo(char *netroot, char *attr, char *val, char **attrs,
+Ndbtuple*	csipinfo(char *netroot, char *attr, char *val,
 .br
-.B		int nattr)
+.B		char **attrs, int nattr)
 .PP
 .B
 ulong	ndbhash(char *val, int hlen)
@@ -203,7 +204,7 @@ If
 .I tp
 is non nil,
 .I *tp
-will point to the entry.  Otherwise the entry will be freeed.
+will point to the entry.  Otherwise the entry will be freed.
 .PP
 .I Csgetvalue
 is like
@@ -258,13 +259,13 @@ attribute/value pair,
 .IR attr = val .
 .I Ndbipinfo
 returns a list of tuples whose attributes match the
-attributes in the 
+attributes in the
 .I n
 element array
 .IR attrs .
 For example, consider the following database entries describing a network,
 a subnetwork, and a system.
-.PP
+.IP
 .EX
 ipnet=big ip=10.0.0.0
 	dns=dns.big.com
@@ -276,9 +277,9 @@ ip=10.1.1.4 dom=x.big.com
 .EE
 .PP
 Calling
-.PP
+.IP
 .EX
-   ndbipinfo(db, "dom", "x.big.com", ["bootf" "smtp" "dns"], 3)
+ndbipinfo(db, "dom", "x.big.com", ["bootf" "smtp" "dns"], 3)
 .EE
 .PP
 will return the tuples
@@ -319,9 +320,9 @@ mounted at
 It returns a linked list of
 .I Ndbtuple's
 representing a single database entry.
-The tuples are logicly arranged into lines using the
+The tuples are logically arranged into lines using the
 .B line
-fieldin the structure.
+field in the structure.
 The possible
 .IR type 's
 of query are and the attributes on each returned tuple line is:
@@ -346,7 +347,7 @@ must be an
 .SM ASCII
 IP address.  Returns reverse name
 .RI ( ptr )
-and domain name 
+and domain name
 .RI ( dom )
 .TP
 .B cname
@@ -379,7 +380,7 @@ and name server
 .RI ( ns )
 .PP
 .I Ndbfindattr
-searches 
+searches
 .I entry
 for the tuple
 with attribute
@@ -400,13 +401,12 @@ and
 .I ndbparse
 and provide its own search routines.  The
 .I ndbchanged
-routine can be used by the application to periodicly
+routine can be used by the application to periodically
 check for changes.  It returns zero
 if none of the files comprising the database have
 changes and non-zero if they have.
 .PP
-Finally, a number of routines are provided for manipulating
-tuples.
+Finally, a number of routines are provided for manipulating tuples.
 .PP
 .I Ndbdiscard
 removes attr/val pair
@@ -447,12 +447,12 @@ end up on the same line.
 is freed.
 .PP
 .I Ndbsetmalloctag
-sets the malloc tag 
+sets the malloc tag
 (see
 .I setmalloctag
 in
 .IR malloc (2))
-of each tuple in the list 
+of each tuple in the list
 .I t
 to
 .IR tag .
@@ -461,7 +461,7 @@ to
 .SH SOURCE
 .B /sys/src/libndb
 .SH SEE ALSO
-.IR ndb (6)
+.IR ndb (6),
 .IR ndb (8)
 .SH DIAGNOSTICS
 .IR Ndbgetvalue ,

+ 2 - 2
sys/src/9/pc/devpccard.c

@@ -536,7 +536,7 @@ devpccardlink(void)
 
 	/* Find all CardBus controllers */
 	pci = nil;
-	intl = (uchar)-1;
+	intl = 0xff;
 	while ((pci = pcimatch(pci, 0, 0)) != nil) {
 		ulong baddr;
 		Cardbus *cb;
@@ -630,7 +630,7 @@ devpccardlink(void)
 			pcicfgw8(cb->pci, 0xD4, 0xCA);
 		}
 
-		if (intl != 0xFF && intl != pci->intl)
+		if (intl != 0xff && intl != pci->intl)
 			intrenable(pci->intl, cbinterrupt, cb, pci->tbdf, "cardbus");
 		intl = pci->intl;
 

+ 18 - 10
sys/src/cmd/ndb/convM2DNS.c

@@ -37,13 +37,20 @@ errneg(RR *rp, Scan *sp, int actual)
 static int
 errtoolong(RR *rp, Scan *sp, int actual, int nominal, char *where)
 {
+	char *p, *ep;
 	char ptype[64];
 
-	snprint(sp->errbuf, sizeof sp->errbuf,
-		"%s%s %s RR: wrong length (actual %d, nominal %d): %R",
-		where? where: "", where? ":": "",
-		rrname(rp? rp->type: -1, ptype, sizeof ptype),
-		actual, nominal, rp);
+	p =  sp->errbuf;
+	ep = sp->errbuf + sizeof sp->errbuf - 1;
+	if (where)
+		p = seprint(p, ep, "%s: ", where);
+	if (rp)
+		p = seprint(p, ep, "type %s RR: ",
+			rrname(rp->type, ptype, sizeof ptype));
+	p = seprint(p, ep, "wrong length (actual %d, nominal %d)",
+		actual, nominal);
+	if (rp)
+		seprint(p, ep, ": %R", rp);
 	sp->err = sp->errbuf;
 	return 0;
 }
@@ -59,7 +66,7 @@ gchar(RR *rp, Scan *sp)
 	if(sp->err)
 		return 0;
 	if(sp->ep - sp->p < 1)
-		return errtoolong(rp, sp, sp->ep - sp->p, 1, nil);
+		return errtoolong(rp, sp, sp->ep - sp->p, 1, "gchar");
 	x = sp->p[0];
 	sp->p += 1;
 	return x;
@@ -72,7 +79,7 @@ gshort(RR *rp, Scan *sp)
 	if(sp->err)
 		return 0;
 	if(sp->ep - sp->p < 2)
-		return errtoolong(rp, sp, sp->ep - sp->p, 2, nil);
+		return errtoolong(rp, sp, sp->ep - sp->p, 2, "gshort");
 	x = sp->p[0]<<8 | sp->p[1];
 	sp->p += 2;
 	return x;
@@ -85,7 +92,7 @@ glong(RR *rp, Scan *sp)
 	if(sp->err)
 		return 0;
 	if(sp->ep - sp->p < 4)
-		return errtoolong(rp, sp, sp->ep - sp->p, 4, nil);
+		return errtoolong(rp, sp, sp->ep - sp->p, 4, "glong");
 	x = sp->p[0]<<24 | sp->p[1]<<16 | sp->p[2]<<8 | sp->p[3];
 	sp->p += 4;
 	return x;
@@ -102,7 +109,7 @@ gv4addr(RR *rp, Scan *sp)
 	if(sp->err)
 		return 0;
 	if(sp->ep - sp->p < 4)
-		return (DN*)errtoolong(rp, sp, sp->ep - sp->p, 4, nil);
+		return (DN*)errtoolong(rp, sp, sp->ep - sp->p, 4, "gv4addr");
 	snprint(addr, sizeof(addr), "%V", sp->p);
 	sp->p += 4;
 
@@ -116,7 +123,8 @@ gv6addr(RR *rp, Scan *sp)
 	if(sp->err)
 		return 0;
 	if(sp->ep - sp->p < IPaddrlen)
-		return (DN*)errtoolong(rp, sp, sp->ep - sp->p, IPaddrlen, nil);
+		return (DN*)errtoolong(rp, sp, sp->ep - sp->p, IPaddrlen,
+			"gv6addr");
 	snprint(addr, sizeof(addr), "%I", sp->p);
 	sp->p += IPaddrlen;
 

+ 3 - 3
sys/src/cmd/ndb/dblookup.c

@@ -73,11 +73,11 @@ opendatabase(void)
 RR*
 dblookup(char *name, int class, int type, int auth, int ttl)
 {
-	RR *rp, *tp;
-	char buf[256];
+	int err;
 	char *wild, *cp;
+	char buf[256];
+	RR *rp, *tp;
 	DN *dp, *ndp;
-	int err;
 	static int parallel;
 	static int parfd[2];
 	static char token[1];

+ 13 - 1
sys/src/cmd/ndb/dn.c

@@ -387,12 +387,19 @@ dnageall(int doit)
 			if(dp->rr == 0 && dp->refs == 0){
 				assert(dp->magic == DNmagic);
 				*l = dp->next;
+
 				if(dp->name)
 					free(dp->name);
 				dp->magic = ~dp->magic;
 				dnvars.names--;
+				if (canqlock(&dp->querylck))
+					qunlock(&dp->querylck);
+				else
+					syslog(0, "dns",
+				    "dnageall: freeing DN with querylck held");
 				memset(dp, 0, sizeof *dp); /* cause trouble */
 				free(dp);
+
 				continue;
 			}
 			l = &dp->next;
@@ -1350,7 +1357,6 @@ void
 slave(Request *req)
 {
 	int ppid;
-	static int slaveid;
 
 	if(req->isslave)
 		return;		/* we're already a slave process */
@@ -1371,6 +1377,7 @@ slave(Request *req)
 		return;
 	}
 
+	/* parent returns to main loop, child does the work */
 	ppid = getpid();
 	switch(rfork(RFPROC|RFNOTEG|RFMEM|RFNOWAIT)){
 	case -1:
@@ -1384,6 +1391,11 @@ slave(Request *req)
 		req->isslave = 1;	/* why not `= getpid()'? */
 		break;
 	default:
+		/*
+		 * this relies on rfork producing separate, initially-identical
+		 * stacks, thus giving us two copies of `req', one in each
+		 * process.
+		 */
 		longjmp(req->mret, 1);
 	}
 }

+ 1 - 1
sys/src/cmd/ndb/dnnotify.c

@@ -78,7 +78,7 @@ send_notify(char *slave, RR *soa, Request *req)
 		rrfree(rp);
 	}
 
-	fd = udpport();
+	fd = udpport(nil);
 	if(fd < 0)
 		return;
 

+ 198 - 41
sys/src/cmd/ndb/dnresolve.c

@@ -1,7 +1,9 @@
 #include <u.h>
 #include <libc.h>
+#include <ip.h>
+#include <bio.h>
+#include <ndb.h>
 #include "dns.h"
-#include "ip.h"
 
 enum
 {
@@ -284,13 +286,13 @@ static char *hmsg = "headers";
 static char *ohmsg = "oldheaders";
 
 int
-udpport(void)
+udpport(char *mtpt)
 {
 	int fd, ctl;
 	char ds[64], adir[64];
 
 	/* get a udp port */
-	snprint(ds, sizeof(ds), "%s/udp!*!0", mntpt);
+	snprint(ds, sizeof ds, "%s/udp!*!0", (mtpt? mtpt: "/net"));
 	ctl = announce(ds, adir);
 	if(ctl < 0){
 		/* warning("can't get udp port"); */
@@ -306,11 +308,11 @@ udpport(void)
 	write(ctl, ohmsg, strlen(ohmsg));
 
 	/* grab the data file */
-	snprint(ds, sizeof(ds), "%s/data", adir);
+	snprint(ds, sizeof ds, "%s/data", adir);
 	fd = open(ds, ORDWR);
 	close(ctl);
 	if(fd < 0)
-		warning("can't open udp port: %r");
+		warning("can't open udp port %s: %r", ds);
 	return fd;
 }
 
@@ -475,11 +477,88 @@ ipisbm(uchar *ip)
 	return 0;
 }
 
+static Ndbtuple *indoms, *innmsrvs, *outnmsrvs;
+static QLock readlock;
+
+/*
+ * is this domain (or DOMAIN or Domain or dOMAIN)
+ * internal to our organisation (behind our firewall)?
+ */
+static int
+insideaddr(char *dom)
+{
+	int domlen, vallen;
+	Ndb *db;
+	Ndbs s;
+	Ndbtuple *t;
+
+	if (0 && indoms == nil) {	/* not ready for prime time */
+		db = ndbopen("/lib/ndb/local");
+		if (db != nil) {
+			qlock(&readlock);
+			if (indoms == nil) {	/* retest under lock */
+				free(ndbgetvalue(db, &s, "sys", "inside-dom",
+					"dom", &indoms));
+				free(ndbgetvalue(db, &s, "sys", "inside-ns",
+					"ip", &innmsrvs));
+				free(ndbgetvalue(db, &s, "sys", "outside-ns",
+					"ip", &outnmsrvs));
+			}
+			qunlock(&readlock);
+			ndbclose(db);	/* destroys *indoms, *innmsrvs? */
+		}
+	}
+	if (indoms == nil)
+		return 1;	/* no "inside" sys, try inside nameservers */
+
+	domlen = strlen(dom);
+	for (t = indoms; t != nil; t = t->entry) {
+		if (strcmp(t->attr, "dom") != 0)
+			continue;
+		vallen = strlen(t->val);
+		if (cistrcmp(dom, t->val) == 0 ||
+		    domlen > vallen &&
+		     cistrcmp(dom + domlen - vallen, t->val) == 0 &&
+		     dom[domlen - vallen - 1] == '.')
+			return 1;
+	}
+	return 0;
+}
+
+static int
+insidens(uchar *ip)
+{
+	uchar ipa[IPaddrlen];
+	Ndbtuple *t;
+
+	for (t = innmsrvs; t != nil; t = t->entry)
+		if (strcmp(t->attr, "ip") == 0) {
+			parseip(ipa, t->val);
+			if (memcmp(ipa, ip, sizeof ipa) == 0)
+				return 1;
+		}
+	return 0;
+}
+
+static uchar *
+outsidens(void)
+{
+	Ndbtuple *t;
+	static uchar ipa[IPaddrlen];
+
+	for (t = outnmsrvs; t != nil; t = t->entry)
+		if (strcmp(t->attr, "ip") == 0) {
+			parseip(ipa, t->val);
+			return ipa;
+		}
+	return nil;
+}
+
 /*
  *  Get next server address
  */
 static int
-serveraddrs(RR *nsrp, Dest *dest, int nd, int depth, Request *reqp)
+serveraddrs(DN *dp, RR *nsrp, Dest *dest, int nd, int depth, Request *reqp)
 {
 	RR *rp, *arp, *trp;
 	Dest *cur;
@@ -539,7 +618,8 @@ serveraddrs(RR *nsrp, Dest *dest, int nd, int depth, Request *reqp)
 			break;
 		cur = &dest[nd];
 		parseip(cur->a, trp->ip->name);
-		if(ipisbm(cur->a))
+		if (ipisbm(cur->a) ||
+		    !insideaddr(dp->name) && insidens(cur->a))
 			continue;
 		cur->nx = 0;
 		cur->s = trp->owner;
@@ -594,7 +674,7 @@ cacheneg(DN *dp, int type, int rcode, RR *soarr)
  */
 static int
 netquery1(int fd, DN *dp, int type, RR *nsrp, Request *reqp, int depth,
-	uchar *ibuf, uchar *obuf)
+	uchar *ibuf, uchar *obuf, int waitsecs, int inns)
 {
 	int ndest, j, len, replywaits, rv;
 	ulong endtime;
@@ -627,13 +707,25 @@ netquery1(int fd, DN *dp, int type, RR *nsrp, Request *reqp, int depth,
 
 		/* get a server address if we need one */
 		if(ndest > l - p){
-			j = serveraddrs(nsrp, dest, l - p, depth, reqp);
+			j = serveraddrs(dp, nsrp, dest, l - p, depth, reqp);
 			l = &dest[j];
 		}
 
 		/* no servers, punt */
 		if(l == dest)
-			break;
+			if (0 && inside) {	/* not ready for prime time */
+				/* HACK: use sys=outside ips */
+				if (0 && outsidens() == nil)
+					sysfatal("no outside-ns in ndb");
+				p = dest;
+				memmove(p->a, outsidens(), sizeof p->a);
+				p->s = dnlookup("outside", Cin, 1);
+				p->nx = p->code = 0;
+				l = p + 1;
+			} else {
+syslog(0, LOG, "netquery1: no servers for %s", dp->name);	// DEBUG
+				break;
+			}
 
 		/* send to first 'ndest' destinations */
 		j = 0;
@@ -648,13 +740,15 @@ netquery1(int fd, DN *dp, int type, RR *nsrp, Request *reqp, int depth,
 			if((1<<p->nx) > ndest)
 				continue;
 
-			procsetname("req slave: query to %I/%s %s %s",
-				obuf, p->s->name, dp->name,
-				rrname(type, buf, sizeof buf));
 			memmove(obuf, p->a, sizeof p->a);
+			procsetname("req slave: %sside query to %I/%s %s %s",
+				(inns? "in": "out"), obuf, p->s->name, dp->name,
+				rrname(type, buf, sizeof buf));
 			if(debug)
 				logsend(reqp->id, depth, obuf, p->s->name,
 					dp->name, type);
+
+			/* actually send the UDP packet */
 			if(write(fd, obuf, len + OUdphdrsize) < 0)
 				warning("sending udp msg %r");
 			p->nx++;
@@ -662,14 +756,15 @@ netquery1(int fd, DN *dp, int type, RR *nsrp, Request *reqp, int depth,
 		if(j == 0)
 			break;		/* no destinations left */
 
-		/* wait up to 5 seconds for replies */
-		endtime = time(0) + 5;
+		endtime = time(0) + waitsecs;
 		if(endtime > reqp->aborttime)
 			endtime = reqp->aborttime;
 
 		for(replywaits = 0; replywaits < ndest; replywaits++){
-			procsetname("req slave: reading reply from %I for %s %s",
-				obuf, dp->name, rrname(type, buf, sizeof buf));
+			procsetname(
+			    "req slave: reading %sside reply from %I for %s %s",
+				(inns? "in": "out"), obuf, dp->name,
+				rrname(type, buf, sizeof buf));
 			memset(&m, 0, sizeof m);
 			if(readreply(fd, dp, type, req, ibuf, &m, endtime, reqp) < 0)
 				break;		/* timed out */
@@ -721,7 +816,7 @@ netquery1(int fd, DN *dp, int type, RR *nsrp, Request *reqp, int depth,
 				ndp = m.ns->owner;
 				rrattach(m.ns, 0);
 			} else
-				ndp = 0;
+				ndp = nil;
 
 			/* free the question */
 			if(m.qd)
@@ -750,8 +845,10 @@ netquery1(int fd, DN *dp, int type, RR *nsrp, Request *reqp, int depth,
 			rrfreelist(soarr);
 
 			/*
-			 *  if we've been given better name servers
-			 *  recurse
+			 *  if we've been given better name servers,
+			 *  recurse.  we're called from udpquery, called from
+			 *  netquery, which current holds dp->querylck,
+			 *  so release it now and acquire it upon return.
 			 */
 			if(m.ns){
 				tp = rrlookup(ndp, Tns, NOneg);
@@ -760,8 +857,10 @@ netquery1(int fd, DN *dp, int type, RR *nsrp, Request *reqp, int depth,
 					 "req slave: recursive query for %s %s",
 						dp->name,
 						rrname(type, buf, sizeof buf));
+					qunlock(&dp->querylck);
 					rv = netquery(dp, type, tp, reqp,
 						depth + 1);
+					qlock(&dp->querylck);
 					rrfreelist(tp);
 					return rv;
 				} else
@@ -779,40 +878,98 @@ netquery1(int fd, DN *dp, int type, RR *nsrp, Request *reqp, int depth,
 	return 0;
 }
 
+enum { Hurry, Patient, };
+enum { Outns, Inns, };
+
 static int
-netquery(DN *dp, int type, RR *nsrp, Request *reqp, int depth)
+udpquery(char *mntpt, DN *dp, int type, RR *nsrp, Request *reqp, int depth,
+	int patient, int inns)
 {
-	int fd, rv;
-//	int pid;
+	int fd, rv = 0;
 	uchar *obuf, *ibuf;
-	RR *rp;
-
-	if(depth > 12)			/* in a recursive loop? */
-		return 0;
 
 	/* use alloced buffers rather than ones from the stack */
 	ibuf = emalloc(Maxudpin+OUdphdrsize);
 	obuf = emalloc(Maxudp+OUdphdrsize);
 
-//	pid = getpid();
-	slave(reqp);
-	/* parent process longjmped to req->mret; we're the child slave */
+	fd = udpport(mntpt);
+	if(fd >= 0) {
+		reqp->aborttime = time(0) + (patient? Maxreqtm: Maxreqtm/2);
+		rv = netquery1(fd, dp, type, nsrp, reqp, depth,
+			ibuf, obuf, (patient? 15: 10), inns);
+		close(fd);
+	}
+
+	free(obuf);
+	free(ibuf);
+	return rv;
+}
+
+/* look up (dp->name,type) via *nsrp with results in *reqp */
+static int
+netquery(DN *dp, int type, RR *nsrp, Request *reqp, int depth)
+{
+	int lock, rv, triedin;
+	RR *rp;
+
+	if(depth > 12)			/* in a recursive loop? */
+		return 0;
+
+	slave(reqp);			/* might fork */
+	/* if so, parent process longjmped to req->mret; we're child slave */
+	if (!reqp->isslave)
+		syslog(0, LOG,
+			"[%d] netquery: slave returned with reqp->isslave==0",
+			getpid());
+
+	/* don't lock before call to slave so only children can block */
+	lock = reqp->isslave != 0;
+	if(lock) {
+		procsetname("waiting for query lock on %s", dp->name);
+		/* don't make concurrent queries for this name */
+		qlock(&dp->querylck);
+		procsetname("netquery: %s", dp->name);
+	}
 
 	/* prepare server RR's for incremental lookup */
 	for(rp = nsrp; rp; rp = rp->next)
 		rp->marker = 0;
 
-//	if (pid != getpid())
-//		syslog(0, LOG, "[%d] netquery: forked child for %s",
-//			getpid(), dp->name);
-	fd = udpport();
-	if(fd < 0)
-		rv = 0;
-	else
-		rv = netquery1(fd, dp, type, nsrp, reqp, depth, ibuf, obuf);
-	close(fd);
-	free(ibuf);
-	free(obuf);
+	rv = 0;				/* pessimism */
+	triedin = 0;
+	/*
+	 * don't bother to query the broken inside nameservers for outside
+	 * addresses.
+	 */
+	if (!inside || insideaddr(dp->name)) {
+		rv = udpquery(mntpt, dp, type, nsrp, reqp, depth, Hurry,
+			(inside? Inns: Outns));
+		triedin = 1;
+	}
+
+	/*
+	 * if we're still looking and have an outside address,
+	 * try it on our outside interface, if any.
+	 */
+	if (rv == 0 && inside && !insideaddr(dp->name)) {
+		if (triedin)
+			syslog(0, LOG,
+	   "[%d] netquery: internal nameservers failed for %s; trying external",
+				getpid(), dp->name);
+
+		/* prepare server RR's for incremental lookup */
+		for(rp = nsrp; rp; rp = rp->next)
+			rp->marker = 0;
+
+		rv = udpquery("/net.alt", dp, type, nsrp, reqp, depth, Patient,
+			Outns);
+		if (rv == 0)
+			syslog(0, LOG, "[%d] netquery: no luck for %s",
+				getpid(), dp->name);
+	}
+
+	if(lock)
+		qunlock(&dp->querylck);
 
 	return rv;
 }

+ 12 - 8
sys/src/cmd/ndb/dns.c

@@ -11,7 +11,6 @@
 enum
 {
 	Maxrequest=		1024,
-	Maxpath=		128,
 	Maxreply=		512,
 	Maxrrr=			16,
 	Maxfdata=		8192,
@@ -64,6 +63,7 @@ struct {
 int	cachedb;
 int	debug;
 uchar	ipaddr[IPaddrlen];	/* my ip address */
+int	inside;
 int	maxage = Defmaxage;
 int	mfd[2];
 int	needrefresh;
@@ -116,7 +116,7 @@ main(int argc, char *argv[])
 	char	servefile[Maxpath], ext[Maxpath];
 
 	serve = 0;
-	setnetmtpt(mntpt, sizeof(mntpt), nil);
+	setnetmtpt(mntpt, sizeof mntpt, nil);
 	ext[0] = 0;
 	ARGBEGIN{
 	case 'a':
@@ -165,9 +165,11 @@ main(int argc, char *argv[])
 
 	if(testing)
 		mainmem->flags |= POOL_NOREUSE;
-//		mainmem->flags |= POOL_ANTAGONISM | POOL_PARANOIA;
+//	mainmem->flags |= POOL_ANTAGONISM | POOL_PARANOIA;	/* DEBUG */
 	rfork(RFREND|RFNOTEG);
 
+	inside = (*mntpt == '\0' || strcmp(mntpt, "/net") == 0);
+
 	/* start syslog before we fork */
 	fmtinstall('F', fcallfmt);
 	dninit();
@@ -733,7 +735,7 @@ rwrite(Job *job, Mfile *mf, Request *req)
 		status = neg->negrcode;
 		rrfreelist(neg);
 	}
-	if(rp == 0){
+	if(rp == 0)
 		switch(status){
 		case Rname:
 			err = "name does not exist";
@@ -745,19 +747,21 @@ rwrite(Job *job, Mfile *mf, Request *req)
 			err = "resource does not exist";
 			break;
 		}
-	} else {
+	else {
 		lock(&joblock);
 		if(!job->flushed){
 			/* format data to be read later */
 			n = 0;
 			mf->nrr = 0;
 			for(tp = rp; mf->nrr < Maxrrr-1 && n < Maxreply && tp &&
-					tsame(mf->type, tp->type); tp = tp->next){
+			    tsame(mf->type, tp->type); tp = tp->next){
 				mf->rr[mf->nrr++] = n;
 				if(wantsav)
-					n += snprint(mf->reply+n, Maxreply-n, "%Q", tp);
+					n += snprint(mf->reply+n, Maxreply-n,
+						"%Q", tp);
 				else
-					n += snprint(mf->reply+n, Maxreply-n, "%R", tp);
+					n += snprint(mf->reply+n, Maxreply-n,
+						"%R", tp);
 			}
 			mf->rr[mf->nrr] = n;
 		}

+ 5 - 1
sys/src/cmd/ndb/dns.h

@@ -137,6 +137,8 @@ enum
 	/* length of domain name hash table */
 	HTLEN= 		4*1024,
 
+	Maxpath=	128,	/* size of mntpt */
+
 	RRmagic=	0xdeadbabe,
 	DNmagic=	0xa110a110,
 
@@ -186,6 +188,7 @@ struct DN
 	char	refs;		/* for mark and sweep */
 	char	nonexistent;	/* true if we get an authoritative nx for this domain */
 	ulong	ordinal;
+	QLock	querylck;	/* permit only 1 query per domain name at a time */
 };
 
 /*
@@ -346,6 +349,7 @@ extern char	*dbfile;
 extern int	debug;
 extern Area	*delegated;
 extern char	*logfile;
+extern int	inside;
 extern int	maxage;		/* age of oldest entry in cache (secs) */
 extern char	mntpt[];
 extern int	needrefresh;
@@ -435,7 +439,7 @@ void	procsetname(char *fmt, ...);
 
 /* dnresolve.c */
 RR*	dnresolve(char*, int, int, Request*, RR**, int, int, int, int*);
-int	udpport(void);
+int	udpport(char *);
 int	mkreq(DN *dp, int type, uchar *buf, int flags, ushort reqno);
 
 /* dnserver.c */

+ 1 - 1
sys/src/cmd/ndb/dnsdebug.c

@@ -8,7 +8,6 @@
 
 enum {
 	Maxrequest=		128,
-	Maxpath=		128,
 };
 
 static char *servername;
@@ -19,6 +18,7 @@ int	cachedb;
 char	*dbfile;
 int	debug;
 uchar	ipaddr[IPaddrlen];	/* my ip address */
+int	inside;
 char	*logfile = "dns";
 int	maxage  = 60;
 char	mntpt[Maxpath];

+ 17 - 18
sys/src/cmd/ndb/dnstcp.c

@@ -1,27 +1,26 @@
+/*
+ * dnstcp - serve dns via tcp
+ */
 #include <u.h>
 #include <libc.h>
 #include <ip.h>
 #include "dns.h"
 
-enum
-{
-	Maxpath=		128,
-};
-
-char	*logfile = "dns";
+char	*LOG;
+int	cachedb = 1;
+char	*caller = "";
 char	*dbfile;
 int	debug;
-int	cachedb = 1;
-int	testing;
-int traceactivity;
-int	needrefresh;
-int 	resolver;
+uchar	ipaddr[IPaddrlen];	/* my ip address */
+int	inside;
+char	*logfile = "dns";
+int	maxage = 60;
 char	mntpt[Maxpath];
-char	*caller = "";
+int	needrefresh;
 ulong	now;
-int	maxage = 60;
-uchar	ipaddr[IPaddrlen];	/* my ip address */
-char	*LOG;
+int 	resolver;
+int	testing;
+int	traceactivity;
 char	*zonerefreshprogram;
 
 static int	readmsg(int, uchar*, int);
@@ -41,11 +40,11 @@ void
 main(int argc, char *argv[])
 {
 	int len, errflags;
-	Request req;
-	DNSmsg reqmsg, repmsg;
 	uchar buf[512];
 	char tname[32];
 	char *err, *ext = "";
+	Request req;
+	DNSmsg reqmsg, repmsg;
 
 	ARGBEGIN{
 	case 'd':
@@ -76,7 +75,7 @@ main(int argc, char *argv[])
 
 	dninit();
 
-	snprint(mntpt, sizeof(mntpt), "/net%s", ext);
+	snprint(mntpt, sizeof mntpt, "/net%s", ext);
 	if(myipaddr(ipaddr, mntpt) < 0)
 		sysfatal("can't read my ip address");
 	syslog(0, logfile, "dnstcp call from %s to %I", caller, ipaddr);

+ 4 - 1
sys/src/cmd/ndb/dnudpserver.c

@@ -97,11 +97,14 @@ restart:
 		close(fd);
 	while((fd = udpannounce(mntpt)) < 0)
 		sleep(5000);
+
+	procsetname("udp server loop");
 	memset(&req, 0, sizeof req);
 	if(setjmp(req.mret))
 		putactivity(0);
 	req.isslave = 0;
-	procsetname("udp server loop");
+	req.id = 0;
+	req.aborttime = 0;
 
 	/* loop on requests */
 	for(;; putactivity(0)){

+ 9 - 9
sys/src/cmd/ndb/query.c

@@ -1,11 +1,11 @@
+/*
+ *  search the network database for matches
+ */
 #include <u.h>
 #include <libc.h>
 #include <bio.h>
 #include <ndb.h>
 
-/*
- *  search the database for matches
- */
 void
 usage(void)
 {
@@ -16,10 +16,9 @@ usage(void)
 void
 search(Ndb *db, char *attr, char *val, char *rattr)
 {
-	Ndbs s;
-	Ndbtuple *t;
-	Ndbtuple *nt;
 	char *p;
+	Ndbs s;
+	Ndbtuple *t, *nt;
 
 	if(rattr){
 		p = ndbgetvalue(db, &s, attr, val, rattr, nil);
@@ -43,15 +42,16 @@ search(Ndb *db, char *attr, char *val, char *rattr)
 void
 main(int argc, char **argv)
 {
-	char *rattr = 0;
-	Ndb *db;
-	char *dbfile = 0;
 	int reps = 1;
+	char *rattr = nil, *dbfile = nil;
+	Ndb *db;
 
 	ARGBEGIN{
 	case 'f':
 		dbfile = ARGF();
 		break;
+	default:
+		usage();
 	}ARGEND;
 
 	switch(argc){