cluster/cman/daemon ais.c barrier.c cmanccs.c ...
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: pcaulfield at sourceware.org 2007-09-17 08:03:37
Modified files:
cman/daemon : ais.c barrier.c cmanccs.c commands.c daemon.c
logging.c logging.h
Log message:
Use openais logsys functions.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/ais.c.diff?cvsroot=cluster&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/barrier.c.diff?cvsroot=cluster&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/commands.c.diff?cvsroot=cluster&r1=1.70&r2=1.71
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/daemon.c.diff?cvsroot=cluster&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/logging.c.diff?cvsroot=cluster&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/logging.h.diff?cvsroot=cluster&r1=1.7&r2=1.8
cman/daemon/ais.c +4 -4
@@ -36,7 +36,7 @@#include <openais/service/config.h> #include <openais/lcr/lcr_comp.h> #include <openais/service/swab.h> -#include <openais/service/print.h> +#include <openais/service/logsys.h> #include "cnxman-socket.h" #include "commands.h"
@@ -204,9 +204,7 @@/* Initialise early logging */ if (getenv ("CMAN_DEBUGLOG" )) - { debug_mask =atoi (getenv ("CMAN_DEBUGLOG" )); - }if (getenv ("CMAN_PIPE" )) startup_pipe =atoi (getenv ("CMAN_PIPE" ));
@@ -242,7 +240,7 @@ {unsigned int object_handle; -/* We can only work if our config inerface was run first */ +/* We can only work if our config interface was run first */ if (!config_run)return 0 ;
@@ -269,6 +267,8 @@close (startup_pipe); startup_pipe =0 ; +cman_flush_debuglog (); +/* Start totem */ totempg_groups_initialize (&group_handle, cman_deliver_fn, cman_confchg_fn);totempg_groups_join (group_handle, cman_group,1 );
cman/daemon/barrier.c +1 -1
@@ -240,7 +240,7 @@/* See if it already exists */ if ((barrier =find_barrier (name))) {if (nodes != barrier->expected_nodes) { -log_msg (LOG_ERR ,"Barrier registration failed for '%s', expected nodes=%d, requested=%d\n" , +log_printf (LOG_ERR ,"Barrier registration failed for '%s', expected nodes=%d, requested=%d\n" , name, barrier->expected_nodes, nodes);return -EINVAL ; }
cman/daemon/cmanccs.c +24 -24
187 lines not on this page · raw message
cman/daemon/commands.c +25 -25
177 lines not on this page · raw message
cman/daemon/daemon.c +6 -6
@@ -337,7 +337,7 @@unlink (name); local_socket =socket (PF_UNIX ,SOCK_STREAM ,0 );if (local_socket <0 ) { -log_msg (LOG_ERR ,"Can't create local socket %s: %s\n" , name,strerror (errno)); +log_printf (LOG_ERR ,"Can't create local socket %s: %s\n" , name,strerror (errno));write_cman_pipe ("Can't create local cman socket" );return -1 ; }
@@ -349,13 +349,13 @@memcpy (sockaddr.sun_path, name, name_len); sockaddr.sun_family =AF_UNIX ;if (bind (local_socket, (struct sockaddr *) &sockaddr,sizeof (sockaddr))) { -log_msg (LOG_ERR ,"can't bind local socket to %s: %s\n" , name,strerror (errno)); +log_printf (LOG_ERR ,"can't bind local socket to %s: %s\n" , name,strerror (errno));write_cman_pipe ("Can't bind to local cman socket" );close (local_socket);return -1 ; }if (listen (local_socket,1 ) !=0 ) { -log_msg (LOG_ERR ,"listen on %s failed: %s\n" , name,strerror (errno)); +log_printf (LOG_ERR ,"listen on %s failed: %s\n" , name,strerror (errno));write_cman_pipe ("listen failed on local cman socket" );close (local_socket);return -1 ;
@@ -366,7 +366,7 @@ con =malloc (sizeof (struct connection ));if (!con) { -log_msg (LOG_ERR ,"Can't allocate space for local connection: %s\n" ,strerror (errno)); +log_printf (LOG_ERR ,"Can't allocate space for local connection: %s\n" ,strerror (errno));write_cman_pipe ("malloc failed for connection info" );close (local_socket);return -1 ;
@@ -481,8 +481,8 @@ ais_poll_handle = aisexec_poll_handle;barrier_init (); -log_msg (LOG_INFO ,"CMAN %s (built %s %s) started\n" , -RELEASE_VERSION , __DATE__, __TIME__); +log_printf (LOG_INFO ,"CMAN %s (built %s %s) started\n" , +RELEASE_VERSION , __DATE__, __TIME__); fd =open_local_sock (CLIENT_SOCKNAME ,sizeof (CLIENT_SOCKNAME ),0660 , ais_poll_handle,CON_CLIENT );if (fd <0 )
cman/daemon/logging.c +8 -58
83 lines not on this page · raw message
cman/daemon/logging.h +8 -7
@@ -9,9 +9,9 @@** ******************************************************************************* ******************************************************************************/ - -extern void log_msg (int priority,char *fmt, ...); +#include <openais/service/logsys.h> extern void init_debug (int subsystems); +extern void cman_flush_debuglog (void );extern void set_debuglog (int subsystems);/* Debug macros */
@@ -21,9 +21,10 @@#define CMAN_DEBUG_DAEMON 8#define CMAN_DEBUG_AIS 16 -extern void log_debug (int subsys,int stamp,const char *fmt, ...); +extern unsigned int logsys_subsys_id; +extern int subsys_mask; -#define P_BARRIER(fmt, args...) log_debug(CMAN_DEBUG_BARRIER, 1, fmt, ## args) -#define P_MEMB(fmt, args...) log_debug(CMAN_DEBUG_MEMB, 1, fmt, ## args) -#define P_DAEMON(fmt, args...) log_debug(CMAN_DEBUG_DAEMON, 1, fmt, ## args) -#define P_AIS(fmt, args...) log_debug(CMAN_DEBUG_AIS, 1, fmt, ## args) +#define P_BARRIER(fmt, args...) if (subsys_mask & CMAN_DEBUG_BARRIER) log_printf(logsys_mkpri(LOG_LEVEL_DEBUG, logsys_subsys_id), "barrier: " fmt, ## args) +#define P_MEMB(fmt, args...) if (subsys_mask & CMAN_DEBUG_MEMB) log_printf(LOG_LEVEL_DEBUG , "memb: " fmt, ## args) +#define P_DAEMON(fmt, args...) if (subsys_mask & CMAN_DEBUG_DAEMON) log_printf(LOG_LEVEL_DEBUG , "daemon: " fmt, ## args) +#define P_AIS(fmt, args...) if (subsys_mask & CMAN_DEBUG_AIS) log_printf(LOG_LEVEL_DEBUG, "ais " fmt, ## args)
Patrick,
I think the usage of this isnt quite right.
You should be suing DECLARE_LOGSYS_SUBSYS in your plugin C files to declare the CMAN logging system. Also the use of the config API is a bit tricky since the executive also uses this same API. It is designed to be called by only one subsystem.
Regards
-steve
Quoted 640 lines · pcaulfield at sourceware.org
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: pcaulfield at sourceware.org 2007-09-17 08:03:37Modified files:
cman/daemon :ais.cbarrier.ccmanccs.ccommands.cdaemon.c
logging.clogging.hLog message:
Use openais logsys functions.Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/ais.c.diff?cvsroot=cluster&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/barrier.c.diff?cvsroot=cluster&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/commands.c.diff?cvsroot=cluster&r1=1.70&r2=1.71
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/daemon.c.diff?cvsroot=cluster&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/logging.c.diff?cvsroot=cluster&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/logging.h.diff?cvsroot=cluster&r1=1.7&r2=1.8cman/daemon/ais.c +4
-4@@ -36,7 +36,7 @@#include <openais/service/config.h> #include <openais/lcr/lcr_comp.h> #include <openais/service/swab.h> -#include <openais/service/print.h> +#include <openais/service/logsys.h> #include "cnxman-socket.h" #include "commands.h" @@ -204,9 +204,7 @@/* Initialise early logging */ if (getenv ("CMAN_DEBUGLOG" )) - { debug_mask =atoi (getenv ("CMAN_DEBUGLOG" )); - }if (getenv ("CMAN_PIPE" )) startup_pipe =atoi (getenv ("CMAN_PIPE" ));@@ -242,7 +240,7 @@ {unsigned int object_handle; -/* We can only work if our config inerface was run first */ +/* We can only work if our config interface was run first */ if (!config_run)return 0 ;@@ -269,6 +267,8 @@close (startup_pipe); startup_pipe =0 ; +cman_flush_debuglog (); +/* Start totem */ totempg_groups_initialize (&group_handle, cman_deliver_fn, cman_confchg_fn);totempg_groups_join (group_handle, cman_group,1 );cman/daemon/barrier.c +1
-1@@ -240,7 +240,7 @@/* See if it already exists */ if ((barrier =find_barrier (name))) {if (nodes != barrier->expected_nodes) { -log_msg (LOG_ERR ,"Barrier registration failed for '%s', expected nodes=%d, requested=%d\n" , +log_printf (LOG_ERR ,"Barrier registration failed for '%s', expected nodes=%d, requested=%d\n" , name, barrier->expected_nodes, nodes);return -EINVAL ; }cman/daemon/cmanccs.c +24
-24@@ -102,7 +102,7 @@/* Open the config file */ ctree =ccs_force_connect (NULL ,1 );if (ctree <0 ) { -log_msg (LOG_ERR ,"Error connecting to CCS" ); +log_printf (LOG_ERR ,"Error connecting to CCS" );write_cman_pipe ("Cannot connect to CCS" );return -1 ; }@@ -156,7 +156,7 @@char message[132 ];sprintf (message,"No node ID for %s, run 'ccs_tool addnodeids' to fix" , nodename); -log_msg (LOG_ERR , message); +log_printf (LOG_ERR , message);write_cman_pipe (message);return -1 ; }@@ -190,7 +190,7 @@default a multicast address */ ret =getaddrinfo (nodenames[0 ],NULL , &ahints, &ainfo);if (ret) { -log_msg (LOG_ERR ,"Can't determine address family of nodename %s\n" , nodenames[0 ]); +log_printf (LOG_ERR ,"Can't determine address family of nodename %s\n" , nodenames[0 ]);write_cman_pipe ("Can't determine address family of nodename" );return NULL ; }@@ -402,12 +402,12 @@/* Connect to ccsd */ if (getenv ("CMAN_CLUSTER_NAME" )) { cname =getenv ("CMAN_CLUSTER_NAME" ); -log_msg (LOG_INFO ,"Using override cluster name %s\n" , cname); +log_printf (LOG_INFO ,"Using override cluster name %s\n" , cname); } cd =ccs_force_connect (cname,1 );if (cd <0 ) { -log_msg (LOG_ERR ,"Error connecting to CCS" ); +log_printf (LOG_ERR ,"Error connecting to CCS" );write_cman_pipe ("Can't connect to CCSD" );return -ENOTCONN ; }@@ -415,14 +415,14 @@/* Cluster name */ error =ccs_get (cd,CLUSTER_NAME_PATH , &str);if (error) { -log_msg (LOG_ERR ,"cannot find cluster name in config file" ); +log_printf (LOG_ERR ,"cannot find cluster name in config file" );write_cman_pipe ("Can't find cluster name in CCS" );return -ENOENT ; }if (cname) {if (strcmp (cname, str)) { -log_msg (LOG_ERR ,"cluster names not equal %s %s" , cname, str); +log_printf (LOG_ERR ,"cluster names not equal %s %s" , cname, str);write_cman_pipe ("Cluster name in CCS does not match that passed to cman_tool" );return -ENOENT ; }@@ -445,7 +445,7 @@if (getenv ("CMAN_NODENAME" )) {strcpy (nodename,getenv ("CMAN_NODENAME" )); -log_msg (LOG_INFO ,"Using override node name %s\n" , nodename); +log_printf (LOG_INFO ,"Using override node name %s\n" , nodename);sprintf (path,NODE_NAME_PATH_BYNAME , nodename);@@ -454,7 +454,7 @@free (str); }else { -log_msg (LOG_ERR ,"Overridden node name %s is not in CCS" , nodename); +log_printf (LOG_ERR ,"Overridden node name %s is not in CCS" , nodename);write_cman_pipe ("Overridden node name is not in CCS" );return -ENOENT ; }@@ -463,7 +463,7 @@struct utsname utsname; error =uname (&utsname);if (error) { -log_msg (LOG_ERR ,"cannot get node name, uname failed" ); +log_printf (LOG_ERR ,"cannot get node name, uname failed" );write_cman_pipe ("Can't determine local node name" );return -ENOENT ; }@@ -474,7 +474,7 @@/* Find our nodename in cluster.conf */ error =verify_nodename (cd, nodename);if (error) { -log_msg (LOG_ERR ,"local node name \"%s\" not found in cluster.conf" , +log_printf (LOG_ERR ,"local node name \"%s\" not found in cluster.conf" , nodename);write_cman_pipe ("Can't find local node name in cluster.conf" );return -ENOENT ;@@ -485,11 +485,11 @@if (getenv ("CMAN_EXPECTEDVOTES" )) { expected_votes =atoi (getenv ("CMAN_EXPECTEDVOTES" ));if (expected_votes <1 ) { -log_msg (LOG_ERR ,"CMAN_EXPECTEDVOTES environment variable is invalid, ignoring" ); +log_printf (LOG_ERR ,"CMAN_EXPECTEDVOTES environment variable is invalid, ignoring" ); expected_votes =0 ; }else { -log_msg (LOG_INFO ,"Using override expected votes %d\n" , expected_votes); +log_printf (LOG_INFO ,"Using override expected votes %d\n" , expected_votes); } }@@ -515,7 +515,7 @@ vote_sum++; else {if (atoi (str) <0 ) { -log_msg (LOG_ERR ,"negative votes not allowed" ); +log_printf (LOG_ERR ,"negative votes not allowed" );write_cman_pipe ("Found negative votes for this node in CCS" );return -EINVAL ; }@@ -537,7 +537,7 @@/* optional port */ if (getenv ("CMAN_IP_PORT" )) { port =atoi (getenv ("CMAN_IP_PORT" )); -log_msg (LOG_INFO ,"Using override IP port %d\n" , port); +log_printf (LOG_INFO ,"Using override IP port %d\n" , port); }if (!port) {@@ -565,7 +565,7 @@/* find our own number of votes */ if (getenv ("CMAN_VOTES" )) { votes =atoi (getenv ("CMAN_VOTES" )); -log_msg (LOG_INFO ,"Using override votes %d\n" , votes); +log_printf (LOG_INFO ,"Using override votes %d\n" , votes); }if (!votes) {@@ -576,7 +576,7 @@if (!error) {int votestmp =atoi (str);if (votestmp <0 || votestmp >255 ) { -log_msg (LOG_ERR ,"invalid votes value %d" , votes); +log_printf (LOG_ERR ,"invalid votes value %d" , votes);write_cman_pipe ("Found invalid votes for node in CCS" );return -EINVAL ; }@@ -592,7 +592,7 @@/* nodeid */ if (getenv ("CMAN_NODEID" )) { nodeid =atoi (getenv ("CMAN_NODEID" )); -log_msg (LOG_INFO ,"Using override nodeid %d\n" , nodeid); +log_printf (LOG_INFO ,"Using override nodeid %d\n" , nodeid); }if (!nodeid) {@@ -607,14 +607,14 @@ }if (!nodeid) { -log_msg (LOG_ERR ,"No nodeid specified in cluster.conf" ); +log_printf (LOG_ERR ,"No nodeid specified in cluster.conf" );write_cman_pipe ("CCS does not have a nodeid for this node, run 'ccs_tool addnodeids' to fix" );return -EINVAL ; }if (getenv ("CMAN_MCAST_ADDR" )) { mcast_name =getenv ("CMAN_MCAST_ADDR" ); -log_msg (LOG_INFO ,"Using override multicast address %s\n" , mcast_name); +log_printf (LOG_INFO ,"Using override multicast address %s\n" , mcast_name); }/* Optional multicast name */ @@ -627,7 +627,7 @@if (!mcast_name) { mcast_name =default_mcast (cluster_id); -log_msg (LOG_INFO ,"Using default multicast address of %s\n" , mcast_name); +log_printf (LOG_INFO ,"Using default multicast address of %s\n" , mcast_name); } mcast[0 ] = mcast_name;@@ -678,7 +678,7 @@free (str);if (two_node) {if (node_count !=2 || vote_sum !=2 ) { -log_msg (LOG_ERR ,"the two-node option requires exactly two " +log_printf (LOG_ERR ,"the two-node option requires exactly two " "nodes with one vote each and expected " "votes of 1 (node_count=%d vote_sum=%d)" , node_count, vote_sum);@@ -687,7 +687,7 @@ }if (votes !=1 ) { -log_msg (LOG_ERR ,"the two-node option requires exactly two " +log_printf (LOG_ERR ,"the two-node option requires exactly two " "nodes with one vote each and expected " "votes of 1 (votes=%d)" , votes);write_cman_pipe ("two_node set but votes not set to 1" );@@ -710,7 +710,7 @@ error =get_ccs_join_info ();if (error) { -log_msg (LOG_ERR ,"Error reading CCS info, cannot start" ); +log_printf (LOG_ERR ,"Error reading CCS info, cannot start" );return error; }cman/daemon/commands.c +25
-25@@ -34,7 +34,7 @@#include <openais/totem/totemip.h> #include <openais/totem/totempg.h> #include <openais/service/swab.h> -#include <openais/service/print.h> +#include <openais/service/logsys.h> #include <openais/service/timer.h> #include <openais/totem/aispoll.h> #include "list.h" @@ -159,9 +159,9 @@ }if (cluster_is_quorate && !quorate) -log_msg (LOG_INFO ,"quorum lost, blocking activity\n" ); +log_printf (LOG_INFO ,"quorum lost, blocking activity\n" );if (!cluster_is_quorate && quorate) -log_msg (LOG_INFO ,"quorum regained, resuming activity\n" ); +log_printf (LOG_INFO ,"quorum regained, resuming activity\n" );/* If we are newly quorate, then kill any AISONLY nodes */ if (!cluster_is_quorate && quorate) {@@ -404,7 +404,7 @@ ais_running =1 ;if (read_ccs_nodes (&config_version,1 )) { -log_msg (LOG_ERR ,"Can't initialise list of nodes from CCS\n" ); +log_printf (LOG_ERR ,"Can't initialise list of nodes from CCS\n" );return -EINVAL ; }@@ -997,7 +997,7 @@/* Keep this list valid so it doesn't confuse other code */ list_init (&quorum_device->addr_list); -log_msg (LOG_INFO ,"quorum device registered\n" ); +log_printf (LOG_INFO ,"quorum device registered\n" );return 0 ; }@@ -1014,7 +1014,7 @@ quorum_device =NULL ; -log_msg (LOG_INFO ,"quorum device unregistered\n" ); +log_printf (LOG_INFO ,"quorum device unregistered\n" );return 0 ; }@@ -1022,17 +1022,17 @@ {int ccs_err; -log_msg (LOG_DEBUG ,"Polling ccsd for updated information\n" ); +log_printf (LOG_DEBUG ,"Polling ccsd for updated information\n" ); ccs_err =read_ccs_nodes (&config_version,0 );if (ccs_err || config_version < wanted_config_version) { -log_msg (LOG_ERR ,"Can't read CCS to get updated config version %d. Activity suspended on this node\n" , - wanted_config_version); +log_printf (LOG_ERR ,"Can't read CCS to get updated config version %d. Activity suspended on this node\n" , + wanted_config_version);openais_timer_add_duration ((unsigned long long )ccsd_poll_interval*1000000 ,NULL , ccsd_timer_fn, &ccsd_timer); }else { -log_msg (LOG_ERR ,"Now got CCS information version %d, continuing\n" , config_version); +log_printf (LOG_ERR ,"Now got CCS information version %d, continuing\n" , config_version); config_error =0 ;recalculate_quorum (0 ,0 ); }@@ -1048,7 +1048,7 @@gettimeofday (&now,NULL );if (quorum_device->last_hello.tv_sec + quorumdev_poll/1000 < now.tv_sec) { quorum_device->state =NODESTATE_DEAD ; -log_msg (LOG_INFO ,"lost contact with quorum device\n" ); +log_printf (LOG_INFO ,"lost contact with quorum device\n" );recalculate_quorum (0 ,0 ); }else {@@ -1478,20 +1478,20 @@static int valid_transition_msg (int nodeid,struct cl_transmsg *msg) {if (strcmp (msg->clustername, cluster_name) !=0 ) { -log_msg (LOG_ERR ,"Node %d conflict, remote cluster name='%s', local='%s'\n" , +log_printf (LOG_ERR ,"Node %d conflict, remote cluster name='%s', local='%s'\n" , nodeid, msg->clustername, cluster_name);return -1 ; }if (msg->cluster_id != cluster_id) { -log_msg (LOG_ERR ,"Node %d conflict, remote cluster id=%d, local=%d\n" , +log_printf (LOG_ERR ,"Node %d conflict, remote cluster id=%d, local=%d\n" , nodeid, msg->cluster_id, cluster_id);return -1 ; }if (msg->major_version !=CNXMAN_MAJOR_VERSION ) { -log_msg (LOG_ERR ,"Node %d conflict, remote version id=%d, local=%d\n" , +log_printf (LOG_ERR ,"Node %d conflict, remote version id=%d, local=%d\n" , nodeid, msg->major_version,CNXMAN_MAJOR_VERSION );return -1 ; }@@ -1503,7 +1503,7 @@ ccs_err =read_ccs_nodes (&config_version,0 );if (ccs_err || config_version < msg->config_version) { config_error =1 ; -log_msg (LOG_ERR ,"Can't read CCS to get updated config version %d. Activity suspended on this node\n" , +log_printf (LOG_ERR ,"Can't read CCS to get updated config version %d. Activity suspended on this node\n" , msg->config_version); wanted_config_version = msg->config_version;@@ -1518,7 +1518,7 @@if (msg->config_version != config_version) { -log_msg (LOG_ERR ,"Node %d conflict, remote config version id=%d, local=%d\n" , +log_printf (LOG_ERR ,"Node %d conflict, remote config version id=%d, local=%d\n" , nodeid, msg->config_version, config_version);return -1 ; }@@ -1660,7 +1660,7 @@case RECONFIG_PARAM_CONFIG_VERSION :if (read_ccs_nodes (&config_version,0 )) { -log_msg (LOG_ERR ,"Can't read CCS to get updated config version %d. Activity suspended on this node\n" , +log_printf (LOG_ERR ,"Can't read CCS to get updated config version %d. Activity suspended on this node\n" , msg->value); config_error =1 ;@@ -1839,7 +1839,7 @@case CLUSTER_MSG_PORTSTATUS :if (nodeid != us->node_id) { -P_MEMB ("got PORTRESULT from %d, low bytes = %x %x\n" , data[1 ], data[2 ]); +P_MEMB ("got PORTRESULT from %d, low bytes = %x %x\n" , nodeid, data[1 ], data[2 ]);if (node)memcpy (node->port_bits, data+1 ,PORT_BITS_SIZE ); }@@ -1854,7 +1854,7 @@ killmsg = (struct cl_killmsg *)data;P_MEMB ("got KILL for node %d\n" , killmsg->nodeid);if (killmsg->nodeid == wanted_nodeid) { -log_msg (LOG_INFO ,"cman killed by node %d because %s\n" , nodeid, +log_printf (LOG_INFO ,"cman killed by node %d because %s\n" , nodeid,killmsg_reason (killmsg->reason));exit (1 ); }@@ -1896,7 +1896,7 @@break ;default : -log_msg (LOG_WARNING ,"Unknown protocol message %d received\n" , msg->cmd); +log_printf (LOG_WARNING ,"Unknown protocol message %d received\n" , msg->cmd);break ; }@@ -1926,11 +1926,11 @@if (totemip_parse (&ipaddr, nodename,0 )) {if (!nodeid) { -log_msg (LOG_ERR ,"Error, can't find IP address and no nodeid for node %s - ignoring it\n" , nodename); +log_printf (LOG_ERR ,"Error, can't find IP address and no nodeid for node %s - ignoring it\n" , nodename);return ; }else { -log_msg (LOG_WARNING ,"Warning, can't resolve IP address for node %s\n" , nodename); +log_printf (LOG_WARNING ,"Warning, can't resolve IP address for node %s\n" , nodename);memset (&ipaddr,0 ,sizeof (ipaddr)); } }@@ -1943,7 +1943,7 @@ {struct cluster_node *node; -P_MEMB ("add_ais_node ID=%d, incarnation = %d\n" ,nodeid, incarnation); +P_MEMB ("add_ais_node ID=%d, incarnation = %lld\n" ,nodeid, incarnation); node =find_node_by_nodeid (nodeid);if (!node && total_members ==1 ) {@@ -1956,11 +1956,11 @@char tempname[256 ]; node =malloc (sizeof (struct cluster_node ));if (!node) { -log_msg (LOG_ERR ,"error allocating node struct for id %d, but CCS doesn't know about it anyway\n" , +log_printf (LOG_ERR ,"error allocating node struct for id %d, but CCS doesn't know about it anyway\n" , nodeid);return ; } -log_msg (LOG_ERR ,"Got node from AIS id %d with no CCS entry\n" , nodeid); +log_printf (LOG_ERR ,"Got node from AIS id %d with no CCS entry\n" , nodeid);memset (node,0 ,sizeof (struct cluster_node ));node_add_ordered (node);cman/daemon/daemon.c +6
-6@@ -337,7 +337,7 @@unlink (name); local_socket =socket (PF_UNIX ,SOCK_STREAM ,0 );if (local_socket <0 ) { -log_msg (LOG_ERR ,"Can't create local socket %s: %s\n" , name,strerror (errno)); +log_printf (LOG_ERR ,"Can't create local socket %s: %s\n" , name,strerror (errno));write_cman_pipe ("Can't create local cman socket" );return -1 ; }@@ -349,13 +349,13 @@memcpy (sockaddr.sun_path, name, name_len); sockaddr.sun_family =AF_UNIX ;if (bind (local_socket, (struct sockaddr *) &sockaddr,sizeof (sockaddr))) { -log_msg (LOG_ERR ,"can't bind local socket to %s: %s\n" , name,strerror (errno)); +log_printf (LOG_ERR ,"can't bind local socket to %s: %s\n" , name,strerror (errno));write_cman_pipe ("Can't bind to local cman socket" );close (local_socket);return -1 ; }if (listen (local_socket,1 ) !=0 ) { -log_msg (LOG_ERR ,"listen on %s failed: %s\n" , name,strerror (errno)); +log_printf (LOG_ERR ,"listen on %s failed: %s\n" , name,strerror (errno));write_cman_pipe ("listen failed on local cman socket" );close (local_socket);return -1 ;@@ -366,7 +366,7 @@ con =malloc (sizeof (struct connection ));if (!con) { -log_msg (LOG_ERR ,"Can't allocate space for local connection: %s\n" ,strerror (errno)); +log_printf (LOG_ERR ,"Can't allocate space for local connection: %s\n" ,strerror (errno));write_cman_pipe ("malloc failed for connection info" );close (local_socket);return -1 ;@@ -481,8 +481,8 @@ ais_poll_handle = aisexec_poll_handle;barrier_init (); -log_msg (LOG_INFO ,"CMAN %s (built %s %s) started\n" , -RELEASE_VERSION , __DATE__, __TIME__); +log_printf (LOG_INFO ,"CMAN %s (built %s %s) started\n" , +RELEASE_VERSION , __DATE__, __TIME__); fd =open_local_sock (CLIENT_SOCKNAME ,sizeof (CLIENT_SOCKNAME ),0660 , ais_poll_handle,CON_CLIENT );if (fd <0 )cman/daemon/logging.c +8
-58@@ -21,32 +21,17 @@#include <sys/socket.h> #include <netinet/in.h> -/* openais header */ -#include <openais/service/print.h> - +#include <openais/service/logsys.h> #include "logging.h" -/* All logging comes through here so it can be stamped [CMAN] */ - -static int use_stderr =0 ; +/* Make this global so that all of cman can use the same subsys name */ +unsigned int logsys_subsys_id;int subsys_mask =0 ; -void log_msg (int priority,char *fmt, ...) -{ -va_list va; -char log_buf[1024 ]; - -va_start (va, fmt); -vsprintf (log_buf, fmt, va); -va_end (va); -log_printf (priority, log_buf); -} -void init_debug (int subsystems) { -log_init ("CMAN" ); - - use_stderr = (subsystems !=0 ); + logsys_subsys_id =_logsys_subsys_create ("CMAN" , (subsystems?LOG_LEVEL_DEBUG :LOG_LEVEL_WARNING ) ); +logsys_config_mode_set (LOG_MODE_BUFFER_BEFORE_CONFIG | ((subsystems)?LOG_MODE_OUTPUT_STDERR :0 )); subsys_mask = subsystems; }@@ -55,43 +40,8 @@ subsys_mask = subsystems; } -void log_debug (int subsys,int stamp,const char *fmt, ...) + +void cman_flush_debuglog () { -va_list va; -char newfmt[strlen (fmt)+10 ]; -char log_buf[1024 ]; - -if (!(subsys_mask & subsys)) -return ; - -if (stamp) - { -switch (subsys) - { -case CMAN_DEBUG_MEMB : -strcpy (newfmt,"memb: " ); -break ; -case CMAN_DEBUG_DAEMON : -strcpy (newfmt,"daemon: " ); -break ; -case CMAN_DEBUG_BARRIER : -strcpy (newfmt,"barrier: " ); -break ; -case CMAN_DEBUG_AIS : -strcpy (newfmt,"ais: " ); -break ; -default : -break ; - } - } -else - { - newfmt[0 ] ='\0' ; - } -strcat (newfmt, fmt); - -va_start (va, fmt); -vsprintf (log_buf, newfmt, va); -log_printf (LOG_LEVEL_DEBUG , log_buf); -va_end (va); +logsys_config_mode_set (LOG_MODE_FLUSH_AFTER_CONFIG | ((subsys_mask)?LOG_MODE_OUTPUT_STDERR :0 )); }cman/daemon/logging.h +8
-7@@ -9,9 +9,9 @@** ******************************************************************************* ******************************************************************************/ - -extern void log_msg (int priority,char *fmt, ...); +#include <openais/service/logsys.h> extern void init_debug (int subsystems); +extern void cman_flush_debuglog (void );extern void set_debuglog (int subsystems);/* Debug macros */ @@ -21,9 +21,10 @@#define CMAN_DEBUG_DAEMON 8#define CMAN_DEBUG_AIS 16 -extern void log_debug (int subsys,int stamp,const char *fmt, ...); +extern unsigned int logsys_subsys_id; +extern int subsys_mask; -#define P_BARRIER(fmt, args...) log_debug(CMAN_DEBUG_BARRIER, 1, fmt, ## args) -#define P_MEMB(fmt, args...) log_debug(CMAN_DEBUG_MEMB, 1, fmt, ## args) -#define P_DAEMON(fmt, args...) log_debug(CMAN_DEBUG_DAEMON, 1, fmt, ## args) -#define P_AIS(fmt, args...) log_debug(CMAN_DEBUG_AIS, 1, fmt, ## args) +#define P_BARRIER(fmt, args...) if (subsys_mask & CMAN_DEBUG_BARRIER) log_printf(logsys_mkpri(LOG_LEVEL_DEBUG, logsys_subsys_id), "barrier: " fmt, ## args) +#define P_MEMB(fmt, args...) if (subsys_mask & CMAN_DEBUG_MEMB) log_printf(LOG_LEVEL_DEBUG , "memb: " fmt, ## args) +#define P_DAEMON(fmt, args...) if (subsys_mask & CMAN_DEBUG_DAEMON) log_printf(LOG_LEVEL_DEBUG , "daemon: " fmt, ## args) +#define P_AIS(fmt, args...) if (subsys_mask & CMAN_DEBUG_AIS) log_printf(LOG_LEVEL_DEBUG, "ais " fmt, ## args)