This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".
The branch, master has been updated
via 03781f0e840d268cbc5fffc9a36548fca28a3d76 (commit)
from 96078c8382cb000b85424d5826f6ac83d49ce2ee (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 03781f0e840d268cbc5fffc9a36548fca28a3d76
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date: Thu Apr 24 09:47:51 2008 +0200
[CMAN] Convert qdiskd to use logsys
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
diff --git a/cman/qdisk/clulog.c b/cman/qdisk/clulog.c
deleted file mode 100644
index 6b998f1..0000000
--- a/cman/qdisk/clulog.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- Copyright Red Hat, Inc. 2002
- Copyright Mission Critical Linux, 2000
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
- MA 02139, USA.
-*/
-/** @file
- * Library routines for communicating with the logging daemon.
- *
- * Author: Jeff Moyer <moyer@missioncriticallinux.com>
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <malloc.h>
-#include <dirent.h>
-#include <signal.h>
-#include <sys/errno.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/socket.h>
-#include <ccs.h>
-#define SYSLOG_NAMES
-#include <sys/syslog.h>
-#undef SYSLOG_NAMES
-
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <linux/unistd.h>
-#include <pthread.h>
-#include <gettid.h>
-#include <clulog.h>
-#include <string.h>
-
-
-#ifdef DEBUG
-#include <assert.h>
-#define Dprintf(fmt,args...) printf(fmt,##args)
-#define DBG_ASSERT(x) assert(x)
-#else
-#define Dprintf(fmt,args...)
-#define DBG_ASSERT(x)
-#endif
-
-/*
- * Globals
- */
-static int log_is_open = 0;
-static int useconsole = 0;
-static int loglevel = LOGLEVEL_DFLT;
-static int syslog_facility = LOG_DAEMON;
-static char *daemon_name = NULL;
-static pid_t daemon_pid = -1;
-static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-CODE logger_prioritynames[] =
-{ {"emerg", LOG_EMERG},
- {"alert", LOG_ALERT},
- {"crit", LOG_CRIT},
- {"err", LOG_ERR},
- {"warning", LOG_WARNING},
- {"notice", LOG_NOTICE},
- {"info", LOG_INFO},
- {"debug", LOG_DEBUG}
-};
-
-/*
- * Exported Functions.
- */
-
-/**
- * @return The current cluster log level.
- */
-int
-clu_get_loglevel(void)
-{
- return loglevel;
-}
-
-
-/**
- * Set the cluster log level.
- *
- * @param severity New log level.
- * @return Old log level, or -1 if 'severity' is an invalid log
- * level.
- */
-int
-clu_set_loglevel(int severity)
-{
- int ret = loglevel;
-
- if (severity > 0) {
- loglevel = severity;
- return ret;
- }
-
- return -1;
-}
-
-
-/**
- * @return The current cluster log facility.
- */
-char *
-clu_get_facility(void)
-{
- int x = 0;
-
- pthread_mutex_lock(&log_mutex);
- for (; facilitynames[x].c_name; x++) {
- if (syslog_facility == facilitynames[x].c_val) {
- pthread_mutex_unlock(&log_mutex);
- return facilitynames[x].c_name;
- }
- }
-
- pthread_mutex_unlock(&log_mutex);
- return "daemon";
-}
-
-
-/**
- * Set the cluster log facility.
- *
- * @param facilityname New log facility (see /usr/include/sys/syslog.h).
- * @return 0
- */
-int
-clu_set_facility(char *facilityname)
-{
- int x = 0, old;
-
- pthread_mutex_lock(&log_mutex);
- old = syslog_facility;
-
- for (; facilitynames[x].c_name; x++) {
- if (strcmp(facilityname, facilitynames[x].c_name))
- continue;
- syslog_facility = facilitynames[x].c_val;
- break;
- }
-
- if (syslog_facility == old) {
- pthread_mutex_unlock(&log_mutex);
- return 0;
- }
-
- closelog();
- log_is_open = 0;
- pthread_mutex_unlock(&log_mutex);
- return 0;
-}
-
-
-/**
- * Set the console logging mode. Does not work for daemons.
- *
- * @param onoff 0 = off, otherwise on.
- * @return Old log-to-console state.
- */
-int
-clu_log_console(int onoff)
-{
- int ret = useconsole;
-
- useconsole = !!onoff;
- return ret;
-}
-
-
-/**
- * Cluster logging function. Talks to syslog and writes to the
- * console, if necessary.
- */
-int
-do_clulog(int severity,
- int write_to_cons,
- pid_t pid,
- char *prog,
- const char *fmt, ...)
-{
- va_list args;
- char logmsg[MAX_LOGMSG_LEN]; /* message to go to the log */
- char printmsg[MAX_LOGMSG_LEN]; /* message to go to stdout */
- int syslog_flags = LOG_NDELAY;
-
- pthread_mutex_lock(&log_mutex);
- if (severity > loglevel) {
- pthread_mutex_unlock(&log_mutex);
- return 0;
- }
-
- memset(logmsg, 0, MAX_LOGMSG_LEN);
- memset(printmsg, 0, MAX_LOGMSG_LEN);
-
- /*
- * Check to see if the caller has forked.
- */
- if (!pid) {
-
- /* Use thread IDs */
- if (daemon_pid != gettid()) {
-
- daemon_pid = gettid();
- log_is_open = 0;
- }
-
- syslog_flags |= LOG_PID;
-
- } else {
-
- daemon_pid = pid;
- closelog();
- log_is_open = 0;
- snprintf(logmsg, MAX_LOGMSG_LEN, "[%d]: ", pid);
- }
-
- if (prog) {
-
- if (daemon_name) {
-
- free(daemon_name);
- daemon_name = NULL;
- }
-
- daemon_name = strdup(prog);
- }
-
- if (!log_is_open) {
-
- openlog(daemon_name, syslog_flags, syslog_facility);
- log_is_open = 1;
- }
- /*
- * Note: This can be called in the context of a CGI program, in which
- * case anything printed to stdout goes to the web page. This can
- * cause problems if we have our standard <warning> strings b/c
- * the web client will try to interpret this as an html tag.
- */
- snprintf(logmsg + strlen(logmsg), MAX_LOGMSG_LEN - strlen(logmsg),
- "<%s> ", logger_prioritynames[severity].c_name);
-
- va_start(args, fmt);
- vsnprintf(logmsg + strlen(logmsg), MAX_LOGMSG_LEN - strlen(logmsg),
- fmt, args);
- va_end(args);
-
- if (write_to_cons || useconsole) {
- snprintf(printmsg, MAX_LOGMSG_LEN, "[%d] %s: ", daemon_pid,
- logger_prioritynames[severity].c_name);
-
- va_start(args, fmt);
- vsnprintf(printmsg + strlen(printmsg),
- MAX_LOGMSG_LEN - strlen(printmsg), fmt, args);
- va_end(args);
-
- fprintf(stdout, "%s", printmsg);
- }
-
- syslog(severity, "%s", logmsg);
-
- pthread_mutex_unlock(&log_mutex);
-
- return 0;
-}
-
-
-/**
- * Stop the cluster logging facility.
- */
-void
-clulog_close(void)
-{
- closelog();
-}
diff --git a/cman/qdisk/clulog.h b/cman/qdisk/clulog.h
deleted file mode 100644
index 856d83c..0000000
--- a/cman/qdisk/clulog.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- Copyright Red Hat, Inc. 2002
- Copyright Mission Critical Linux, 2000
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
- MA 02139, USA.
-*/
-/** @file
- * Header for clulog.c
- */
-/*
- * author: Jeff Moyer <moyer@missioncriticallinux.com>
- */
-
-#ifndef __CLUSTER_LOG_H
-#define __CLUSTER_LOG_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <syslog.h>
-#include <sys/types.h>
-
-#define LOGLEVEL_DFLT LOG_INFO
-#define MAX_LOGMSG_LEN 512
-
-/*
- * int clu_set_loglevel(int severity)
- *
- * DESCRIPTION
- * Set the logging level for this daemon. This is not a
- * system-wide setting.
- *
- * ARGUMENTS
- * severity Severity as documented in sys/syslog.h (i.e. LOG_ERR)
- *
- * RETURN VALUES
- * On success, the previous loglevel is returned. On error -1 is returned.
- *
- * NOTES
- * The only way of generating errors for this call is to give a negative
- * value for severity. Currently, syslog lists severities up to 8, but
- * I see no reason for this restriction if, in the future, we decided to
- * add more levels. Thus, any number up to MAXINT will be supported.
- */
-int clu_set_loglevel(int severity);
-int clu_set_facility(char *facility);
-int clu_log_console(int onoff);
-
-/*
- * int clu_get_loglevel(void)
- *
- * DESCRIPTION
- * Get the current logging level.
- *
- * ARGUMENTS
- * none
- *
- * RETURN VALUES
- * The current logging level is returned.
- */
-int clu_get_loglevel(void);
-
-/*
- * DESCRIPTION
- * Cluster logging facility. This is the actual function that does the
- * logging. No one should call this, you should call the wrappers provided.
- * i.e. clulog and clulog_and_print.
- */
-int do_clulog(int severity, int write_to_cons, pid_t pid,
- char *prog, const char *fmt, ...);
-/*
- * int clulog(int severity, const char *fmt, ...)
- *
- * DESCRIPTION
- * Cluster logging facility. This is a library routine which sends the
- * supplied parameters to the syslog daemon. If the supplied severity is
- * numerically larger than the current loglevel, the message is never sent
- * to the log.
- *
- * ARGUMENTS
- * severity Severity as documented in sys/syslog.h (i.e. LOG_ERR)
- * fmt Format string as used with printf.
- *
- * RETURN VALUES
- * On success, 0 is returned. On error, -1 is returned.
- *
- * NOTES
- * Inability to contact the logging daemon is the only source of error
- * for this function. Thus, it would behoove you to try a clulog before
- * daemonizing your process. If it fails, print a message to stderr
- * explaining that the cluster logging daemon should probably be started.
- * If you really want your message to be heard by someone, use
- * clulog_and_print().
- */
-#define clulog(x,fmt,args...) do_clulog(x,0,0,NULL,fmt,##args)
-#define clulog_pid(x,pid,prog,fmt,args...) do_clulog(x,0,pid,prog,fmt,##args)
-
-/*
- * int clulog_and_print(int severity, int write_to_cons, const char *fmt, ...)
- *
- * DESCRIPTION
- * Cluster logging facility. This is a library routine which sends the
- * supplied parameters to the syslog daemon. If the supplied severity is
- * numerically larger than the current loglevel, the message is never sent
- * to the log. This version also prints the given message to the terminal.
- *
- * ARGUMENTS
- * severity Severity as documented in sys/syslog.h (i.e. LOG_ERR)
- * fmt Format string as used with printf.
- *
- * RETURN VALUES
- * On success, 0 is returned. On error, -1 is returned.
- */
-#define clulog_and_print(x,fmt,args...) do_clulog(x,1,0,NULL,fmt,##args)
-
-
-/*
- * void clulog_close(void)
- *
- * DESCRIPTION
- * This is an optional call to close the logfile. This translates into a
- * closelog() call.
- *
- * ARGUMENTS
- * none
- *
- * RETURN VALUES
- * This function does not return anything.
- */
-void clulog_close(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __CLUSTER_LOG_H */
-/*
- * Local variables:
- * c-basic-offset: 8
- * c-indent-level: 8
- * tab-width: 8
- * End:
- */
diff --git a/cman/qdisk/daemon_init.c b/cman/qdisk/daemon_init.c
index 4fd0309..21aebf2 100644
--- a/cman/qdisk/daemon_init.c
+++ b/cman/qdisk/daemon_init.c
@@ -42,6 +42,7 @@
#include <sys/errno.h>
#include <libgen.h>
#include <signal.h>
+#include <openais/service/logsys.h>
/*
* This should ultimately go in a header file.
@@ -56,6 +57,7 @@ int check_process_running(char *prog, pid_t * pid);
static void update_pidfile(char *prog);
static int setup_sigmask(void);
static int diskRawRead(target_info_t *disk, char *buf, int len);
uint32_t clu_crc32(const char *data, size_t count);
+LOGSYS_DECLARE_SUBSYS ("QDISK", LOG_LEVEL_INFO);
/**
* Swap the bytes of a shared header so that it's always in big-endian form
@@ -119,7 +121,7 @@ header_generate(shared_header_t *hdr, const char *data, size_t count)
hdr->h_length = (uint32_t)count;
get_my_score(&score, &score_max);
if (score_max < ctx->qc_scoremin) {
- clulog(LOG_WARNING, "Minimum score (%d) is impossible to "
+ log_printf(LOG_WARNING, "Minimum score (%d) is impossible to "
"achieve (heuristic total = %d)
",
ctx->qc_scoremin, score_max);
}
@@ -882,7 +889,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
if (score < score_req) {
clear_bit(mask, (ctx->qc_my_id-1), sizeof(mask));
if (ctx->qc_status > S_NONE) {
- clulog(LOG_NOTICE,
+ log_printf(LOG_NOTICE,
"Score insufficient for master "
"operation (%d/%d; required=%d); "
"downgrading
",
@@ -892,7 +899,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
++msg.m_seq;
bid_pending = 0;
if (cman_alive(ctx->qc_ch) < 0) {
- clulog(LOG_ERR, "cman: %s
",
+ log_printf(LOG_ERR, "cman: %s
",
strerror(errno));
} else {
cman_poll_quorum_device(ctx->qc_ch, 0);
@@ -903,7 +910,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
} else {
set_bit(mask, (ctx->qc_my_id-1), sizeof(mask));
if (ctx->qc_status == S_NONE) {
- clulog(LOG_NOTICE,
+ log_printf(LOG_NOTICE,
"Score sufficient for master "
"operation (%d/%d; required=%d); "
"upgrading
",
@@ -922,7 +929,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
/* Resolve master conflict, if one exists */
if (count >= 1 && ctx->qc_status == S_MASTER &&
ctx->qc_master != ctx->qc_my_id) {
- clulog(LOG_WARNING, "Master conflict: abdicating
");
+ log_printf(LOG_WARNING, "Master conflict: abdicating
");
/* Handle just like a recent upgrade */
ctx->qc_status = S_RUN;
@@ -945,7 +952,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
upgraded.
*/
- clulog(LOG_DEBUG,"Making bid for master
");
+ log_printf(LOG_DEBUG,"Making bid for master
");
msg.m_msg = M_BID;
++msg.m_seq;
bid_pending = 1;
@@ -972,7 +979,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
if (bid_pending < (ctx->qc_master_wait))
break;
- clulog(LOG_INFO,
+ log_printf(LOG_INFO,
"Assuming master role
");
ctx->qc_status = S_MASTER;
case 2:
@@ -988,7 +995,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
/* We think we're master, but someone else claims
that they are master. */
- clulog(LOG_CRIT,
+ log_printf(LOG_CRIT,
"A master exists, but it's not me?!
");
/* XXX Handle this how? Should not happen*/
/* reboot(RB_AUTOBOOT); */
@@ -1000,9 +1007,9 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
We can't be the master unless we score high
enough on our heuristics. */
if (cman_alive(ctx->qc_ch) < 0) {
- clulog(LOG_ERR, "cman_dispatch: %s
",
+ log_printf(LOG_ERR, "cman_dispatch: %s
",
strerror(errno));
- clulog(LOG_ERR,
+ log_printf(LOG_ERR,
"Halting qdisk operations
");
return -1;
}
@@ -1020,9 +1027,9 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
ctx->qc_my_id-1,
sizeof(memb_mask_t))) {
if (cman_alive(ctx->qc_ch) < 0) {
- clulog(LOG_ERR, "cman_dispatch: %s
",
+ log_printf(LOG_ERR, "cman_dispatch: %s
",
strerror(errno));
- clulog(LOG_ERR,
+ log_printf(LOG_ERR,
"Halting qdisk operations
");
return -1;
}
@@ -1033,7 +1040,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
/* Write out our status */
if (qd_write_status(ctx, ctx->qc_my_id, ctx->qc_status,
&msg, mask, master_mask) != 0) {
- clulog(LOG_ERR, "Error writing to quorum disk
");
+ log_printf(LOG_ERR, "Error writing to quorum disk
");
}
/* write out our local status */
@@ -1049,7 +1056,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
*/
if (_cmp_tv(&maxtime, &diff) == 1 &&
ctx->qc_flags & RF_PARANOID) {
- clulog(LOG_EMERG, "Failed to complete a cycle within "
+ log_printf(LOG_EMERG, "Failed to complete a cycle within "
"%d second%s (%d.%06d) - REBOOTING
",
(int)maxtime.tv_sec,
maxtime.tv_sec==1?"":"s",
@@ -1068,7 +1075,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
if (_cmp_tv(&diff, &interval) == 1) {
_diff_tv(&sleeptime, &diff, &interval);
} else {
- clulog(LOG_WARNING, "qdisk cycle took more "
+ log_printf(LOG_WARNING, "qdisk cycle took more "
"than %d second%s to complete (%d.%06d)
",
ctx->qc_interval, ctx->qc_interval==1?"":"s",
(int)diff.tv_sec, (int)diff.tv_usec);
@@ -1093,7 +1100,7 @@ quorum_logout(qd_ctx *ctx)
/* Write out our status */
if (qd_write_status(ctx, ctx->qc_my_id, S_NONE,
NULL, NULL, NULL) != 0) {
- clulog(LOG_WARNING,
+ log_printf(LOG_WARNING,
"Error writing to quorum disk during logout
");
}
return 0;
@@ -1111,11 +1118,11 @@ get_config_data(char *cluster_name, qd_ctx *ctx, struct h_data *h, int maxh,
char query[256];
char *val;
- clulog(LOG_DEBUG, "Loading configuration information
");
+ log_printf(LOG_DEBUG, "Loading configuration information
");
ccsfd = ccs_force_connect(cluster_name, 1);
if (ccsfd < 0) {
- clulog(LOG_CRIT, "Connection to CCSD failed; cannot start
");
+ log_printf(LOG_CRIT, "Connection to CCSD failed; cannot start
");
return -1;
}