summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-01-31 19:14:15 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-01-31 19:29:17 +0100
commite6508c84c88c8b6db9e8c04ec387a70ce79d4a40 (patch)
tree0c4d51a29c2c364199ca1868a139a092d5666634
parent6a6748c9c70bc585611f74811bd2bf71f9a14814 (diff)
downloadrvnit-e6508c84c88c8b6db9e8c04ec387a70ce79d4a40.tar.gz
rvnit-e6508c84c88c8b6db9e8c04ec387a70ce79d4a40.tar.xz
rvnit-e6508c84c88c8b6db9e8c04ec387a70ce79d4a40.zip
put want_rescan/want_rescandir inside services_lock
-rwxr-xr-xrvnitbin0 -> 76160 bytes
-rw-r--r--rvnit.c14
2 files changed, 8 insertions, 6 deletions
diff --git a/rvnit b/rvnit
new file mode 100755
index 0000000..730af55
--- /dev/null
+++ b/rvnit
Binary files differdiff --git a/rvnit.c b/rvnit.c
index 794d43c..0846457 100644
--- a/rvnit.c
+++ b/rvnit.c
@@ -68,9 +68,9 @@ int real_pid1;
 int use_global_log;
 
 volatile sig_atomic_t want_shutdown;
-volatile sig_atomic_t want_rescan;
-volatile sig_atomic_t want_rescandir;
 volatile sig_atomic_t want_reboot;
+int want_rescan;
+int want_rescandir;
 
 void
 on_signal(int sig)
@@ -328,8 +328,10 @@ socket_loop(void* ignored)
 
 		if (cmd == 'r') {
 			write(connfd, "ok\n", 3);
+			pthread_mutex_lock(&services_lock);
 			want_rescandir = 1;
 			want_rescan = 1;
+			pthread_mutex_unlock(&services_lock);
 			pthread_kill(main_thread, SIGCONT);
 		}
 
@@ -867,16 +869,15 @@ cont1:
 	LOG("system up");
 
 	while (!want_shutdown) {
+		pthread_mutex_lock(&services_lock);
+
 		if (want_rescandir) {
-			pthread_mutex_lock(&services_lock);
 			rescandir();
-			pthread_mutex_unlock(&services_lock);
 			want_rescandir = 0;
 		}
 
 		if (want_rescan) {
 			printf("rescanning state\n");
-			pthread_mutex_lock(&services_lock);
 			for (i = 0; i < MAX_SV; i++) {
 				if (services[i].name[2] == 'L') {
 					if (services[i].state == UP &&
@@ -910,11 +911,12 @@ cont1:
 					}
 				}
 			}
-			pthread_mutex_unlock(&services_lock);
 
 			want_rescan = 0;
 		}
 
+		pthread_mutex_lock(&services_lock);
+
 		int status = 0;
 		errno = 0;
 		int pid = wait(&status);