All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Asleson <tasleson@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - lvmdbusd: Correct locking for _common_log
Date: Thu, 30 Mar 2023 16:05:15 +0000 (GMT)	[thread overview]
Message-ID: <20230330160515.32D253858CDA@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f7ca470abe995210e8008084c0b4436292b2816b
Commit:        f7ca470abe995210e8008084c0b4436292b2816b
Parent:        d6f8f59239c65a7f1f9be1d24bf9ba02cfee5b0e
Author:        Tony Asleson <tasleson@redhat.com>
AuthorDate:    Thu Mar 30 10:07:13 2023 -0500
Committer:     Tony Asleson <tasleson@redhat.com>
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 <zbyszek@in.waw.pl>
---
 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


                 reply	other threads:[~2023-03-30 16:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230330160515.32D253858CDA@sourceware.org \
    --to=tasleson@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.