properly update database when the databases= line is changed. really. you need this. Reference: /n/atom/patch/applied2013/csdbline Date: Wed Sep 11 03:23:54 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/ndb/cs.c Wed Sep 11 03:23:37 2013 +++ /sys/src/cmd/ndb/cs.c Wed Sep 11 03:23:39 2013 @@ -167,7 +167,7 @@ /* * net doesn't apply to (r)udp, icmp(v6), or telco (for speed). - */ + */ Network network[] = { [Nilfast] { "il", iplookup, iptrans, 0, 1 }, [Ntcp] { "tcp", iplookup, iptrans, 0, 0 }, @@ -350,7 +350,7 @@ } void -ndbinit(void) +ndbinit0(void) { db = ndbopen(dbfile); if(db == nil) @@ -363,6 +363,25 @@ } } +void +ndbinit(void) +{ + long t; + static int once; + static long t0; + + t = time(0); + if(once == 0){ + ndbinit0(); + once = 1; + t0 = t; + } + else if(t - t0 > 30){ + db = ndbreopendb(db); + t0 = t; + } +} + Mfile* newfid(int fid) { @@ -822,6 +841,7 @@ } /* start transaction with a clean slate */ + ndbinit(); cleanmf(mf); /* @@ -1101,16 +1121,6 @@ if(strcmp(attr, "el") != 0) myelname = strdup(p); } - if(myelname == 0 && netdb != nil){ - ndbreopen(netdb); - for(tt = t = ndbparse(netdb); t != nil; t = t->entry){ - if(strcmp(t->attr, "el") == 0){ - mysysname = strdup(t->val); - break; - } - } - ndbfree(tt); - } if(myelname == 0){ snprint(buf, sizeof buf, "#l0/ether0/addr"); fd = open(buf, OREAD); @@ -1120,11 +1130,21 @@ } close(fd); } + if(mysysname == 0 && myelname != 0 && netdb != nil){ + ndbreopen(netdb); + for(tt = t = ndbparse(netdb); t != nil; t = t->entry){ + if(strcmp(t->attr, "el") == 0){ + mysysname = strdup(t->val); + break; + } + } + ndbfree(tt); + } if(myelname != nil){ fd = open("/net/el/ctl", OWRITE); if(fd != -1){ fprint(fd, "add %s", myelname); - fprint(fd, "bind ether #l0/ether0"); + // fprint(fd, "bind ether #l0/ether0"); if(mysysname != nil) fprint(fd, "arpattr add sysname %s", mysysname); close(fd);