All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Benjamin Marzinski" <bmarzins@redhat.com>
To: dm-devel@redhat.com
Cc: Martin Wilck <mwilck@suse.com>, christophe.varoqui@free.fr
Subject: [PATCH 04/12] multipathd: log thread cleanup
Date: Wed, 14 Mar 2018 12:46:37 -0500	[thread overview]
Message-ID: <1521049605-22050-5-git-send-email-bmarzins@redhat.com> (raw)
In-Reply-To: <1521049605-22050-1-git-send-email-bmarzins@redhat.com>

The function log_thread_flush() is an exact copy of flush_lgoqueue(), so
both clearly don't need to exist. Also, There is no reason to make all
of the log thread variables global.  The only time any of them were
being used outside of log_thread.c, was to reset the log.  This code
should never be run if the log_thread isn't running, so it makes more
sense to live inside of log_thread.c

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/log_pthread.c | 34 +++++++++++++++-------------------
 libmultipath/log_pthread.h | 10 +---------
 multipathd/main.c          |  5 ++---
 3 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/libmultipath/log_pthread.c b/libmultipath/log_pthread.c
index 035ae5d..f491386 100644
--- a/libmultipath/log_pthread.c
+++ b/libmultipath/log_pthread.c
@@ -14,13 +14,13 @@
 #include "log.h"
 #include "lock.h"
 
-pthread_t log_thr;
+static pthread_t log_thr;
 
-pthread_mutex_t logq_lock;
-pthread_mutex_t logev_lock;
-pthread_cond_t logev_cond;
+static pthread_mutex_t logq_lock;
+static pthread_mutex_t logev_lock;
+static pthread_cond_t logev_cond;
 
-int logq_running;
+static int logq_running;
 
 void log_safe (int prio, const char * fmt, va_list ap)
 {
@@ -38,19 +38,6 @@ void log_safe (int prio, const char * fmt, va_list ap)
 	pthread_mutex_unlock(&logev_lock);
 }
 
-void log_thread_flush (void)
-{
-	int empty;
-
-	do {
-		pthread_mutex_lock(&logq_lock);
-		empty = log_dequeue(la->buff);
-		pthread_mutex_unlock(&logq_lock);
-		if (!empty)
-			log_syslog(la->buff);
-	} while (empty == 0);
-}
-
 static void flush_logqueue (void)
 {
 	int empty;
@@ -82,7 +69,7 @@ static void * log_thread (void * et)
 		pthread_mutex_unlock(&logev_lock);
 		if (!running)
 			break;
-		log_thread_flush();
+		flush_logqueue();
 	}
 	return NULL;
 }
@@ -107,6 +94,15 @@ void log_thread_start (pthread_attr_t *attr)
 	return;
 }
 
+void log_thread_reset (void)
+{
+	logdbg(stderr,"resetting log\n");
+
+	pthread_mutex_lock(&logq_lock);
+	log_reset("multipathd");
+	pthread_mutex_unlock(&logq_lock);
+}
+
 void log_thread_stop (void)
 {
 	logdbg(stderr,"enter log_thread_stop\n");
diff --git a/libmultipath/log_pthread.h b/libmultipath/log_pthread.h
index e5c6499..7e138a0 100644
--- a/libmultipath/log_pthread.h
+++ b/libmultipath/log_pthread.h
@@ -3,17 +3,9 @@
 
 #include <pthread.h>
 
-extern pthread_t log_thr;
-
-extern pthread_mutex_t logq_lock;
-extern pthread_mutex_t logev_lock;
-extern pthread_cond_t logev_cond;
-
-extern int logq_running;
-
 void log_safe(int prio, const char * fmt, va_list ap);
 void log_thread_start(pthread_attr_t *attr);
+void log_thread_reset (void);
 void log_thread_stop(void);
-void log_thread_flush(void);
 
 #endif /* _LOG_PTHREAD_H */
diff --git a/multipathd/main.c b/multipathd/main.c
index a03ba20..6ba6131 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -2219,9 +2219,8 @@ handle_signals(bool nonfatal)
 	}
 	if (log_reset_sig) {
 		condlog(2, "reset log (signal)");
-		pthread_mutex_lock(&logq_lock);
-		log_reset("multipathd");
-		pthread_mutex_unlock(&logq_lock);
+		if (logsink == 1)
+			log_thread_reset();
 	}
 	reconfig_sig = 0;
 	log_reset_sig = 0;
-- 
2.7.4

  parent reply	other threads:[~2018-03-14 17:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-14 17:46 [PATCH 00/12] multipath: new and rebased patches Benjamin Marzinski
2018-03-14 17:46 ` [PATCH 01/12] Unit tests for basenamecpy Benjamin Marzinski
2018-03-19  9:49   ` Martin Wilck
2018-03-19 10:05     ` Martin Wilck
2018-03-14 17:46 ` [PATCH 02/12] libmultipath: fix basenamecpy Benjamin Marzinski
2018-03-14 17:46 ` [PATCH 03/12] libmultipath: set dm_conf_verbosity Benjamin Marzinski
2018-03-19 10:18   ` Martin Wilck
2018-03-14 17:46 ` Benjamin Marzinski [this message]
2018-03-19 10:20   ` [PATCH 04/12] multipathd: log thread cleanup Martin Wilck
2018-03-14 17:46 ` [PATCH 05/12] libmultipath: fix log_pthread processing Benjamin Marzinski
2018-03-19 10:22   ` Martin Wilck
2018-03-14 17:46 ` [PATCH 06/12] multipathd: use nanosleep for strict timing Benjamin Marzinski
2018-03-19 10:50   ` Martin Wilck
2018-03-14 17:46 ` [PATCH 07/12] libmultipath: move remove_map waiter code to multipathd Benjamin Marzinski
2018-03-19 10:57   ` Martin Wilck
2018-03-14 17:46 ` [PATCH 08/12] move waiter code from libmultipath " Benjamin Marzinski
2018-03-14 17:46 ` [PATCH 09/12] call start_waiter_thread() before setup_multipath() Benjamin Marzinski
2018-03-14 17:46 ` [PATCH 10/12] libmultipath: add helper functions Benjamin Marzinski
2018-03-14 17:46 ` [PATCH 11/12] multipathd: add new polling dmevents waiter thread Benjamin Marzinski
2018-03-19 12:48   ` Martin Wilck
2018-03-14 17:46 ` [PATCH 12/12] multipath: add unit tests for dmevents code Benjamin Marzinski
2018-03-19 12:01   ` Martin Wilck
2018-03-15 14:30 ` [PATCH 00/12] multipath: new and rebased patches Benjamin Marzinski

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=1521049605-22050-5-git-send-email-bmarzins@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=christophe.varoqui@free.fr \
    --cc=dm-devel@redhat.com \
    --cc=mwilck@suse.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.