dhcpd: fix build on OS X, silence non-log prints
http://codereview.appspot.com/117064
This commit is contained in:
parent
9eec023b80
commit
417b681c0d
2 changed files with 2 additions and 9 deletions
|
|
@ -97,7 +97,6 @@ lockopen(char *file)
|
||||||
fd = open(file, OLOCK|ORDWR);
|
fd = open(file, OLOCK|ORDWR);
|
||||||
if(fd >= 0)
|
if(fd >= 0)
|
||||||
return fd;
|
return fd;
|
||||||
print("open %s: %r\n", file);
|
|
||||||
errstr(err, sizeof err);
|
errstr(err, sizeof err);
|
||||||
if(strstr(err, "lock")){
|
if(strstr(err, "lock")){
|
||||||
/* wait for other process to let go of lock */
|
/* wait for other process to let go of lock */
|
||||||
|
|
@ -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
|
* look for oldest binding that we think is unused
|
||||||
*/
|
*/
|
||||||
|
|
@ -306,7 +303,6 @@ print("looking for old for %I\n", iip->ipnet);
|
||||||
oldest = nil;
|
oldest = nil;
|
||||||
oldesttime = 0;
|
oldesttime = 0;
|
||||||
for(b = bcache; b; b = b->next){
|
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->tried != now)
|
||||||
if(b->lease < now && b->expoffer < now && samenet(b->ip, iip))
|
if(b->lease < now && b->expoffer < now && samenet(b->ip, iip))
|
||||||
if(oldest == nil || b->lasttouched < oldesttime){
|
if(oldest == nil || b->lasttouched < oldesttime){
|
||||||
|
|
@ -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(b->lease < now && b->expoffer < now && samenet(b->ip, iip))
|
||||||
if(oldest == nil || b->lasttouched < oldesttime){
|
if(oldest == nil || b->lasttouched < oldesttime){
|
||||||
oldest = b;
|
oldest = b;
|
||||||
print("have oldest\n");
|
|
||||||
oldesttime = b->lasttouched;
|
oldesttime = b->lasttouched;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -325,7 +320,6 @@ print("have oldest\n");
|
||||||
|
|
||||||
/* make sure noone is still using it */
|
/* make sure noone is still using it */
|
||||||
oldest->tried = now;
|
oldest->tried = now;
|
||||||
print("return oldest\n");
|
|
||||||
if(ping == 0 || icmpecho(oldest->ip) == 0)
|
if(ping == 0 || icmpecho(oldest->ip) == 0)
|
||||||
return oldest;
|
return oldest;
|
||||||
|
|
||||||
|
|
@ -378,11 +372,9 @@ idtooffer(char *id, Info *iip)
|
||||||
|
|
||||||
/* look for an offer to this id */
|
/* look for an offer to this id */
|
||||||
for(b = bcache; b; b = b->next){
|
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)){
|
if(b->offeredto && strcmp(b->offeredto, id) == 0 && samenet(b->ip, iip)){
|
||||||
/* make sure some other system hasn't stolen it */
|
/* make sure some other system hasn't stolen it */
|
||||||
syncbinding(b, 0);
|
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
|
if(b->lease < now
|
||||||
|| (b->boundto && strcmp(b->boundto, b->offeredto) == 0))
|
|| (b->boundto && strcmp(b->boundto, b->offeredto) == 0))
|
||||||
return b;
|
return b;
|
||||||
|
|
|
||||||
|
|
@ -294,8 +294,10 @@ main(int argc, char **argv)
|
||||||
fd = openlisten(net);
|
fd = openlisten(net);
|
||||||
wfd = fd;
|
wfd = fd;
|
||||||
bwfd = fd;
|
bwfd = fd;
|
||||||
|
#ifdef SO_BINDTODEVICE
|
||||||
if(setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, "eth0", 5) < 0)
|
if(setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, "eth0", 5) < 0)
|
||||||
print("setsockopt: %r\n");
|
print("setsockopt: %r\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
for(;;){
|
for(;;){
|
||||||
memset(&r, 0, sizeof(r));
|
memset(&r, 0, sizeof(r));
|
||||||
|
|
@ -752,7 +754,6 @@ sendoffer(Req *rp, uchar *ip, int offer)
|
||||||
* send
|
* send
|
||||||
*/
|
*/
|
||||||
n = rp->p - rp->buf;
|
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)
|
if(!mute && udpwrite(fd, rp->up, rp->buf, n) != n)
|
||||||
warning(0, "offer: write failed: %r");
|
warning(0, "offer: write failed: %r");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue