summaryrefslogtreecommitdiffstats
path: root/src/udev/udev-ctrl.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-08-31 15:32:41 +0200
committerLennart Poettering <lennart@poettering.net>2021-09-01 14:44:00 +0200
commitbdb492b2edca50d89f8d80900bda1156fb252a18 (patch)
tree4a3aa8a6cec78fbc8fabeec4a2d83e5f6246b626 /src/udev/udev-ctrl.c
parentMerge pull request #20537 from yuwata/sd-netlink-more-attributes (diff)
downloadsystemd-bdb492b2edca50d89f8d80900bda1156fb252a18.tar.xz
systemd-bdb492b2edca50d89f8d80900bda1156fb252a18.zip
udev: do not remove control socket on exit
As we usually do, remove old unix socket before bind. Note that systemd-udevd-control.socket has `RemoveOnStop=yes`. So, it is not necessary to be removed when the service exits. Replaces #20584 and #20588.
Diffstat (limited to 'src/udev/udev-ctrl.c')
-rw-r--r--src/udev/udev-ctrl.c22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 00279ba3d8..179a1fdec3 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -37,7 +37,6 @@ struct UdevCtrl {
union sockaddr_union saddr;
socklen_t addrlen;
bool bound;
- bool cleanup_socket;
bool connected;
bool maybe_disconnected;
sd_event *event;
@@ -82,28 +81,19 @@ int udev_ctrl_new_from_fd(UdevCtrl **ret, int fd) {
}
int udev_ctrl_enable_receiving(UdevCtrl *uctrl) {
- int r;
-
assert(uctrl);
if (uctrl->bound)
return 0;
- r = bind(uctrl->sock, &uctrl->saddr.sa, uctrl->addrlen);
- if (r < 0 && errno == EADDRINUSE) {
- (void) sockaddr_un_unlink(&uctrl->saddr.un);
- r = bind(uctrl->sock, &uctrl->saddr.sa, uctrl->addrlen);
- }
-
- if (r < 0)
+ (void) sockaddr_un_unlink(&uctrl->saddr.un);
+ if (bind(uctrl->sock, &uctrl->saddr.sa, uctrl->addrlen) < 0)
return log_error_errno(errno, "Failed to bind udev control socket: %m");
if (listen(uctrl->sock, 0) < 0)
return log_error_errno(errno, "Failed to listen udev control socket: %m");
uctrl->bound = true;
- uctrl->cleanup_socket = true;
-
return 0;
}
@@ -129,14 +119,6 @@ static UdevCtrl *udev_ctrl_free(UdevCtrl *uctrl) {
DEFINE_TRIVIAL_REF_UNREF_FUNC(UdevCtrl, udev_ctrl, udev_ctrl_free);
-int udev_ctrl_cleanup(UdevCtrl *uctrl) {
- if (!uctrl)
- return 0;
- if (uctrl->cleanup_socket)
- sockaddr_un_unlink(&uctrl->saddr.un);
- return 0;
-}
-
int udev_ctrl_attach_event(UdevCtrl *uctrl, sd_event *event) {
int r;