]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: fput[cs]() → fput[cs]_unlocked() wherever that makes sense (#6396)
authorLennart Poettering <lennart@poettering.net>
Fri, 21 Jul 2017 08:35:45 +0000 (10:35 +0200)
committerGitHub <noreply@github.com>
Fri, 21 Jul 2017 08:35:45 +0000 (10:35 +0200)
As a follow-up for db3f45e2d2586d78f942a43e661415bc50716d11 let's do the
same for all other cases where we create a FILE* with local scope and
know that no other threads hence can have access to it.

For most cases this shouldn't change much really, but this should speed
dbus introspection and calender time formatting up a bit.

23 files changed:
src/basic/calendarspec.c
src/basic/fileio.c
src/core/dbus-cgroup.c
src/core/dbus-service.c
src/core/manager.c
src/core/smack-setup.c
src/coredump/coredump.c
src/coredump/stacktrace.c
src/cryptsetup/cryptsetup-generator.c
src/fstab-generator/fstab-generator.c
src/journal/journal-qrcode.c
src/libsystemd-network/sd-dhcp-lease.c
src/libsystemd/sd-bus/bus-introspect.c
src/libsystemd/sd-bus/bus-match.c
src/libsystemd/sd-bus/bus-objects.c
src/locale/keymap-util.c
src/login/logind-seat.c
src/login/logind-user.c
src/machine/machine.c
src/network/networkd-link.c
src/network/networkd-manager.c
src/resolve/resolved-link.c
src/resolve/resolved-resolv-conf.c

index 204120ee0e939bcf11716c11b88631860d55cdfc..b0712a4bada7e44c2b3dc5c315169a351dcde9d5 100644 (file)
@@ -257,19 +257,19 @@ static void format_weekdays(FILE *f, const CalendarSpec *c) {
 
                         if (l < 0) {
                                 if (need_comma)
-                                        fputc(',', f);
+                                        fputc_unlocked(',', f);
                                 else
                                         need_comma = true;
 
-                                fputs(days[x], f);
+                                fputs_unlocked(days[x], f);
                                 l = x;
                         }
 
                 } else if (l >= 0) {
 
                         if (x > l + 1) {
-                                fputs(x > l + 2 ? ".." : ",", f);
-                                fputs(days[x-1], f);
+                                fputs_unlocked(x > l + 2 ? ".." : ",", f);
+                                fputs_unlocked(days[x-1], f);
                         }
 
                         l = -1;
@@ -277,8 +277,8 @@ static void format_weekdays(FILE *f, const CalendarSpec *c) {
         }
 
         if (l >= 0 && x > l + 1) {
-                fputs(x > l + 2 ? ".." : ",", f);
-                fputs(days[x-1], f);
+                fputs_unlocked(x > l + 2 ? ".." : ",", f);
+                fputs_unlocked(days[x-1], f);
         }
 }
 
@@ -288,12 +288,12 @@ static void format_chain(FILE *f, int space, const CalendarComponent *c, bool us
         assert(f);
 
         if (!c) {
-                fputc('*', f);
+                fputc_unlocked('*', f);
                 return;
         }
 
         if (usec && c->start == 0 && c->repeat == USEC_PER_SEC && !c->next) {
-                fputc('*', f);
+                fputc_unlocked('*', f);
                 return;
         }
 
@@ -314,7 +314,7 @@ static void format_chain(FILE *f, int space, const CalendarComponent *c, bool us
                 fprintf(f, ".%06i", c->repeat % d);
 
         if (c->next) {
-                fputc(',', f);
+                fputc_unlocked(',', f);
                 format_chain(f, space, c->next, usec);
         }
 }
@@ -334,23 +334,23 @@ int calendar_spec_to_string(const CalendarSpec *c, char **p) {
 
         if (c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS) {
                 format_weekdays(f, c);
-                fputc(' ', f);
+                fputc_unlocked(' ', f);
         }
 
         format_chain(f, 4, c->year, false);
-        fputc('-', f);
+        fputc_unlocked('-', f);
         format_chain(f, 2, c->month, false);
-        fputc(c->end_of_month ? '~' : '-', f);
+        fputc_unlocked(c->end_of_month ? '~' : '-', f);
         format_chain(f, 2, c->day, false);
-        fputc(' ', f);
+        fputc_unlocked(' ', f);
         format_chain(f, 2, c->hour, false);
-        fputc(':', f);
+        fputc_unlocked(':', f);
         format_chain(f, 2, c->minute, false);
-        fputc(':', f);
+        fputc_unlocked(':', f);
         format_chain(f, 2, c->microsecond, true);
 
         if (c->utc)
-                fputs(" UTC", f);
+                fputs_unlocked(" UTC", f);
         else if (IN_SET(c->dst, 0, 1)) {
 
                 /* If daylight saving is explicitly on or off, let's show the used timezone. */
@@ -358,8 +358,8 @@ int calendar_spec_to_string(const CalendarSpec *c, char **p) {
                 tzset();
 
                 if (!isempty(tzname[c->dst])) {
-                        fputc(' ', f);
-                        fputs(tzname[c->dst], f);
+                        fputc_unlocked(' ', f);
+                        fputs_unlocked(tzname[c->dst], f);
                 }
         }
 
index 0678db4a7bac3707a6f8ed33f7b7eab6eb7a7843..a0250385880a8027c9c46eec69432fc211366bc4 100644 (file)
@@ -824,29 +824,29 @@ static void write_env_var(FILE *f, const char *v) {
         p = strchr(v, '=');
         if (!p) {
                 /* Fallback */
-                fputs(v, f);
-                fputc('\n', f);
+                fputs_unlocked(v, f);
+                fputc_unlocked('\n', f);
                 return;
         }
 
         p++;
-        fwrite(v, 1, p-v, f);
+        fwrite_unlocked(v, 1, p-v, f);
 
         if (string_has_cc(p, NULL) || chars_intersect(p, WHITESPACE SHELL_NEED_QUOTES)) {
-                fputc('\"', f);
+                fputc_unlocked('\"', f);
 
                 for (; *p; p++) {
                         if (strchr(SHELL_NEED_ESCAPE, *p))
-                                fputc('\\', f);
+                                fputc_unlocked('\\', f);
 
-                        fputc(*p, f);
+                        fputc_unlocked(*p, f);
                 }
 
-                fputc('\"', f);
+                fputc_unlocked('\"', f);
         } else
-                fputs(p, f);
+                fputs_unlocked(p, f);
 
-        fputc('\n', f);
+        fputc_unlocked('\n', f);
 }
 
 int write_env_file(const char *fname, char **l) {
index 12d3ca076bdee0dac6ce014acca64614d4c689f3..4e6d1effaa804dda5da3da7e3dc25303d49ad0eb 100644 (file)
@@ -625,7 +625,7 @@ int bus_cgroup_set_property(
                         if (!f)
                                 return -ENOMEM;
 
-                        fputs("IODeviceWeight=\n", f);
+                        fputs_unlocked("IODeviceWeight=\n", f);
                         LIST_FOREACH(device_weights, a, c->io_device_weights)
                                 fprintf(f, "IODeviceWeight=%s %" PRIu64 "\n", a->path, a->weight);
 
@@ -774,12 +774,12 @@ int bus_cgroup_set_property(
                                 return -ENOMEM;
 
                         if (read) {
-                                fputs("BlockIOReadBandwidth=\n", f);
+                                fputs_unlocked("BlockIOReadBandwidth=\n", f);
                                 LIST_FOREACH(device_bandwidths, a, c->blockio_device_bandwidths)
                                         if (a->rbps != CGROUP_LIMIT_MAX)
                                                 fprintf(f, "BlockIOReadBandwidth=%s %" PRIu64 "\n", a->path, a->rbps);
                         } else {
-                                fputs("BlockIOWriteBandwidth=\n", f);
+                                fputs_unlocked("BlockIOWriteBandwidth=\n", f);
                                 LIST_FOREACH(device_bandwidths, a, c->blockio_device_bandwidths)
                                         if (a->wbps != CGROUP_LIMIT_MAX)
                                                 fprintf(f, "BlockIOWriteBandwidth=%s %" PRIu64 "\n", a->path, a->wbps);
@@ -857,7 +857,7 @@ int bus_cgroup_set_property(
                         if (!f)
                                 return -ENOMEM;
 
-                        fputs("BlockIODeviceWeight=\n", f);
+                        fputs_unlocked("BlockIODeviceWeight=\n", f);
                         LIST_FOREACH(device_weights, a, c->blockio_device_weights)
                                 fprintf(f, "BlockIODeviceWeight=%s %" PRIu64 "\n", a->path, a->weight);
 
@@ -1086,7 +1086,7 @@ int bus_cgroup_set_property(
                         if (!f)
                                 return -ENOMEM;
 
-                        fputs("DeviceAllow=\n", f);
+                        fputs_unlocked("DeviceAllow=\n", f);
                         LIST_FOREACH(device_allow, a, c->device_allow)
                                 fprintf(f, "DeviceAllow=%s %s%s%s\n", a->path, a->r ? "r" : "", a->w ? "w" : "", a->m ? "m" : "");
 
index 6458ee5c121c45c5ffd361ae137f7754b114743a..a20d4b3b99a3956145c40d358d72a436792b6db7 100644 (file)
@@ -308,7 +308,7 @@ static int bus_service_set_transient_property(
                         if (!f)
                                 return -ENOMEM;
 
-                        fputs("ExecStart=\n", f);
+                        fputs_unlocked("ExecStart=\n", f);
 
                         LIST_FOREACH(command, c, s->exec_command[SERVICE_EXEC_START]) {
                                 _cleanup_free_ char *a;
index 63893243913262f1b612883f4cc39ee3097e85fb..d29acf500fd741b7e0c626e216bd2a9c18c8c758 100644 (file)
@@ -2592,15 +2592,15 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root) {
         manager_serialize_uid_refs(m, f);
         manager_serialize_gid_refs(m, f);
 
-        fputc('\n', f);
+        fputc_unlocked('\n', f);
 
         HASHMAP_FOREACH_KEY(u, t, m->units, i) {
                 if (u->id != t)
                         continue;
 
                 /* Start marker */
-                fputs(u->id, f);
-                fputc('\n', f);
+                fputs_unlocked(u->id, f);
+                fputc_unlocked('\n', f);
 
                 r = unit_serialize(u, f, fds, !switching_root);
                 if (r < 0) {
index adf22931422c8f30fb4c1b22c9037e2a2587e0fb..9f253643351f24d10898ee0fda5de5e6b5375930 100644 (file)
@@ -246,7 +246,7 @@ static int write_netlabel_rules(const char* srcdir) {
                 FOREACH_LINE(buf, policy,
                              log_error_errno(errno, "Failed to read line from %s: %m",
                                        entry->d_name)) {
-                        if (!fputs(buf, dst)) {
+                        if (!fputs_unlocked(buf, dst)) {
                                 if (r == 0)
                                         r = -EINVAL;
                                 log_error_errno(errno, "Failed to write line to /sys/fs/smackfs/netlabel");
index a2c62e55a5f231915549b987000e2c1e5e304798..57d1af454a3e424bc3454572c2bfc8e8ed79a98b 100644 (file)
@@ -564,7 +564,7 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
                 }
 
                 FOREACH_LINE(line, fdinfo, break) {
-                        fputs(line, stream);
+                        fputs_unlocked(line, stream);
                         if (!endswith(line, "\n"))
                                 fputc('\n', stream);
                 }
index 778bee9b12956e3a818703da6ae8b4882804dd94..1726613623c6f929fc364e4b55f1e4aea032709b 100644 (file)
@@ -107,7 +107,7 @@ static int thread_callback(Dwfl_Thread *thread, void *userdata) {
                 return DWARF_CB_ABORT;
 
         if (c->n_thread != 0)
-                fputc('\n', c->f);
+                fputc_unlocked('\n', c->f);
 
         c->n_frame = 0;
 
index 3fdf65be6552bcaaf0a05c5615a18569f9d26326..cd07f2abd98eda6eaf9cfb9ad585789d3dfd83df 100644 (file)
@@ -102,17 +102,17 @@ static int create_disk(
         if (!f)
                 return log_error_errno(errno, "Failed to create unit file %s: %m", p);
 
-        fputs("# Automatically generated by systemd-cryptsetup-generator\n\n"
-              "[Unit]\n"
-              "Description=Cryptography Setup for %I\n"
-              "Documentation=man:crypttab(5) man:systemd-cryptsetup-generator(8) man:systemd-cryptsetup@.service(8)\n"
-              "SourcePath=/etc/crypttab\n"
-              "DefaultDependencies=no\n"
-              "Conflicts=umount.target\n"
-              "BindsTo=dev-mapper-%i.device\n"
-              "IgnoreOnIsolate=true\n"
-              "After=cryptsetup-pre.target\n",
-              f);
+        fputs_unlocked("# Automatically generated by systemd-cryptsetup-generator\n\n"
+                       "[Unit]\n"
+                       "Description=Cryptography Setup for %I\n"
+                       "Documentation=man:crypttab(5) man:systemd-cryptsetup-generator(8) man:systemd-cryptsetup@.service(8)\n"
+                       "SourcePath=/etc/crypttab\n"
+                       "DefaultDependencies=no\n"
+                       "Conflicts=umount.target\n"
+                       "BindsTo=dev-mapper-%i.device\n"
+                       "IgnoreOnIsolate=true\n"
+                       "After=cryptsetup-pre.target\n",
+                       f);
 
         if (!nofail)
                 fprintf(f,
@@ -120,7 +120,7 @@ static int create_disk(
 
         if (password) {
                 if (STR_IN_SET(password, "/dev/urandom", "/dev/random", "/dev/hw_random"))
-                        fputs("After=systemd-random-seed.service\n", f);
+                        fputs_unlocked("After=systemd-random-seed.service\n", f);
                 else if (!STR_IN_SET(password, "-", "none")) {
                         _cleanup_free_ char *uu;
 
@@ -152,8 +152,8 @@ static int create_disk(
                         d, d);
 
                 if (swap)
-                        fputs("Before=dev-mapper-%i.swap\n",
-                              f);
+                        fputs_unlocked("Before=dev-mapper-%i.swap\n",
+                                       f);
         } else
                 fprintf(f,
                         "RequiresMountsFor=%s\n",
index 8fc4c8d179e33b80b5c80eb45c93d390c4cdcc77..ec70a349fcff990dd8104598a970b2f7d9b87d3f 100644 (file)
@@ -125,11 +125,11 @@ static int add_swap(
                                        "Failed to create unit file %s: %m",
                                        unit);
 
-        fputs("# Automatically generated by systemd-fstab-generator\n\n"
-              "[Unit]\n"
-              "SourcePath=/etc/fstab\n"
-              "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n\n"
-              "[Swap]\n", f);
+        fputs_unlocked("# Automatically generated by systemd-fstab-generator\n\n"
+                       "[Unit]\n"
+                       "SourcePath=/etc/fstab\n"
+                       "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n\n"
+                       "[Swap]\n", f);
 
         r = write_what(f, what);
         if (r < 0)
index 5ee10498d10a00e2b014706c0b5954279fc2309a..4e194bd809eefc7ef955adcff1b9b3563c4c61c2 100644 (file)
@@ -65,11 +65,11 @@ int print_qr_code(
         if (!f)
                 return -ENOMEM;
 
-        fputs("fss://", f);
+        fputs_unlocked("fss://", f);
 
         for (i = 0; i < seed_size; i++) {
                 if (i > 0 && i % 3 == 0)
-                        fputc('-', f);
+                        fputc_unlocked('-', f);
                 fprintf(f, "%02x", ((uint8_t*) seed)[i]);
         }
 
index 1661874a55bb422f75d8fcbd6d1aabe325351128..6f0e51720a118ddca387b20739fc380bd015a1ad 100644 (file)
@@ -926,16 +926,16 @@ int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
 
         r = sd_dhcp_lease_get_dns(lease, &addresses);
         if (r > 0) {
-                fputs("DNS=", f);
+                fputs_unlocked("DNS=", f);
                 serialize_in_addrs(f, addresses, r);
-                fputs("\n", f);
+                fputs_unlocked("\n", f);
         }
 
         r = sd_dhcp_lease_get_ntp(lease, &addresses);
         if (r > 0) {
-                fputs("NTP=", f);
+                fputs_unlocked("NTP=", f);
                 serialize_in_addrs(f, addresses, r);
-                fputs("\n", f);
+                fputs_unlocked("\n", f);
         }
 
         r = sd_dhcp_lease_get_domainname(lease, &string);
@@ -944,9 +944,9 @@ int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
 
         r = sd_dhcp_lease_get_search_domains(lease, &search_domains);
         if (r > 0) {
-                fputs("DOMAIN_SEARCH_LIST=", f);
+                fputs_unlocked("DOMAIN_SEARCH_LIST=", f);
                 fputstrv(f, search_domains, NULL, NULL);
-                fputs("\n", f);
+                fputs_unlocked("\n", f);
         }
 
         r = sd_dhcp_lease_get_hostname(lease, &string);
index 8f93edb8dae317c30f1cdb9393da6f7273ed0b32..5dab4a9af3b1c547f43b423149323cf870ddf432 100644 (file)
@@ -36,8 +36,8 @@ int introspect_begin(struct introspect *i, bool trusted) {
         if (!i->f)
                 return -ENOMEM;
 
-        fputs(BUS_INTROSPECT_DOCTYPE
-              "<node>\n", i->f);
+        fputs_unlocked(BUS_INTROSPECT_DOCTYPE
+                       "<node>\n", i->f);
 
         return 0;
 }
@@ -45,12 +45,12 @@ int introspect_begin(struct introspect *i, bool trusted) {
 int introspect_write_default_interfaces(struct introspect *i, bool object_manager) {
         assert(i);
 
-        fputs(BUS_INTROSPECT_INTERFACE_PEER
-              BUS_INTROSPECT_INTERFACE_INTROSPECTABLE
-              BUS_INTROSPECT_INTERFACE_PROPERTIES, i->f);
+        fputs_unlocked(BUS_INTROSPECT_INTERFACE_PEER
+                       BUS_INTROSPECT_INTERFACE_INTROSPECTABLE
+                       BUS_INTROSPECT_INTERFACE_PROPERTIES, i->f);
 
         if (object_manager)
-                fputs(BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER, i->f);
+                fputs_unlocked(BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER, i->f);
 
         return 0;
 }
@@ -76,27 +76,27 @@ int introspect_write_child_nodes(struct introspect *i, Set *s, const char *prefi
 
 static void introspect_write_flags(struct introspect *i, int type, int flags) {
         if (flags & SD_BUS_VTABLE_DEPRECATED)
-                fputs("   <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f);
+                fputs_unlocked("   <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f);
 
         if (type == _SD_BUS_VTABLE_METHOD && (flags & SD_BUS_VTABLE_METHOD_NO_REPLY))
-                fputs("   <annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>\n", i->f);
+                fputs_unlocked("   <annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>\n", i->f);
 
         if (type == _SD_BUS_VTABLE_PROPERTY || type == _SD_BUS_VTABLE_WRITABLE_PROPERTY) {
                 if (flags & SD_BUS_VTABLE_PROPERTY_EXPLICIT)
-                        fputs("   <annotation name=\"org.freedesktop.systemd1.Explicit\" value=\"true\"/>\n", i->f);
+                        fputs_unlocked("   <annotation name=\"org.freedesktop.systemd1.Explicit\" value=\"true\"/>\n", i->f);
 
                 if (flags & SD_BUS_VTABLE_PROPERTY_CONST)
-                        fputs("   <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"const\"/>\n", i->f);
+                        fputs_unlocked("   <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"const\"/>\n", i->f);
                 else if (flags & SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION)
-                        fputs("   <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"invalidates\"/>\n", i->f);
+                        fputs_unlocked("   <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"invalidates\"/>\n", i->f);
                 else if (!(flags & SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE))
-                        fputs("   <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"false\"/>\n", i->f);
+                        fputs_unlocked("   <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"false\"/>\n", i->f);
         }
 
         if (!i->trusted &&
             (type == _SD_BUS_VTABLE_METHOD || type == _SD_BUS_VTABLE_WRITABLE_PROPERTY) &&
             !(flags & SD_BUS_VTABLE_UNPRIVILEGED))
-                fputs("   <annotation name=\"org.freedesktop.systemd1.Privileged\" value=\"true\"/>\n", i->f);
+                fputs_unlocked("   <annotation name=\"org.freedesktop.systemd1.Privileged\" value=\"true\"/>\n", i->f);
 }
 
 static int introspect_write_arguments(struct introspect *i, const char *signature, const char *direction) {
@@ -117,7 +117,7 @@ static int introspect_write_arguments(struct introspect *i, const char *signatur
                 if (direction)
                         fprintf(i->f, " direction=\"%s\"/>\n", direction);
                 else
-                        fputs("/>\n", i->f);
+                        fputs_unlocked("/>\n", i->f);
 
                 signature += l;
         }
@@ -140,7 +140,7 @@ int introspect_write_interface(struct introspect *i, const sd_bus_vtable *v) {
 
                 case _SD_BUS_VTABLE_START:
                         if (v->flags & SD_BUS_VTABLE_DEPRECATED)
-                                fputs("  <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f);
+                                fputs_unlocked("  <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f);
                         break;
 
                 case _SD_BUS_VTABLE_METHOD:
@@ -148,7 +148,7 @@ int introspect_write_interface(struct introspect *i, const sd_bus_vtable *v) {
                         introspect_write_arguments(i, strempty(v->x.method.signature), "in");
                         introspect_write_arguments(i, strempty(v->x.method.result), "out");
                         introspect_write_flags(i, v->type, v->flags);
-                        fputs("  </method>\n", i->f);
+                        fputs_unlocked("  </method>\n", i->f);
                         break;
 
                 case _SD_BUS_VTABLE_PROPERTY:
@@ -158,14 +158,14 @@ int introspect_write_interface(struct introspect *i, const sd_bus_vtable *v) {
                                 v->x.property.signature,
                                 v->type == _SD_BUS_VTABLE_WRITABLE_PROPERTY ? "readwrite" : "read");
                         introspect_write_flags(i, v->type, v->flags);
-                        fputs("  </property>\n", i->f);
+                        fputs_unlocked("  </property>\n", i->f);
                         break;
 
                 case _SD_BUS_VTABLE_SIGNAL:
                         fprintf(i->f, "  <signal name=\"%s\">\n", v->x.signal.member);
                         introspect_write_arguments(i, strempty(v->x.signal.signature), NULL);
                         introspect_write_flags(i, v->type, v->flags);
-                        fputs("  </signal>\n", i->f);
+                        fputs_unlocked("  </signal>\n", i->f);
                         break;
                 }
 
@@ -182,7 +182,7 @@ int introspect_finish(struct introspect *i, sd_bus *bus, sd_bus_message *m, sd_b
         assert(m);
         assert(reply);
 
-        fputs("</node>\n", i->f);
+        fputs_unlocked("</node>\n", i->f);
 
         r = fflush_and_check(i->f);
         if (r < 0)
index db01f211355efedf6956f8bedfeaab0281c672e9..02587a3e8d565b112550348107717402e0d5e3d5 100644 (file)
@@ -957,18 +957,18 @@ char *bus_match_to_string(struct bus_match_component *components, unsigned n_com
                 char buf[32];
 
                 if (i != 0)
-                        fputc(',', f);
+                        fputc_unlocked(',', f);
 
-                fputs(bus_match_node_type_to_string(components[i].type, buf, sizeof(buf)), f);
-                fputc('=', f);
-                fputc('\'', f);
+                fputs_unlocked(bus_match_node_type_to_string(components[i].type, buf, sizeof(buf)), f);
+                fputc_unlocked('=', f);
+                fputc_unlocked('\'', f);
 
                 if (components[i].type == BUS_MATCH_MESSAGE_TYPE)
-                        fputs(bus_message_type_to_string(components[i].value_u8), f);
+                        fputs_unlocked(bus_message_type_to_string(components[i].value_u8), f);
                 else
-                        fputs(components[i].value_str, f);
+                        fputs_unlocked(components[i].value_str, f);
 
-                fputc('\'', f);
+                fputc_unlocked('\'', f);
         }
 
         r = fflush_and_check(f);
index 98911d520366004e04bedeffec522e65d1199363..bb06d302ca13d9ae820403d6db6c72a6b51b9522 100644 (file)
@@ -955,7 +955,7 @@ static int process_introspect(
                 if (!streq_ptr(previous_interface, c->interface)) {
 
                         if (previous_interface)
-                                fputs(" </interface>\n", intro.f);
+                                fputs_unlocked(" </interface>\n", intro.f);
 
                         fprintf(intro.f, " <interface name=\"%s\">\n", c->interface);
                 }
@@ -968,7 +968,7 @@ static int process_introspect(
         }
 
         if (previous_interface)
-                fputs(" </interface>\n", intro.f);
+                fputs_unlocked(" </interface>\n", intro.f);
 
         if (empty) {
                 /* Nothing?, let's see if we exist at all, and if not
index 105d9b0ee4c86d9afbf97065d0e66ca4bc44c804..ec48e8ba6d5ff709586061959b2532fece06a384 100644 (file)
@@ -361,12 +361,12 @@ int x11_write_data(Context *c) {
 
         fchmod(fileno(f), 0644);
 
-        fputs("# Written by systemd-localed(8), read by systemd-localed and Xorg. It's\n"
-              "# probably wise not to edit this file manually. Use localectl(1) to\n"
-              "# instruct systemd-localed to update it.\n"
-              "Section \"InputClass\"\n"
-              "        Identifier \"system-keyboard\"\n"
-              "        MatchIsKeyboard \"on\"\n", f);
+        fputs_unlocked("# Written by systemd-localed(8), read by systemd-localed and Xorg. It's\n"
+                       "# probably wise not to edit this file manually. Use localectl(1) to\n"
+                       "# instruct systemd-localed to update it.\n"
+                       "Section \"InputClass\"\n"
+                       "        Identifier \"system-keyboard\"\n"
+                       "        MatchIsKeyboard \"on\"\n", f);
 
         if (!isempty(c->x11_layout))
                 fprintf(f, "        Option \"XkbLayout\" \"%s\"\n", c->x11_layout);
@@ -380,7 +380,7 @@ int x11_write_data(Context *c) {
         if (!isempty(c->x11_options))
                 fprintf(f, "        Option \"XkbOptions\" \"%s\"\n", c->x11_options);
 
-        fputs("EndSection\n", f);
+        fputs_unlocked("EndSection\n", f);
 
         r = fflush_and_check(f);
         if (r < 0)
index 30dac7997b8d6a787b35c8fabf5e7a94c1ff6afe..85258737c3209acfbec1c8f5f0e552d5e23157aa 100644 (file)
@@ -127,7 +127,7 @@ int seat_save(Seat *s) {
         if (s->sessions) {
                 Session *i;
 
-                fputs("SESSIONS=", f);
+                fputs_unlocked("SESSIONS=", f);
                 LIST_FOREACH(sessions_by_seat, i, s->sessions) {
                         fprintf(f,
                                 "%s%c",
@@ -135,7 +135,7 @@ int seat_save(Seat *s) {
                                 i->sessions_by_seat_next ? ' ' : '\n');
                 }
 
-                fputs("UIDS=", f);
+                fputs_unlocked("UIDS=", f);
                 LIST_FOREACH(sessions_by_seat, i, s->sessions)
                         fprintf(f,
                                 UID_FMT"%c",
index 888a97c2fc21c3000afb62ff4d392712b92610d3..66d9d06b5f17e07458148d2ebf3fb6e4c3e99805 100644 (file)
@@ -182,18 +182,18 @@ static int user_save_internal(User *u) {
                 Session *i;
                 bool first;
 
-                fputs("SESSIONS=", f);
+                fputs_unlocked("SESSIONS=", f);
                 first = true;
                 LIST_FOREACH(sessions_by_user, i, u->sessions) {
                         if (first)
                                 first = false;
                         else
-                                fputc(' ', f);
+                                fputc_unlocked(' ', f);
 
-                        fputs(i->id, f);
+                        fputs_unlocked(i->id, f);
                 }
 
-                fputs("\nSEATS=", f);
+                fputs_unlocked("\nSEATS=", f);
                 first = true;
                 LIST_FOREACH(sessions_by_user, i, u->sessions) {
                         if (!i->seat)
@@ -202,12 +202,12 @@ static int user_save_internal(User *u) {
                         if (first)
                                 first = false;
                         else
-                                fputc(' ', f);
+                                fputc_unlocked(' ', f);
 
-                        fputs(i->seat->id, f);
+                        fputs_unlocked(i->seat->id, f);
                 }
 
-                fputs("\nACTIVE_SESSIONS=", f);
+                fputs_unlocked("\nACTIVE_SESSIONS=", f);
                 first = true;
                 LIST_FOREACH(sessions_by_user, i, u->sessions) {
                         if (!session_is_active(i))
@@ -216,12 +216,12 @@ static int user_save_internal(User *u) {
                         if (first)
                                 first = false;
                         else
-                                fputc(' ', f);
+                                fputc_unlocked(' ', f);
 
-                        fputs(i->id, f);
+                        fputs_unlocked(i->id, f);
                 }
 
-                fputs("\nONLINE_SESSIONS=", f);
+                fputs_unlocked("\nONLINE_SESSIONS=", f);
                 first = true;
                 LIST_FOREACH(sessions_by_user, i, u->sessions) {
                         if (session_get_state(i) == SESSION_CLOSING)
@@ -230,12 +230,12 @@ static int user_save_internal(User *u) {
                         if (first)
                                 first = false;
                         else
-                                fputc(' ', f);
+                                fputc_unlocked(' ', f);
 
-                        fputs(i->id, f);
+                        fputs_unlocked(i->id, f);
                 }
 
-                fputs("\nACTIVE_SEATS=", f);
+                fputs_unlocked("\nACTIVE_SEATS=", f);
                 first = true;
                 LIST_FOREACH(sessions_by_user, i, u->sessions) {
                         if (!session_is_active(i) || !i->seat)
@@ -244,12 +244,12 @@ static int user_save_internal(User *u) {
                         if (first)
                                 first = false;
                         else
-                                fputc(' ', f);
+                                fputc_unlocked(' ', f);
 
-                        fputs(i->seat->id, f);
+                        fputs_unlocked(i->seat->id, f);
                 }
 
-                fputs("\nONLINE_SEATS=", f);
+                fputs_unlocked("\nONLINE_SEATS=", f);
                 first = true;
                 LIST_FOREACH(sessions_by_user, i, u->sessions) {
                         if (session_get_state(i) == SESSION_CLOSING || !i->seat)
@@ -258,11 +258,11 @@ static int user_save_internal(User *u) {
                         if (first)
                                 first = false;
                         else
-                                fputc(' ', f);
+                                fputc_unlocked(' ', f);
 
-                        fputs(i->seat->id, f);
+                        fputs_unlocked(i->seat->id, f);
                 }
-                fputc('\n', f);
+                fputc_unlocked('\n', f);
         }
 
         r = fflush_and_check(f);
index d3433d9b965f4d8dcf10bfec9f9a1a5b45b79586..399e41f87071fdda8c24bf9be426f6d1ddf2f43f 100644 (file)
@@ -199,16 +199,16 @@ int machine_save(Machine *m) {
         if (m->n_netif > 0) {
                 unsigned i;
 
-                fputs("NETIF=", f);
+                fputs_unlocked("NETIF=", f);
 
                 for (i = 0; i < m->n_netif; i++) {
                         if (i != 0)
-                                fputc(' ', f);
+                                fputc_unlocked(' ', f);
 
                         fprintf(f, "%i", m->netif[i]);
                 }
 
-                fputc('\n', f);
+                fputc_unlocked('\n', f);
         }
 
         r = fflush_and_check(f);
index 4c57fa1793894455eeff66929c4614dfb9dad899..03b8f8c3c4047c56ca46c8adaec7ce1f9ce923cf 100644 (file)
@@ -3276,16 +3276,16 @@ static void print_link_hashmap(FILE *f, const char *prefix, Hashmap* h) {
         if (hashmap_isempty(h))
                 return;
 
-        fputs(prefix, f);
+        fputs_unlocked(prefix, f);
         HASHMAP_FOREACH(link, h, i) {
                 if (space)
-                        fputc(' ', f);
+                        fputc_unlocked(' ', f);
 
                 fprintf(f, "%i", link->ifindex);
                 space = true;
         }
 
-        fputc('\n', f);
+        fputc_unlocked('\n', f);
 }
 
 int link_save(Link *link) {
@@ -3343,7 +3343,7 @@ int link_save(Link *link) {
 
                 fprintf(f, "NETWORK_FILE=%s\n", link->network->filename);
 
-                fputs("DNS=", f);
+                fputs_unlocked("DNS=", f);
                 space = false;
 
                 for (j = 0; j < link->network->n_dns; j++) {
@@ -3357,8 +3357,8 @@ int link_save(Link *link) {
                         }
 
                         if (space)
-                                fputc(' ', f);
-                        fputs(b, f);
+                                fputc_unlocked(' ', f);
+                        fputs_unlocked(b, f);
                         space = true;
                 }
 
@@ -3369,7 +3369,7 @@ int link_save(Link *link) {
                         r = sd_dhcp_lease_get_dns(link->dhcp_lease, &addresses);
                         if (r > 0) {
                                 if (space)
-                                        fputc(' ', f);
+                                        fputc_unlocked(' ', f);
                                 serialize_in_addrs(f, addresses, r);
                                 space = true;
                         }
@@ -3381,7 +3381,7 @@ int link_save(Link *link) {
                         r = sd_dhcp6_lease_get_dns(dhcp6_lease, &in6_addrs);
                         if (r > 0) {
                                 if (space)
-                                        fputc(' ', f);
+                                        fputc_unlocked(' ', f);
                                 serialize_in6_addrs(f, in6_addrs, r);
                                 space = true;
                         }
@@ -3395,16 +3395,16 @@ int link_save(Link *link) {
 
                         SET_FOREACH(dd, link->ndisc_rdnss, i) {
                                 if (space)
-                                        fputc(' ', f);
+                                        fputc_unlocked(' ', f);
 
                                 serialize_in6_addrs(f, &dd->address, 1);
                                 space = true;
                         }
                 }
 
-                fputc('\n', f);
+                fputc_unlocked('\n', f);
 
-                fputs("NTP=", f);
+                fputs_unlocked("NTP=", f);
                 space = false;
                 fputstrv(f, link->network->ntp, NULL, &space);
 
@@ -3415,7 +3415,7 @@ int link_save(Link *link) {
                         r = sd_dhcp_lease_get_ntp(link->dhcp_lease, &addresses);
                         if (r > 0) {
                                 if (space)
-                                        fputc(' ', f);
+                                        fputc_unlocked(' ', f);
                                 serialize_in_addrs(f, addresses, r);
                                 space = true;
                         }
@@ -3429,7 +3429,7 @@ int link_save(Link *link) {
                                                          &in6_addrs);
                         if (r > 0) {
                                 if (space)
-                                        fputc(' ', f);
+                                        fputc_unlocked(' ', f);
                                 serialize_in6_addrs(f, in6_addrs, r);
                                 space = true;
                         }
@@ -3439,7 +3439,7 @@ int link_save(Link *link) {
                                 fputstrv(f, hosts, NULL, &space);
                 }
 
-                fputc('\n', f);
+                fputc_unlocked('\n', f);
 
                 if (link->network->dhcp_use_domains != DHCP_USE_DOMAINS_NO) {
                         if (link->dhcp_lease) {
@@ -3450,7 +3450,7 @@ int link_save(Link *link) {
                                 (void) sd_dhcp6_lease_get_domains(dhcp6_lease, &dhcp6_domains);
                 }
 
-                fputs("DOMAINS=", f);
+                fputs_unlocked("DOMAINS=", f);
                 space = false;
                 fputstrv(f, link->network->search_domains, NULL, &space);
 
@@ -3468,9 +3468,9 @@ int link_save(Link *link) {
                                 fputs_with_space(f, NDISC_DNSSL_DOMAIN(dd), NULL, &space);
                 }
 
-                fputc('\n', f);
+                fputc_unlocked('\n', f);
 
-                fputs("ROUTE_DOMAINS=", f);
+                fputs_unlocked("ROUTE_DOMAINS=", f);
                 space = false;
                 fputstrv(f, link->network->route_domains, NULL, &space);
 
@@ -3488,7 +3488,7 @@ int link_save(Link *link) {
                                 fputs_with_space(f, NDISC_DNSSL_DOMAIN(dd), NULL, &space);
                 }
 
-                fputc('\n', f);
+                fputc_unlocked('\n', f);
 
                 fprintf(f, "LLMNR=%s\n",
                         resolve_support_to_string(link->network->llmnr));
@@ -3502,14 +3502,14 @@ int link_save(Link *link) {
                 if (!set_isempty(link->network->dnssec_negative_trust_anchors)) {
                         const char *n;
 
-                        fputs("DNSSEC_NTA=", f);
+                        fputs_unlocked("DNSSEC_NTA=", f);
                         space = false;
                         SET_FOREACH(n, link->network->dnssec_negative_trust_anchors, i)
                                 fputs_with_space(f, n, NULL, &space);
-                        fputc('\n', f);
+                        fputc_unlocked('\n', f);
                 }
 
-                fputs("ADDRESSES=", f);
+                fputs_unlocked("ADDRESSES=", f);
                 space = false;
                 SET_FOREACH(a, link->addresses, i) {
                         _cleanup_free_ char *address_str = NULL;
@@ -3521,9 +3521,9 @@ int link_save(Link *link) {
                         fprintf(f, "%s%s/%u", space ? " " : "", address_str, a->prefixlen);
                         space = true;
                 }
-                fputc('\n', f);
+                fputc_unlocked('\n', f);
 
-                fputs("ROUTES=", f);
+                fputs_unlocked("ROUTES=", f);
                 space = false;
                 SET_FOREACH(route, link->routes, i) {
                         _cleanup_free_ char *route_str = NULL;
@@ -3537,7 +3537,7 @@ int link_save(Link *link) {
                         space = true;
                 }
 
-                fputc('\n', f);
+                fputc_unlocked('\n', f);
         }
 
         print_link_hashmap(f, "CARRIER_BOUND_TO=", link->bound_to_links);
@@ -3555,9 +3555,9 @@ int link_save(Link *link) {
 
                 r = sd_dhcp_lease_get_address(link->dhcp_lease, &address);
                 if (r >= 0) {
-                        fputs("DHCP4_ADDRESS=", f);
+                        fputs_unlocked("DHCP4_ADDRESS=", f);
                         serialize_in_addrs(f, &address, 1);
-                        fputc('\n', f);
+                        fputc_unlocked('\n', f);
                 }
 
                 r = dhcp_lease_save(link->dhcp_lease, link->lease_file);
@@ -3575,9 +3575,9 @@ int link_save(Link *link) {
 
                 r = sd_ipv4ll_get_address(link->ipv4ll, &address);
                 if (r >= 0) {
-                        fputs("IPV4LL_ADDRESS=", f);
+                        fputs_unlocked("IPV4LL_ADDRESS=", f);
                         serialize_in_addrs(f, &address, 1);
-                        fputc('\n', f);
+                        fputc_unlocked('\n', f);
                 }
         }
 
index 5f10b4f993af8c1cb235c3e1dbd9a821fd1ec8c2..c28088d3a3c8f1fa61a1df7f58dfb445d3dc1f37 100644 (file)
@@ -866,12 +866,12 @@ static void print_string_set(FILE *f, const char *field, OrderedSet *s) {
         if (ordered_set_isempty(s))
                 return;
 
-        fputs(field, f);
+        fputs_unlocked(field, f);
 
         ORDERED_SET_FOREACH(p, s, i)
                 fputs_with_space(f, p, NULL, &space);
 
-        fputc('\n', f);
+        fputc_unlocked('\n', f);
 }
 
 static int manager_save(Manager *m) {
index 61a3f2036253c3e59b6c198e28d112185686d096..ea3b0618770ec974158c70129d4af7f196959ac3 100644 (file)
@@ -1050,7 +1050,7 @@ int link_save_user(Link *l) {
         if (r < 0)
                 goto fail;
 
-        fputs("# This is private data. Do not parse.\n", f);
+        fputs_unlocked("# This is private data. Do not parse.\n", f);
 
         v = resolve_support_to_string(l->llmnr_support);
         if (v)
@@ -1067,11 +1067,11 @@ int link_save_user(Link *l) {
         if (l->dns_servers) {
                 DnsServer *server;
 
-                fputs("SERVERS=", f);
+                fputs_unlocked("SERVERS=", f);
                 LIST_FOREACH(servers, server, l->dns_servers) {
 
                         if (server != l->dns_servers)
-                                fputc(' ', f);
+                                fputc_unlocked(' ', f);
 
                         v = dns_server_string(server);
                         if (!v) {
@@ -1079,26 +1079,26 @@ int link_save_user(Link *l) {
                                 goto fail;
                         }
 
-                        fputs(v, f);
+                        fputs_unlocked(v, f);
                 }
-                fputc('\n', f);
+                fputc_unlocked('\n', f);
         }
 
         if (l->search_domains) {
                 DnsSearchDomain *domain;
 
-                fputs("DOMAINS=", f);
+                fputs_unlocked("DOMAINS=", f);
                 LIST_FOREACH(domains, domain, l->search_domains) {
 
                         if (domain != l->search_domains)
-                                fputc(' ', f);
+                                fputc_unlocked(' ', f);
 
                         if (domain->route_only)
-                                fputc('~', f);
+                                fputc_unlocked('~', f);
 
-                        fputs(DNS_SEARCH_DOMAIN_NAME(domain), f);
+                        fputs_unlocked(DNS_SEARCH_DOMAIN_NAME(domain), f);
                 }
-                fputc('\n', f);
+                fputc_unlocked('\n', f);
         }
 
         if (!set_isempty(l->dnssec_negative_trust_anchors)) {
@@ -1106,16 +1106,16 @@ int link_save_user(Link *l) {
                 Iterator i;
                 char *nta;
 
-                fputs("NTAS=", f);
+                fputs_unlocked("NTAS=", f);
                 SET_FOREACH(nta, l->dnssec_negative_trust_anchors, i) {
 
                         if (space)
-                                fputc(' ', f);
+                                fputc_unlocked(' ', f);
 
-                        fputs(nta, f);
+                        fputs_unlocked(nta, f);
                         space = true;
                 }
-                fputc('\n', f);
+                fputc_unlocked('\n', f);
         }
 
         r = fflush_and_check(f);
index 3c62550872688a5990971d1dcb84bcb9b356c4c5..f4e071ebaad79c94d97bf53ebd797544356806fc 100644 (file)
@@ -165,7 +165,7 @@ static void write_resolv_conf_server(DnsServer *s, FILE *f, unsigned *count) {
         }
 
         if (*count == MAXNS)
-                fputs("# Too many DNS servers configured, the following entries may be ignored.\n", f);
+                fputs_unlocked("# Too many DNS servers configured, the following entries may be ignored.\n", f);
         (*count)++;
 
         fprintf(f, "nameserver %s\n", dns_server_string(s));
@@ -181,39 +181,39 @@ static void write_resolv_conf_search(
         assert(domains);
         assert(f);
 
-        fputs("search", f);
+        fputs_unlocked("search", f);
 
         ORDERED_SET_FOREACH(domain, domains, i) {
                 if (++count > MAXDNSRCH) {
-                        fputs("\n# Too many search domains configured, remaining ones ignored.", f);
+                        fputs_unlocked("\n# Too many search domains configured, remaining ones ignored.", f);
                         break;
                 }
                 length += strlen(domain) + 1;
                 if (length > 256) {
-                        fputs("\n# Total length of all search domains is too long, remaining ones ignored.", f);
+                        fputs_unlocked("\n# Total length of all search domains is too long, remaining ones ignored.", f);
                         break;
                 }
-                fputc(' ', f);
-                fputs(domain, f);
+                fputc_unlocked(' ', f);
+                fputs_unlocked(domain, f);
         }
 
-        fputs("\n", f);
+        fputs_unlocked("\n", f);
 }
 
 static int write_resolv_conf_contents(FILE *f, OrderedSet *dns, OrderedSet *domains) {
         Iterator i;
 
-        fputs("# This file is managed by man:systemd-resolved(8). Do not edit.\n#\n"
-              "# This is a dynamic resolv.conf file for connecting local clients directly to\n"
-              "# all known DNS servers.\n#\n"
-              "# Third party programs must not access this file directly, but only through the\n"
-              "# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,\n"
-              "# replace this symlink by a static file or a different symlink.\n#\n"
-              "# See man:systemd-resolved.service(8) for details about the supported modes of\n"
-              "# operation for /etc/resolv.conf.\n\n", f);
+        fputs_unlocked("# This file is managed by man:systemd-resolved(8). Do not edit.\n#\n"
+                       "# This is a dynamic resolv.conf file for connecting local clients directly to\n"
+                       "# all known DNS servers.\n#\n"
+                       "# Third party programs must not access this file directly, but only through the\n"
+                       "# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,\n"
+                       "# replace this symlink by a static file or a different symlink.\n#\n"
+                       "# See man:systemd-resolved.service(8) for details about the supported modes of\n"
+                       "# operation for /etc/resolv.conf.\n\n", f);
 
         if (ordered_set_isempty(dns))
-                fputs("# No DNS servers known.\n", f);
+                fputs_unlocked("# No DNS servers known.\n", f);
         else {
                 unsigned count = 0;
                 DnsServer *s;