Make fopen_temporary and fopen_temporary_label unlocked
This is partially a refactoring, but also makes many more places use unlocked operations implicitly, i.e. all users of fopen_temporary(). AFAICT, the uses are always for short-lived files which are not shared externally, and are just used within the same context. Locking is not necessary.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <net/if.h>
|
||||
#include <linux/if.h>
|
||||
#include <stdio_ext.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sd-network.h"
|
||||
@@ -1178,7 +1177,6 @@ int link_save_user(Link *l) {
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
(void) __fsetlocking(f, FSETLOCKING_BYCALLER);
|
||||
(void) fchmod(fileno(f), 0644);
|
||||
|
||||
fputs("# This is private data. Do not parse.\n", f);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include <resolv.h>
|
||||
#include <stdio_ext.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
@@ -359,14 +358,12 @@ int manager_write_resolv_conf(Manager *m) {
|
||||
if (r < 0)
|
||||
return log_warning_errno(r, "Failed to open private resolv.conf file for writing: %m");
|
||||
|
||||
(void) __fsetlocking(f_uplink, FSETLOCKING_BYCALLER);
|
||||
(void) fchmod(fileno(f_uplink), 0644);
|
||||
|
||||
r = fopen_temporary_label(PRIVATE_STUB_RESOLV_CONF, PRIVATE_STUB_RESOLV_CONF, &f_stub, &temp_path_stub);
|
||||
if (r < 0)
|
||||
return log_warning_errno(r, "Failed to open private stub-resolv.conf file for writing: %m");
|
||||
|
||||
(void) __fsetlocking(f_stub, FSETLOCKING_BYCALLER);
|
||||
(void) fchmod(fileno(f_stub), 0644);
|
||||
|
||||
r = write_uplink_resolv_conf_contents(f_uplink, dns, domains);
|
||||
|
||||
Reference in New Issue
Block a user