projects
/
project
/
netifd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Only update resolv.conf if changed (avoid logspam)
[project/netifd.git]
/
interface-ip.c
diff --git
a/interface-ip.c
b/interface-ip.c
index
df2904f
..
fc5a4a3
100644
(file)
--- a/
interface-ip.c
+++ b/
interface-ip.c
@@
-781,10
+781,11
@@
interface_write_resolv_conf(void)
struct interface *iface;
char *path = alloca(strlen(resolv_conf) + 5);
FILE *f;
struct interface *iface;
char *path = alloca(strlen(resolv_conf) + 5);
FILE *f;
+ uint32_t crcold, crcnew;
sprintf(path, "%s.tmp", resolv_conf);
unlink(path);
sprintf(path, "%s.tmp", resolv_conf);
unlink(path);
- f = fopen(path, "w");
+ f = fopen(path, "w
+
");
if (!f) {
D(INTERFACE, "Failed to open %s for writing\n", path);
return;
if (!f) {
D(INTERFACE, "Failed to open %s for writing\n", path);
return;
@@
-805,8
+806,21
@@
interface_write_resolv_conf(void)
if (!iface->proto_ip.no_dns)
write_resolv_conf_entries(f, &iface->proto_ip);
}
if (!iface->proto_ip.no_dns)
write_resolv_conf_entries(f, &iface->proto_ip);
}
+ fflush(f);
+ rewind(f);
+ crcnew = crc32_file(f);
fclose(f);
fclose(f);
- if (rename(path, resolv_conf) < 0) {
+
+ crcold = crcnew + 1;
+ f = fopen(resolv_conf, "r");
+ if (f) {
+ crcold = crc32_file(f);
+ fclose(f);
+ }
+
+ if (crcold == crcnew) {
+ unlink(path);
+ } else if (rename(path, resolv_conf) < 0) {
D(INTERFACE, "Failed to replace %s\n", resolv_conf);
unlink(path);
}
D(INTERFACE, "Failed to replace %s\n", resolv_conf);
unlink(path);
}