]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/ndb/dn.c
fix misleading/wrong fd checks
[plan9front.git] / sys / src / cmd / ndb / dn.c
index 684b25e16610e05d0f172be2287d4f16990035fe..f565a38fe653ae133c6dd292f069ad3635944d16 100644 (file)
@@ -228,11 +228,20 @@ idnlookup(char *name, int class, int enter)
 {
        char dom[Domlen];
 
-       if(utf2idn(name, dom, sizeof dom) != nil)
+       if(utf2idn(name, dom, sizeof dom) >= 0)
                name = dom;
        return dnlookup(name, class, enter);
 }
 
+DN*
+ipalookup(uchar *ip, int class, int enter)
+{
+       char addr[64];
+
+       snprint(addr, sizeof(addr), "%I", ip);
+       return dnlookup(addr, class, enter);
+}
+
 static int
 rrsame(RR *rr1, RR *rr2)
 {
@@ -672,8 +681,6 @@ getactivity(Request *req, int recursive)
 void
 putactivity(int recursive)
 {
-       static ulong lastclean;
-
        if(traceactivity)
                dnslog("put: %d active by pid %d",
                        dnvars.active, getpid());
@@ -706,7 +713,6 @@ putactivity(int recursive)
        dnageall(0);
 
        /* let others back in */
-       lastclean = now;
        needrefresh = 0;
        dnvars.mutex = 0;
 }
@@ -1166,7 +1172,7 @@ idnname(DN *dn, char *buf, int nbuf)
        char *name;
 
        name = dnname(dn);
-       if(idn2utf(name, buf, nbuf) != nil)
+       if(idn2utf(name, buf, nbuf) >= 0)
                return buf;
        return name;
 }
@@ -1460,31 +1466,6 @@ dnslog(char *fmt, ...)
        syslog(0, logfile, dnserr);
 }
 
-/*
- * based on libthread's threadsetname, but drags in less library code.
- * actually just sets the arguments displayed.
- */
-void
-procsetname(char *fmt, ...)
-{
-       int fd;
-       char *cmdname;
-       char buf[128];
-       va_list arg;
-
-       va_start(arg, fmt);
-       cmdname = vsmprint(fmt, arg);
-       va_end(arg);
-       if (cmdname == nil)
-               return;
-       snprint(buf, sizeof buf, "#p/%d/args", getpid());
-       if((fd = open(buf, OWRITE)) >= 0){
-               write(fd, cmdname, strlen(cmdname)+1);
-               close(fd);
-       }
-       free(cmdname);
-}
-
 /*
  *  create a slave process to handle a request to avoid one request blocking
  *  another