Dolda2000 GitWeb
/
ashd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6a7a868
)
dirplex: Merge children with identical names when reloading configuration.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 5 Sep 2010 04:04:36 +0000
(06:04 +0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sun, 5 Sep 2010 04:04:36 +0000
(06:04 +0200)
src/dirplex/conf.c
patch
|
blob
|
blame
|
history
diff --git
a/src/dirplex/conf.c
b/src/dirplex/conf.c
index
96a7704
..
ffa4313
100644
(file)
--- a/
src/dirplex/conf.c
+++ b/
src/dirplex/conf.c
@@
-240,9
+240,24
@@
struct config *readconfig(char *file)
return(cf);
}
return(cf);
}
+static void mergechildren(struct config *dst, struct config *src)
+{
+ struct child *ch1, *ch2;
+
+ for(ch1 = dst->children; ch1 != NULL; ch1 = ch1->next) {
+ for(ch2 = src->children; ch2 != NULL; ch2 = ch2->next) {
+ if(!strcmp(ch1->name, ch2->name)) {
+ ch1->fd = ch2->fd;
+ ch2->fd = -1;
+ break;
+ }
+ }
+ }
+}
+
struct config *getconfig(char *path)
{
struct config *getconfig(char *path)
{
- struct config *cf;
+ struct config *cf
, *ocf
;
struct stat sb;
char *fn;
time_t mtime;
struct stat sb;
char *fn;
time_t mtime;
@@
-251,15
+266,14
@@
struct config *getconfig(char *path)
for(cf = cflist; cf != NULL; cf = cf->next) {
if(!strcmp(cf->path, path)) {
if(now - cf->lastck > 5) {
for(cf = cflist; cf != NULL; cf = cf->next) {
if(!strcmp(cf->path, path)) {
if(now - cf->lastck > 5) {
- if(stat(fn, &sb) || (sb.st_mtime != cf->mtime)) {
- freeconfig(cf);
+ if(stat(fn, &sb) || (sb.st_mtime != cf->mtime))
break;
break;
- }
}
cf->lastck = now;
return(cf);
}
}
}
cf->lastck = now;
return(cf);
}
}
+ ocf = cf;
if(access(fn, R_OK) || stat(fn, &sb)) {
cf = emptyconfig();
mtime = 0;
if(access(fn, R_OK) || stat(fn, &sb)) {
cf = emptyconfig();
mtime = 0;
@@
-268,6
+282,10
@@
struct config *getconfig(char *path)
return(NULL);
mtime = sb.st_mtime;
}
return(NULL);
mtime = sb.st_mtime;
}
+ if(ocf != NULL) {
+ mergechildren(cf, ocf);
+ freeconfig(ocf);
+ }
cf->path = sstrdup(path);
cf->mtime = mtime;
cf->lastck = now;
cf->path = sstrdup(path);
cf->mtime = mtime;
cf->lastck = now;