LEFT | RIGHT |
(no file at all) | |
1 #include <u.h> | 1 #include <u.h> |
2 #include <libc.h> | 2 #include <libc.h> |
3 #include <ip.h> | 3 #include <ip.h> |
4 #include <ctype.h> | 4 #include <ctype.h> |
5 #include <bio.h> | 5 #include <bio.h> |
6 #include <ndb.h> | 6 #include <ndb.h> |
7 #include <thread.h> | 7 #include <thread.h> |
8 #include "dns.h" | 8 #include "dns.h" |
9 | 9 |
10 /* | 10 /* |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 rv = ++dnvars.active; | 455 rv = ++dnvars.active; |
456 now = time(0); | 456 now = time(0); |
457 req->id = ++dnvars.id; | 457 req->id = ++dnvars.id; |
458 unlock(&dnvars.lk); | 458 unlock(&dnvars.lk); |
459 | 459 |
460 return rv; | 460 return rv; |
461 } | 461 } |
462 void | 462 void |
463 putactivity(void) | 463 putactivity(void) |
464 { | 464 { |
465 static ulong lastclean; | |
466 | |
467 if(traceactivity) syslog(0, "dns", "put %d by %d.%d", dnvars.active, get
pid(), threadid()); | 465 if(traceactivity) syslog(0, "dns", "put %d by %d.%d", dnvars.active, get
pid(), threadid()); |
468 lock(&dnvars.lk); | 466 lock(&dnvars.lk); |
469 dnvars.active--; | 467 dnvars.active--; |
470 assert(dnvars.active >= 0); /* "dnvars.active %d", dnvars.active */; | 468 assert(dnvars.active >= 0); /* "dnvars.active %d", dnvars.active */; |
471 | 469 |
472 /* | 470 /* |
473 * clean out old entries and check for new db periodicly | 471 * clean out old entries and check for new db periodicly |
474 */ | 472 */ |
475 if(dnvars.mutex || (needrefresh == 0 && dnvars.active > 0)){ | 473 if(dnvars.mutex || (needrefresh == 0 && dnvars.active > 0)){ |
476 unlock(&dnvars.lk); | 474 unlock(&dnvars.lk); |
477 return; | 475 return; |
478 } | 476 } |
479 | 477 |
480 /* wait till we're alone */ | 478 /* wait till we're alone */ |
481 dnvars.mutex = 1; | 479 dnvars.mutex = 1; |
482 while(dnvars.active > 0){ | 480 while(dnvars.active > 0){ |
483 unlock(&dnvars.lk); | 481 unlock(&dnvars.lk); |
484 sleep(100); | 482 sleep(100); |
485 lock(&dnvars.lk); | 483 lock(&dnvars.lk); |
486 } | 484 } |
487 unlock(&dnvars.lk); | 485 unlock(&dnvars.lk); |
488 | 486 |
489 db2cache(needrefresh); | 487 db2cache(needrefresh); |
490 dnageall(0); | 488 dnageall(0); |
491 | 489 |
492 /* let others back in */ | 490 /* let others back in */ |
493 lastclean = now; | |
494 needrefresh = 0; | 491 needrefresh = 0; |
495 dnvars.mutex = 0; | 492 dnvars.mutex = 0; |
496 } | 493 } |
497 | 494 |
498 /* | 495 /* |
499 * Attach a single resource record to a domain name. | 496 * Attach a single resource record to a domain name. |
500 * - Avoid duplicates with already present RR's | 497 * - Avoid duplicates with already present RR's |
501 * - Chain all RR's of the same type adjacent to one another | 498 * - Chain all RR's of the same type adjacent to one another |
502 * - chain authoritative RR's ahead of non-authoritative ones | 499 * - chain authoritative RR's ahead of non-authoritative ones |
503 */ | 500 */ |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 Server* | 1562 Server* |
1566 copyserverlist(Server *s) | 1563 copyserverlist(Server *s) |
1567 { | 1564 { |
1568 Server *ns; | 1565 Server *ns; |
1569 | 1566 |
1570 ········ | 1567 ········ |
1571 for(ns = nil; s != nil; s = s->next) | 1568 for(ns = nil; s != nil; s = s->next) |
1572 addserver(&ns, s->name); | 1569 addserver(&ns, s->name); |
1573 return ns; | 1570 return ns; |
1574 } | 1571 } |
LEFT | RIGHT |