From f98340f1b830d950978abba752b2b9b004528faf Mon Sep 17 00:00:00 2001 From: Mariusz Tkaczyk Date: Thu, 20 Jun 2024 15:22:50 +0200 Subject: [PATCH 108/201] Revert "mdadm: Fix socket connection failure when mdmon runs in foreground mode." This reverts commit 66a54b266f6c579e5f37b6253820903a55c3346c. connect_monitor() is called from ping_monitor() but this function is often used as advice, without verification that mdmon is really working. This produces hangs in many scenarios. Signed-off-by: Mariusz Tkaczyk --- msg.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/msg.c b/msg.c index d17f679d..f0772b3f 100644 --- a/msg.c +++ b/msg.c @@ -151,7 +151,6 @@ int connect_monitor(char *devname) struct sockaddr_un addr; int pos; char *c; - int rv, retry_count = 0; pos = sprintf(path, "%s/", MDMON_DIR); if (is_subarray(devname)) { @@ -171,24 +170,7 @@ int connect_monitor(char *devname) addr.sun_family = PF_LOCAL; strcpy(addr.sun_path, path); - - /* In foreground mode, when mdadm is trying to connect to control - * socket it is possible that the mdmon has not created it yet. - * Give some time to mdmon to create socket. - */ - for (retry_count = 0; retry_count < 10; retry_count++) { - rv = connect(sfd, (struct sockaddr*)&addr, sizeof(addr)); - - if (rv < 0) { - sleep_for(0, MSEC_TO_NSEC(200), true); - continue; - } - break; - } - - if (rv < 0) { - pr_err("Failed to connect to control socket. (%s!!)\n", - strerror(errno)); + if (connect(sfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { close(sfd); return -1; } -- 2.41.0