tdhcpd: fix build on OS X, silence non-log prints - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 417b681c0d94026da0ad0e79e8e50fe1613f9d65
 (DIR) parent 9eec023b8012162a4dfd78adcb94dea9d5439395
 (HTM) Author: Russ Cox <rsc@swtch.com>
       Date:   Sun, 13 Sep 2009 17:48:44 -0400
       
       dhcpd: fix build on OS X, silence non-log prints
       
       http://codereview.appspot.com/117064
       
       Diffstat:
         M src/cmd/ip/dhcpd/db.c               |       8 --------
         M src/cmd/ip/dhcpd/dhcpd.c            |       3 ++-
       
       2 files changed, 2 insertions(+), 9 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/ip/dhcpd/db.c b/src/cmd/ip/dhcpd/db.c
       t@@ -97,7 +97,6 @@ lockopen(char *file)
                        fd = open(file, OLOCK|ORDWR);
                        if(fd >= 0)
                                return fd;
       -print("open %s: %r\n", file);
                        errstr(err, sizeof err);
                        if(strstr(err, "lock")){
                                /* wait for other process to let go of lock */
       t@@ -297,8 +296,6 @@ idtobinding(char *id, Info *iip, int ping)
                        }
                }
        
       -print("looking for old for %I\n", iip->ipnet);
       -
                /*
                 *  look for oldest binding that we think is unused
                 */
       t@@ -306,7 +303,6 @@ print("looking for old for %I\n", iip->ipnet);
                        oldest = nil;
                        oldesttime = 0;
                        for(b = bcache; b; b = b->next){
       -print("tried %d now %d lease %d exp %d %I\n", b->tried, now, b->lease, b->expoffer, b->ip);
                                if(b->tried != now)
                                if(b->lease < now && b->expoffer < now && samenet(b->ip, iip))
                                if(oldest == nil || b->lasttouched < oldesttime){
       t@@ -315,7 +311,6 @@ print("tried %d now %d lease %d exp %d %I\n", b->tried, now, b->lease, b->expoff
                                        if(b->lease < now && b->expoffer < now && samenet(b->ip, iip))
                                        if(oldest == nil || b->lasttouched < oldesttime){
                                                oldest = b;
       -print("have oldest\n");
                                                oldesttime = b->lasttouched;
                                        }
                                }
       t@@ -325,7 +320,6 @@ print("have oldest\n");
        
                        /* make sure noone is still using it */
                        oldest->tried = now;
       -print("return oldest\n");
                        if(ping == 0 || icmpecho(oldest->ip) == 0)
                                return oldest;
        
       t@@ -378,11 +372,9 @@ idtooffer(char *id, Info *iip)
        
                /* look for an offer to this id */
                for(b = bcache; b; b = b->next){
       -print("%I %I ? offeredto %s id %s\n", b->ip, iip->ipnet, b->offeredto, id);
                        if(b->offeredto && strcmp(b->offeredto, id) == 0 && samenet(b->ip, iip)){
                                /* make sure some other system hasn't stolen it */
                                syncbinding(b, 0);
       -print("b->lease %d now %d boundto %s offered %s\n", b->lease, now, b->boundto, b->offeredto);
                                if(b->lease < now
                                || (b->boundto && strcmp(b->boundto, b->offeredto) == 0))
                                        return b;
 (DIR) diff --git a/src/cmd/ip/dhcpd/dhcpd.c b/src/cmd/ip/dhcpd/dhcpd.c
       t@@ -294,8 +294,10 @@ main(int argc, char **argv)
                fd = openlisten(net);
                wfd = fd;
                bwfd = fd;
       +#ifdef SO_BINDTODEVICE
                if(setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, "eth0", 5) < 0)
                        print("setsockopt: %r\n");
       +#endif
        
                for(;;){
                        memset(&r, 0, sizeof(r));
       t@@ -752,7 +754,6 @@ sendoffer(Req *rp, uchar *ip, int offer)
                 *  send
                 */
                n = rp->p - rp->buf;
       -print("OFFER: %I %I %d %d\n", rp->up->laddr, rp->up->raddr, nhgets(rp->up->lport), nhgets(rp->up->rport));
                if(!mute && udpwrite(fd, rp->up, rp->buf, n) != n)
                        warning(0, "offer: write failed: %r");
        }