Blame SOURCES/0007-selinux_restorecon-add-a-global-mutex-to-synchronize.patch

f10538
From 73310c9694724b3ef54bbf3a3193dbb0a68ecc3b Mon Sep 17 00:00:00 2001
f10538
From: Ondrej Mosnacek <omosnace@redhat.com>
f10538
Date: Tue, 26 Oct 2021 13:52:37 +0200
f10538
Subject: [PATCH] selinux_restorecon: add a global mutex to synchronize
f10538
 progress output
f10538
f10538
Another small incremental change to pave the way for a parallel
f10538
selinux_restorecon() function.
f10538
f10538
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
f10538
---
f10538
 libselinux/src/selinux_restorecon.c | 3 +++
f10538
 1 file changed, 3 insertions(+)
f10538
f10538
diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
f10538
index 43acbace309d..169dfe3ae232 100644
f10538
--- a/libselinux/src/selinux_restorecon.c
f10538
+++ b/libselinux/src/selinux_restorecon.c
f10538
@@ -60,6 +60,7 @@ static int exclude_count = 0;
f10538
 static struct edir *exclude_lst = NULL;
f10538
 static uint64_t fc_count = 0;	/* Number of files processed so far */
f10538
 static uint64_t efile_count;	/* Estimated total number of files */
f10538
+static pthread_mutex_t progress_mutex = PTHREAD_MUTEX_INITIALIZER;
f10538
 
f10538
 /* Store information on directories with xattr's. */
f10538
 static struct dir_xattr *dir_xattr_list;
f10538
@@ -647,6 +648,7 @@ static int restorecon_sb(const char *pathname, const struct stat *sb,
f10538
 	}
f10538
 
f10538
 	if (flags->progress) {
f10538
+		__pthread_mutex_lock(&progress_mutex);
f10538
 		fc_count++;
f10538
 		if (fc_count % STAR_COUNT == 0) {
f10538
 			if (flags->mass_relabel && efile_count > 0) {
f10538
@@ -658,6 +660,7 @@ static int restorecon_sb(const char *pathname, const struct stat *sb,
f10538
 			}
f10538
 			fflush(stdout);
f10538
 		}
f10538
+		__pthread_mutex_unlock(&progress_mutex);
f10538
 	}
f10538
 
f10538
 	if (flags->add_assoc) {
f10538
-- 
f10538
2.33.1
f10538