main - lvmdbusd: Correct locking for _common_log

Tony Asleson <[email protected]>
Newsgroups gmane.linux.lvm.devel
Message-ID <[email protected]>
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f7ca470abe995210e8008084c0b4436292b2816b
Commit:        f7ca470abe995210e8008084c0b4436292b2816b
Parent:        d6f8f59239c65a7f1f9be1d24bf9ba02cfee5b0e
Author:        Tony Asleson <[email protected]>
AuthorDate:    Thu Mar 30 10:07:13 2023 -0500
Committer:     Tony Asleson <[email protected]>
CommitterDate: Thu Mar 30 11:04:42 2023 -0500

lvmdbusd: Correct locking for _common_log

Reduce the lock time and include the flush in the lock.

Reported by: Zbigniew Jędrzejewski-Szmek <[email protected]>
---
 daemons/lvmdbusd/utils.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
index 6013b656f..fdd7578c1 100644
--- a/daemons/lvmdbusd/utils.py
+++ b/daemons/lvmdbusd/utils.py
@@ -323,16 +323,17 @@ def _format_log_entry(msg):
 
 
 def _common_log(msg, *attributes):
-	cfg.stdout_lock.acquire()
 	msg = _format_log_entry(msg)
 
+	cfg.stdout_lock.acquire()
+
 	if STDOUT_TTY and attributes:
 		print(color(msg, *attributes))
 	else:
 		print(msg)
 
-	cfg.stdout_lock.release()
 	sys.stdout.flush()
+	cfg.stdout_lock.release()
 
 
 # Serializes access to stdout to prevent interleaved output

--
lvm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/lvm-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.