From fcb4c678130705e5e2169cea5bc782f59c57670c Mon Sep 17 00:00:00 2001
From: Adam Wujek <dev_public@wujek.eu>
Date: Mon, 3 Feb 2025 02:10:46 +0100
Subject: [PATCH] Revert "[BUG: #363] userspace: reduce re-checking period for
 HAL's shmem"

This reverts commit d9e4bc3d69c4ca3fbdf196fa98c4c2ac88416a3e.
---
 userspace/snmpd/snmp_shmem.c          | 16 ++++++++--------
 userspace/tools/rtu_stat.c            |  8 ++++----
 userspace/tools/wr_mon.c              |  4 ++--
 userspace/tools/wr_phytool.c          |  2 +-
 userspace/tools/wrs_sfp_dump.c        |  2 +-
 userspace/tools/wrs_vlans.c           |  6 +++---
 userspace/wrs_watchdog/wrs_watchdog.c |  4 ++--
 7 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/userspace/snmpd/snmp_shmem.c b/userspace/snmpd/snmp_shmem.c
index bc967bddf..a4bc17976 100644
--- a/userspace/snmpd/snmp_shmem.c
+++ b/userspace/snmpd/snmp_shmem.c
@@ -232,29 +232,29 @@ void init_shm(void){
 			"Using path %s for shmem!\n", shmem_path);
 	}
 
-	for (i = 0; i < 11; i++) {
+	for (i = 0; i < 10; i++) {
 		if (shmem_ready_hald()) {
 			/* shmem opened successfully */
 			break;
 		}
-		/* wait 900ms second before another try */
-		usleep(900000);
+		/* wait 1 second before another try */
+		sleep(1);
 	}
 	for (i = 0; i < 10; i++) {
 		if (shmem_ready_ppsi()) {
 			/* shmem opened successfully */
 			break;
 		}
-		/* wait 900ms second before another try */
-		usleep(900000);
+		/* wait 1 second before another try */
+		sleep(1);
 	}
-	for (i = 0; i < 11; i++) {
+	for (i = 0; i < 10; i++) {
 		if (shmem_ready_rtud()) {
 			/* shmem opened successfully */
 			break;
 		}
-		/* wait 900ms second before another try */
-		usleep(900000);
+		/* wait 1 second before another try */
+		sleep(1);
 	}
 }
 
diff --git a/userspace/tools/rtu_stat.c b/userspace/tools/rtu_stat.c
index 3cfa10aaf..2074cc2a4 100644
--- a/userspace/tools/rtu_stat.c
+++ b/userspace/tools/rtu_stat.c
@@ -237,7 +237,7 @@ int get_nports_from_hal(void)
 			}
 			exit(1);
 		}
-		usleep(900000);
+		sleep(1);
 	}
 
 	h = (void *)hal_head + hal_head->data_off;
@@ -254,7 +254,7 @@ int get_nports_from_hal(void)
 		if (n_wait > 10) {
 			exit(1);
 		}
-		usleep(900000);
+		sleep(1);
 	}
 
 	/* check hal's shm version */
@@ -392,7 +392,7 @@ int open_rtu_shm(void)
 			}
 			exit(1);
 		}
-		usleep(900000);
+		sleep(1);
 	}
 
 	/* check rtu shm version */
@@ -571,7 +571,7 @@ int main(int argc, char **argv)
 			}
 		}
 		n_wait++;
-		usleep(900000);
+		sleep(1);
 	}
 	if (use_static_shmem != SHMEM_STATIC_NO_IPC)
 		minipc_set_logfile(rtud_ch, stdout);
diff --git a/userspace/tools/wr_mon.c b/userspace/tools/wr_mon.c
index 5b753ca00..3a1abb1c7 100644
--- a/userspace/tools/wr_mon.c
+++ b/userspace/tools/wr_mon.c
@@ -601,7 +601,7 @@ void init_shm(void)
 			/* timeout! */
 			exit(-1);
 		}
-		usleep(900000);
+		sleep(1);
 	}
 
 	if (hal_head->version != HAL_SHMEM_VERSION) {
@@ -645,7 +645,7 @@ void init_shm(void)
 			/* timeout! */
 			exit(-1);
 		}
-		usleep(900000);
+		sleep(1);
 	}
 
 	/* check hal's shm version */
diff --git a/userspace/tools/wr_phytool.c b/userspace/tools/wr_phytool.c
index 1bca8696f..a18e1ee45 100644
--- a/userspace/tools/wr_phytool.c
+++ b/userspace/tools/wr_phytool.c
@@ -89,7 +89,7 @@ int hal_shm_init(void)
 			}
 			return(-1);
 		}
-		usleep(900000);
+		sleep(1);
 	}
 
 	/* check hal's shm version */
diff --git a/userspace/tools/wrs_sfp_dump.c b/userspace/tools/wrs_sfp_dump.c
index f6d99161c..15ac423d4 100644
--- a/userspace/tools/wrs_sfp_dump.c
+++ b/userspace/tools/wrs_sfp_dump.c
@@ -262,7 +262,7 @@ void hal_init_shm(void)
 			/* timeout! */
 			exit(1);
 		}
-		usleep(900000);
+		sleep(1);
 	}
 
 	if (hal_head->version != HAL_SHMEM_VERSION) {
diff --git a/userspace/tools/wrs_vlans.c b/userspace/tools/wrs_vlans.c
index f4068d978..ad03b3cb3 100644
--- a/userspace/tools/wrs_vlans.c
+++ b/userspace/tools/wrs_vlans.c
@@ -192,11 +192,11 @@ int main(int argc, char *argv[])
 	/* connect to the RTUd mini-rpc */
 	while((rtud_ch = minipc_client_create("rtud", 0)) == 0) {
 		n_wait++;
-		if (n_wait > 11) {
+		if (n_wait > 10) {
 			pr_error("Can't connect to RTUd mini-rpc server\n");
 			exit(1);
 		}
-		usleep(900000);
+		sleep(1);
 	}
 
 	n_wait = 0;
@@ -216,7 +216,7 @@ int main(int argc, char *argv[])
 			}
 			exit(1);
 		}
-		usleep(900000);
+		sleep(1);
 	}
 
 	/* check rtu shm version */
diff --git a/userspace/wrs_watchdog/wrs_watchdog.c b/userspace/wrs_watchdog/wrs_watchdog.c
index 2dfe3733b..0aea35292 100644
--- a/userspace/wrs_watchdog/wrs_watchdog.c
+++ b/userspace/wrs_watchdog/wrs_watchdog.c
@@ -73,7 +73,7 @@ int get_nports_from_hal(void)
 			}
 			exit(1);
 		}
-		usleep(900000);
+		sleep(1);
 	}
 
 	h = (void *)hal_head + hal_head->data_off;
@@ -94,7 +94,7 @@ int get_nports_from_hal(void)
 			exit(1);
 
 		}
-		usleep(900000);
+		sleep(1);
 	}
 
 	/* check hal's shm version */
-- 
GitLab