diff --git a/cerebro.spec.in b/cerebro.spec.in index 7b0eaf65..55dad4be 100644 --- a/cerebro.spec.in +++ b/cerebro.spec.in @@ -1,4 +1,4 @@ -Name: @PACKAGE@ +Name: @PACKAGE@ Version: @VERSION@ Release: 1 @@ -9,7 +9,7 @@ Source: @PACKAGE@-@VERSION@.tar.gz BuildRequires: systemd Requires: systemd -Requires: /bin/sh +Requires: /bin/sh %description Cerebro is a collection of cluster monitoring tools and libraries. @@ -123,7 +123,7 @@ Event module to monitor node up/down. %{?_enable_static_modules} \ %{?_enable_debug} \ --with-systemdsystemunitdir=%{_unitdir} -make +make %post # are we upgrading? restart it if running diff --git a/config/ac_boottime.m4 b/config/ac_boottime.m4 index 17f411d9..39df7fba 100644 --- a/config/ac_boottime.m4 +++ b/config/ac_boottime.m4 @@ -24,6 +24,6 @@ AC_DEFUN([AC_BOOTTIME], MANPAGE_BOOTTIME=0 ac_with_boottime=no fi - + AC_SUBST(MANPAGE_BOOTTIME) ]) diff --git a/config/ac_cerebro_config_file.m4 b/config/ac_cerebro_config_file.m4 index 59c31150..f49c0707 100644 --- a/config/ac_cerebro_config_file.m4 +++ b/config/ac_cerebro_config_file.m4 @@ -8,19 +8,19 @@ AC_DEFUN([AC_CEREBRO_CONFIG_FILE], AC_MSG_CHECKING([for cerebro config file default path]) AC_ARG_WITH([cerebro-config-file], - AS_HELP_STRING([--with-cerebro-config-file=PATH], + AS_HELP_STRING([--with-cerebro-config-file=PATH], [Specify default cerebro config file path]), [ case "$withval" in no) ;; yes) ;; - *) CEREBRO_CONFIG_FILE_DEFAULT=$withval + *) CEREBRO_CONFIG_FILE_DEFAULT=$withval esac ] ) AC_MSG_RESULT($CEREBRO_CONFIG_FILE_DEFAULT) - AC_DEFINE_UNQUOTED([CEREBRO_CONFIG_FILE_DEFAULT], - ["$CEREBRO_CONFIG_FILE_DEFAULT"], + AC_DEFINE_UNQUOTED([CEREBRO_CONFIG_FILE_DEFAULT], + ["$CEREBRO_CONFIG_FILE_DEFAULT"], [Define default cerebro config_file.]) AC_SUBST(CEREBRO_CONFIG_FILE_DEFAULT) ]) diff --git a/config/ac_cerebro_metric_control_path.m4 b/config/ac_cerebro_metric_control_path.m4 index a2cd831b..3cb9fd6c 100644 --- a/config/ac_cerebro_metric_control_path.m4 +++ b/config/ac_cerebro_metric_control_path.m4 @@ -5,7 +5,7 @@ AC_DEFUN([AC_CEREBRO_METRIC_CONTROL_PATH], [ if test "$ac_debug" = "yes"; then - METRIC_CONTROL_PATH="\"/tmp/cerebro_metric_control\"" + METRIC_CONTROL_PATH="\"/tmp/cerebro_metric_control\"" else # Must expand nested unquoting METRIC_CONTROL_PATH_TMP1="`eval echo ${localstatedir}/run/cerebro_metric_control`" @@ -16,7 +16,7 @@ AC_DEFUN([AC_CEREBRO_METRIC_CONTROL_PATH], AC_MSG_CHECKING([for the metric control path]) AC_ARG_WITH([metric-control-path], - AS_HELP_STRING([--with-metric-control-path], + AS_HELP_STRING([--with-metric-control-path], [Define metric control path]), [ case "$withval" in no) ;; diff --git a/config/ac_cerebro_module_dir.m4 b/config/ac_cerebro_module_dir.m4 index f84d6100..4be836f2 100644 --- a/config/ac_cerebro_module_dir.m4 +++ b/config/ac_cerebro_module_dir.m4 @@ -16,8 +16,8 @@ AC_DEFUN([AC_CEREBRO_MODULE_DIR], CEREBRO_MODULE_DIR=${prefix}/$LIBDIRTYPE/cerebro fi - AC_DEFINE_UNQUOTED([CEREBRO_MODULE_DIR], - ["$CEREBRO_MODULE_DIR"], + AC_DEFINE_UNQUOTED([CEREBRO_MODULE_DIR], + ["$CEREBRO_MODULE_DIR"], [Define default cerebro module dir]) AC_SUBST(CEREBRO_MODULE_DIR) ]) diff --git a/config/ac_cerebrod_speaker_only.m4 b/config/ac_cerebrod_speaker_only.m4 index 93d1ec64..7d984f53 100644 --- a/config/ac_cerebrod_speaker_only.m4 +++ b/config/ac_cerebrod_speaker_only.m4 @@ -15,7 +15,7 @@ AC_DEFUN([AC_CEREBROD_SPEAKER_ONLY], ] ) AC_MSG_RESULT([${ac_cerebrod_speaker_only_test=no}]) - + if test "$ac_cerebrod_speaker_only_test" = "yes"; then AC_DEFINE([WITH_CEREBROD_SPEAKER_ONLY], [1], [Define if you want to build cerebrod with the speaker only]) ac_with_cerebrod_speaker_only=yes @@ -37,7 +37,7 @@ AC_DEFUN([AC_CEREBROD_NO_THREADS], ] ) AC_MSG_RESULT([${ac_cerebrod_no_threads_test=no}]) - + if test "$ac_with_cerebrod_speaker_only" = "yes" && test "$ac_cerebrod_no_threads_test" = "yes"; then AC_DEFINE([WITH_CEREBROD_NO_THREADS], [1], [Define if you want to build cerebrod with no threads (requires --with-cerebrod-speaker-only)]) diff --git a/config/ac_genders.m4 b/config/ac_genders.m4 index d161d230..e1789046 100644 --- a/config/ac_genders.m4 +++ b/config/ac_genders.m4 @@ -15,7 +15,7 @@ AC_DEFUN([AC_GENDERS], ] ) AC_MSG_RESULT([${ac_genders_test=yes}]) - + if test "$ac_genders_test" = "yes"; then AC_CHECK_LIB([genders], [genders_handle_create], [ac_have_genders=yes], []) fi @@ -25,7 +25,7 @@ AC_DEFUN([AC_GENDERS], GENDERS_LIBS="-lgenders" MANPAGE_GENDERS=1 ac_with_genders=yes - else + else MANPAGE_GENDERS=0 ac_with_genders=no fi diff --git a/config/ac_hostsfile.m4 b/config/ac_hostsfile.m4 index 076447ad..9585798a 100644 --- a/config/ac_hostsfile.m4 +++ b/config/ac_hostsfile.m4 @@ -23,7 +23,7 @@ AC_DEFUN([AC_HOSTSFILE], MANPAGE_HOSTSFILE=0 ac_with_hostsfile=no fi - + AC_SUBST(MANPAGE_HOSTSFILE) ]) @@ -33,7 +33,7 @@ AC_DEFUN([AC_HOSTSFILE_PATH], AC_MSG_CHECKING([for default hostsfile path]) AC_ARG_WITH([hostsfile-path], - AS_HELP_STRING([--with-hostsfile-path=PATH], + AS_HELP_STRING([--with-hostsfile-path=PATH], [Specify default hostsfile clusterlist path]), [ case "$withval" in no) ;; @@ -44,8 +44,8 @@ AC_DEFUN([AC_HOSTSFILE_PATH], ) AC_MSG_RESULT($CEREBRO_CLUSTERLIST_HOSTSFILE_DEFAULT) - AC_DEFINE_UNQUOTED([CEREBRO_CLUSTERLIST_HOSTSFILE_DEFAULT], - ["$CEREBRO_CLUSTERLIST_HOSTSFILE_DEFAULT"], + AC_DEFINE_UNQUOTED([CEREBRO_CLUSTERLIST_HOSTSFILE_DEFAULT], + ["$CEREBRO_CLUSTERLIST_HOSTSFILE_DEFAULT"], [Define default hostsfile clusterlist.]) AC_SUBST(CEREBRO_CLUSTERLIST_HOSTSFILE_DEFAULT) ]) diff --git a/config/ac_ipv6.m4 b/config/ac_ipv6.m4 index b2557909..a465f575 100644 --- a/config/ac_ipv6.m4 +++ b/config/ac_ipv6.m4 @@ -17,7 +17,7 @@ AC_DEFUN([AC_IPV6], [ # IEEE standard says it should be in sys/socket.h - AC_CHECK_DECL([AF_INET6], + AC_CHECK_DECL([AF_INET6], AC_DEFINE(HAVE_IPV6,1,[have IPv6]),, - [#include ]) + [#include ]) ]) diff --git a/config/ac_loadavg.m4 b/config/ac_loadavg.m4 index 837c010f..a8a44b97 100644 --- a/config/ac_loadavg.m4 +++ b/config/ac_loadavg.m4 @@ -24,6 +24,6 @@ AC_DEFUN([AC_LOADAVG], MANPAGE_LOADAVG=0 ac_with_loadavg=no fi - + AC_SUBST(MANPAGE_LOADAVG) ]) diff --git a/config/ac_memory.m4 b/config/ac_memory.m4 index c574e02a..77f1a27f 100644 --- a/config/ac_memory.m4 +++ b/config/ac_memory.m4 @@ -24,6 +24,6 @@ AC_DEFUN([AC_MEMORY], MANPAGE_MEMORY=0 ac_with_memory=no fi - + AC_SUBST(MANPAGE_MEMORY) ]) diff --git a/config/ac_network.m4 b/config/ac_network.m4 index 94f4b15c..eccb2b37 100644 --- a/config/ac_network.m4 +++ b/config/ac_network.m4 @@ -24,6 +24,6 @@ AC_DEFUN([AC_NETWORK], MANPAGE_NETWORK=0 ac_with_network=no fi - + AC_SUBST(MANPAGE_NETWORK) ]) diff --git a/config/ac_shutdown.m4 b/config/ac_shutdown.m4 index 5d67d815..9b5b9414 100644 --- a/config/ac_shutdown.m4 +++ b/config/ac_shutdown.m4 @@ -24,6 +24,6 @@ AC_DEFUN([AC_SHUTDOWN], MANPAGE_SHUTDOWN=0 ac_with_shutdown=no fi - + AC_SUBST(MANPAGE_SHUTDOWN) ]) diff --git a/config/ac_slurm_state.m4 b/config/ac_slurm_state.m4 index 5f210b50..152430ae 100644 --- a/config/ac_slurm_state.m4 +++ b/config/ac_slurm_state.m4 @@ -24,21 +24,21 @@ AC_DEFUN([AC_SLURM_STATE], MANPAGE_SLURM_STATE=0 ac_with_slurm_state=no fi - + AC_SUBST(MANPAGE_SLURM_STATE) ]) AC_DEFUN([AC_SLURM_STATE_CONTROL_PATH], [ if test "$ac_debug" = "yes"; then - SLURM_STATE_CONTROL_PATH="/tmp/cerebro_metric_slurm_state" + SLURM_STATE_CONTROL_PATH="/tmp/cerebro_metric_slurm_state" else SLURM_STATE_CONTROL_PATH="$CEREBRO_MODULE_DIR/cerebro_metric_slurm_state" fi AC_MSG_CHECKING([for the slurm state control path]) AC_ARG_WITH([slurm-state-control-path], - AS_HELP_STRING([--with-slurm-state-control-path], + AS_HELP_STRING([--with-slurm-state-control-path], [Define slurm state control path]), [ case "$withval" in no) ;; diff --git a/config/ac_static_modules.m4 b/config/ac_static_modules.m4 index d324bafd..00596973 100644 --- a/config/ac_static_modules.m4 +++ b/config/ac_static_modules.m4 @@ -19,7 +19,7 @@ AC_DEFUN([AC_STATIC_MODULES], if test "$ac_with_static_modules" = "yes"; then AC_DEFINE([WITH_STATIC_MODULES], [1], [Define if builing with static modules]) MANPAGE_STATIC_MODULES=1 - else + else MANPAGE_STATIC_MODULES=0 fi diff --git a/config/ac_struct_sa_len.m4 b/config/ac_struct_sa_len.m4 index 53d1fb6f..46fcb1d9 100644 --- a/config/ac_struct_sa_len.m4 +++ b/config/ac_struct_sa_len.m4 @@ -8,7 +8,7 @@ # AC_STRUCT_SA_LEN # # DESCRIPTION: -# Check for sa_len variable in struct sockaddr_in +# Check for sa_len variable in struct sockaddr_in # # WARNINGS: # This macro must be placed after AC_PROG_CC or equivalent. @@ -18,12 +18,12 @@ AC_DEFUN([AC_STRUCT_SA_LEN], [ AC_CACHE_CHECK([for sa_len in struct sockaddr], ac_cv_struct_sa_len, - AC_TRY_COMPILE([#include #include ], + AC_TRY_COMPILE([#include #include ], [struct sockaddr s; s.sa_len;], - ac_cv_struct_sa_len=yes, + ac_cv_struct_sa_len=yes, ac_cv_struct_sa_len=no)) if test $ac_cv_struct_sa_len = yes; then - AC_DEFINE(HAVE_SA_LEN, [1], [do we have sa_len in struct sockaddr]) + AC_DEFINE(HAVE_SA_LEN, [1], [do we have sa_len in struct sockaddr]) fi ]) diff --git a/config/ac_updown_event.m4 b/config/ac_updown_event.m4 index 5af84a0f..c28caec6 100644 --- a/config/ac_updown_event.m4 +++ b/config/ac_updown_event.m4 @@ -24,6 +24,6 @@ AC_DEFUN([AC_UPDOWN], MANPAGE_UPDOWN=0 ac_with_updown=no fi - + AC_SUBST(MANPAGE_UPDOWN) ]) diff --git a/configure.ac b/configure.ac index 1469ffbe..069a6387 100644 --- a/configure.ac +++ b/configure.ac @@ -20,11 +20,11 @@ AC_CONFIG_HEADERS([config/config.h]) AM_MAINTAINER_MODE # Update this information before a public release only! - + # library versioning # # If the library source code has changed at all since the last update, -# then increment c:r: c:r+1:). +# then increment c:r: c:r+1:). # # If any interfaces have been added, removed, or changed since the # last update, increment current, and set revision to 0. @@ -32,9 +32,9 @@ AM_MAINTAINER_MODE # If any interfaces have been added since the last public release, # then increment age. # -# If any interfaces have been removed or changed since the last public +# If any interfaces have been removed or changed since the last public # release, then set age to 0. -# +# LIBCEREBRO_CURRENT=1 LIBCEREBRO_REVISION=1 LIBCEREBRO_AGE=0 @@ -166,9 +166,9 @@ AM_CONDITIONAL(WITH_UPDOWN, [test "$ac_with_updown" = "yes"]) # Determine which static module libraries do not need to be linked # against under a static module build # -AM_CONDITIONAL(WITH_CLUSTERLIST_STATIC_MODULES, +AM_CONDITIONAL(WITH_CLUSTERLIST_STATIC_MODULES, [(test "$ac_with_static_modules" = "yes") && - (test "$ac_with_genders" = "yes" || + (test "$ac_with_genders" = "yes" || test "$ac_with_hostsfile" = "yes")]) # Placeholder, please don't dailywtf me :-) @@ -182,10 +182,10 @@ AM_CONDITIONAL(WITH_EVENT_STATIC_MODULES, AM_CONDITIONAL(WITH_METRIC_STATIC_MODULES, [(test "$ac_with_static_modules" = "yes") && - (test "$ac_with_boottime" = "yes" || - test "$ac_with_loadavg" = "yes" || - test "$ac_with_memory" = "yes" || - test "$ac_with_network" = "yes" || + (test "$ac_with_boottime" = "yes" || + test "$ac_with_loadavg" = "yes" || + test "$ac_with_memory" = "yes" || + test "$ac_with_network" = "yes" || test "$ac_with_slurm_state" = "yes")]) # Placeholder, please don't dailywtf me :-) diff --git a/man/cerebro-admin.8.in b/man/cerebro-admin.8.in index 4e40f898..939e6480 100644 --- a/man/cerebro-admin.8.in +++ b/man/cerebro-admin.8.in @@ -27,14 +27,14 @@ .SH "NAME" cerebro-admin \- cerebro metric administration .SH "SYNOPSIS" -.B cerebro-admin +.B cerebro-admin .I "[OPTIONS] -m [-r | -u | -p | -s]" .br .SH "DESCRIPTION" The .B cerebro-admin -allows administrators to perform metric administration with -a +allows administrators to perform metric administration with +a .B cerebrod(8) metric server. New metrics can be registered, unregistered, updated or resent. A number of the options below allow for alternate metric diff --git a/man/cerebro-stat.8.in b/man/cerebro-stat.8.in index ef5eb6d0..46e80835 100644 --- a/man/cerebro-stat.8.in +++ b/man/cerebro-stat.8.in @@ -53,22 +53,22 @@ system. The user may specify the .I "-m" -or +or .I "-e" options to retrieve or monitor available metric data and event data. A number of other options specified below allow for alternate output -formats for the +formats for the .I "-m" option. -The +The .I "-l" -and +and .I "-z" can be specified to list available metrics and events respectively. -The default hostname and port used by +The default hostname and port used by .B cerebro-stat can be configured using the cerebro configuration file or having a cerebro configuration loaded. The configuration changes can alter the @@ -79,7 +79,7 @@ suite of tools and libraries. See the .BR cerebro.conf(5) and -.BR cerebro_module(3) +.BR cerebro_module(3) manpages for additional information. .SH "OPTIONS" diff --git a/man/cerebro.7.in b/man/cerebro.7.in index 8a547c05..fba6f8c6 100644 --- a/man/cerebro.7.in +++ b/man/cerebro.7.in @@ -31,7 +31,7 @@ cerebro \- cluster monitoring tools and libraries is a collection of monitoring tools and libraries. It is made up of a daemon, loadable modules, a library, and several tools. -The daemon, +The daemon, .B cerebrod(8), is the core of .B Cerebro. @@ -52,7 +52,7 @@ sends and receives data via a multicast address on a set of defined ports. However, it can be reconfigured to use non-multicast addresses and other alternate default ports. -The metric data that +The metric data that .B cerebrod(8) gathers and sends is dependent on the what data is configured for monitoring. @@ -76,7 +76,7 @@ offer the user the ability to collect/receive monitored data on Before .B cerebro -can be used as a whole it must be configured. +can be used as a whole it must be configured. See .B cerebro.conf(5) for a complete list and description of configuration file options. A @@ -87,7 +87,7 @@ general overview of configuration and setup can be found below. Dynamically loadable modules can be developed for .B cerebrod for a variety of purposes, including configuration, data -gathering/sending, data collection/receiving, or data logging. +gathering/sending, data collection/receiving, or data logging. Most users will likely want to use the @@ -120,7 +120,7 @@ for programming against these events or they can be watched via For more information, see .B libcerebro(3) -and +and .B cerebro_module(3). .SH "COMMON CONFIGURATION AND SETUP" @@ -148,7 +148,7 @@ should be enabled if metric data will be fed into .B cerebrod via .B libcerebro -and/or +and/or .B cerebro-admin. Typically, this means it should be enabled wherever .I cerebrod_speak @@ -186,7 +186,7 @@ is enabled. Tools such as .B cerebro-admin -and +and .B cerebro-stat must commonly access a listening .B cerebrod @@ -198,7 +198,7 @@ and If the default ports chosen by any services of .B cerebro -conflict with existing services, they can be reconfigured +conflict with existing services, they can be reconfigured and alternate default ports via a variety of options. Please see .B cerebro.conf(5) for more details. @@ -216,7 +216,7 @@ and see a list of nodes currently sending/receiving heartbeats. To see if metric data can be sent and collected, on a \fIspeaker\fR node, register a metric and feed some data to -.B cerebrod +.B cerebrod via: .B # /usr/sbin/cerebro-admin -r -m foobar diff --git a/man/cerebro.conf.5.in b/man/cerebro.conf.5.in index 92b5bf31..1617e34f 100644 --- a/man/cerebro.conf.5.in +++ b/man/cerebro.conf.5.in @@ -27,7 +27,7 @@ .SH "NAME" cerebro.conf \- cerebro configuration file .SH "DESCRIPTION" -The +The .B cerebro configuration file configures the features and behavior of the .B libcerebro @@ -42,7 +42,7 @@ for an overview of the .B Cerebro system and common configuration/setup information. -The default configuration file loaded is @CEREBRO_CONFIG_FILE_DEFAULT@. +The default configuration file loaded is @CEREBRO_CONFIG_FILE_DEFAULT@. The configuration options that can be specified in the configuration file are listed below into appropriate sections. Each configuration @@ -58,7 +58,7 @@ backslash (".\"). Specify an alternate default metric server host and port the libcerebro API should attempt to connect to. Metric reading tools such as -.B cerebro-stat +.B cerebro-stat connect to the metric server to read metric data. This option can be listed multiple times to specify multiple hosts. If the port is not specified, a default is assumed. @@ -67,7 +67,7 @@ specified, a default is assumed. .I cerebro_event_server hostname [port] Specify an alternate default event server host and port the libcerebro API should attempt to connect to. Event reading tools such as -.B cerebro-stat +.B cerebro-stat connect to the event server to read event data. This option can be listed multiple times to specify multiple hosts. If the port is not specified, a default is assumed. @@ -84,7 +84,7 @@ default. .I cerebrod_heartbeat_frequency ( sec | sec_min sec_max ) Specify the frequency at which the the .B cerebrod -daemon sends out heartbeat packets containing +daemon sends out heartbeat packets containing .B Cerebro information. The frequency should be specified in seconds. The frequency can be specified either as a static frequency or a range of @@ -116,13 +116,13 @@ specified as a network interface (e.g. eth0), an ip address (e.g. 192.168.1.1) or a subnet using CIDR notation (e.g. 192.168.1.1/16). By default, when a network interface is not specified, -.B cerebrod +.B cerebrod will search for and select an appropriate network interface. If the -machine running -.B cerebrod +machine running +.B cerebrod contains multiple network interfaces, it would be recommended that the appropriate network interface be configured. The destination_port, -source_port, and network_interface may be optionally specified. +source_port, and network_interface may be optionally specified. To use defaults for the ip address or network interface, '0.0.0.0' may be specified. To use defaults for destination_port or source_port a '0' may be specified. @@ -156,10 +156,10 @@ message receiving ip. The network interface can be specified as a network interface (e.g. eth0), an ip address (e.g. 192.168.1.1) or a subnet using CIDR notation (e.g. 192.168.1.1/16). By default, when a network interface is not specified, -.B cerebrod +.B cerebrod will search for and -select an appropriate network interface. If the machine running -.B cerebrod +select an appropriate network interface. If the machine running +.B cerebrod contains multiple network interfaces, it would be recommended that the appropriate network interface be configured. The port and network_interface may be optionally specified. To use defaults for @@ -167,7 +167,7 @@ the ip address or network interface, '0.0.0.0' may be specified. To use defaults for the port, a '0' may be specified. .TP .I cerebrod_listen_threads num -Specify the number of listening threads the +Specify the number of listening threads the .B cerebrod listener server should execute. The default executes 2 threads. .TP @@ -177,10 +177,10 @@ Specify if the daemon should turn on the metric controller. Generally speaking, this option should be turned on if the .I cerebrod_speak -option is turned on. If the +option is turned on. If the .I cerebrod_speak option is turned off, the metric_controller will not be started. The default -turns this option on as long as the +turns this option on as long as the .I cerebrod_speak option is turned on. This must be turned on for metric administration tools such as @@ -195,14 +195,14 @@ Specify if the daemon should turn on the metric server. Generally speaking, this option should be turned on if the .I cerebrod_listen -option is turned on. If the +option is turned on. If the .I cerebrod_listen option is turned off, the metric_server will not be started. The default -turns this option on as long as the +turns this option on as long as the .I cerebrod_listen option is turned on. This must be turned on for metric reading tools such as -.B cerebro-stat +.B cerebro-stat to connect to the .B cerebrod daemon. @@ -216,10 +216,10 @@ Specify if the daemon should turn on the event server. Generally speaking, this option should be turned on if the .I cerebrod_listen -option is turned on. If the +option is turned on. If the .I cerebrod_listen option is turned off, the event_server will not be started. The default -turns this option on as long as the +turns this option on as long as the .I cerebrod_listen option is turned on. .TP @@ -250,10 +250,10 @@ specified as a network interface (e.g. eth0), an ip address (e.g. 192.168.1.1) or a subnet using CIDR notation (e.g. 192.168.1.1/16). By default, when a network interface is not specified, -.B cerebrod +.B cerebrod will search for and select an appropriate network interface. If the -machine running -.B cerebrod +machine running +.B cerebrod contains multiple network interfaces, it would be recommended that the appropriate network interface be configured. Multiple hosts can be specified to indicate metric data from specific hosts in your cluster @@ -272,7 +272,7 @@ parameter is only used if the message destination ip address is a multicast ip address. The default ttl is 1. .TP .I cerebrod_forward_host_accept host1 host2 host3 ... -Specify hosts that are not in the cluster that +Specify hosts that are not in the cluster that .B cerebrod should accept because packets are being forwarded to it. This option is particularly useful for a @@ -282,17 +282,17 @@ Hosts must be specified in their shortened hostname form. The hosts can be specified space separated, comma separated, or hostranged. .TP .I cerebrod_metric_module_exclude str1 str2 str3 ... -Specify metric module names that +Specify metric module names that .B cerebrod should not load. .TP .I cerebrod_monitor_module_exclude str1 str2 str3 ... -Specify monitor module names that +Specify monitor module names that .B cerebrod should not load. .TP .I cerebrod_event_module_exclude str1 str2 str3 ... -Specify event module names that +Specify event module names that .B cerebrod should not load. .TP @@ -332,8 +332,8 @@ gettimeofday(). This option is turned off by default. .if @MANPAGE_DEBUG@ \{ .TP .I cerebrod_alternate_hostname str -Specify an alternate hostname for the -.B cerebrod +Specify an alternate hostname for the +.B cerebrod daemon to use. Used for various testing and debugging purposes. \} .SH "FILES" diff --git a/man/cerebro_errnum.3 b/man/cerebro_errnum.3 index e03f33d6..17d75584 100644 --- a/man/cerebro_errnum.3 +++ b/man/cerebro_errnum.3 @@ -62,12 +62,12 @@ in the cerebro_nodelist_iterator_t passed in. error code \fIerrnum\fR. Generally, an error code is retrieved by calling -\fBcerebro_errnum()\fR, +\fBcerebro_errnum()\fR, \fBcerebro_namelist_errnum()\fR, \fBcerebro_namelist_iterator_errnum() \fBcerebro_nodelist_errnum()\fR, or \fBcerebro_nodelist_iterator_errnum() -and then passed to +and then passed to \fBcerebro_strerror()\fR to retrieve a string describing the error. .br diff --git a/man/cerebro_event.3 b/man/cerebro_event.3 index 7411983c..7ab5bd54 100644 --- a/man/cerebro_event.3 +++ b/man/cerebro_event.3 @@ -25,7 +25,7 @@ .\"############################################################################# .TH CEREBRO_EVENT_REGISTER 3 "May 2005" "LLNL" "LIBCEREBRO" .SH "NAME" -cerebro_event_register, cerebro_event_unregister, cerebro_event_parse \- +cerebro_event_register, cerebro_event_unregister, cerebro_event_parse \- event monitoring routines .SH "SYNOPSIS" .B #include @@ -135,7 +135,7 @@ A config file error occurred. .TP .B CEREBRO_ERR_CONFIG_MODULE A config module error occurred. -.TP +.TP .B CEREBRO_ERR_EVENT_NOT_RECEIVED An event has not yet been fully received. .TP diff --git a/man/cerebro_get_event_names.3 b/man/cerebro_get_event_names.3 index 221754df..b367c1f9 100644 --- a/man/cerebro_get_event_names.3 +++ b/man/cerebro_get_event_names.3 @@ -32,7 +32,7 @@ cerebro_get_event_names \- retrieve available cerebro event names .BI "cerebro_namelist_t cerebro_get_event_names(cerebro_t handle);" .br .SH "DESCRIPTION" -\fBcerebro_get_event_names()\fR retrieves a list of event names available for +\fBcerebro_get_event_names()\fR retrieves a list of event names available for registration with .B cerebro_event_register(3). The event names are returned in a cerebro namelist. The cerebro @@ -42,7 +42,7 @@ The default behavior of \fBcerebro_get_event_names()\fR can be altered by setting alternate defaults using .B cerebro_set_hostname(3), or -.B cerebro_set_port(3). +.B cerebro_set_port(3). It can also be altered using the the cerebro configuration file. .br @@ -52,7 +52,7 @@ returned, and an error code is returned in \fIhandle\fR. The error code can be retrieved via .BR cerebro_errnum(3) , and a description of the error code can be retrieved via -.BR cerebro_strerror(3). +.BR cerebro_strerror(3). .br .SH "ERRORS" .TP @@ -70,7 +70,7 @@ Invalid parameter passed in. Invalid hostname specified. .TP .B CEREBRO_ERR_CONNECT -Error connecting to +Error connecting to .B cerebrod event server. .TP diff --git a/man/cerebro_get_hostname.3 b/man/cerebro_get_hostname.3 index 054e8c2b..2cec446f 100644 --- a/man/cerebro_get_hostname.3 +++ b/man/cerebro_get_hostname.3 @@ -57,14 +57,14 @@ CEREBRO_METRIC_FLAGS_UP_ONLY CEREBRO_METRIC_FLAGS_NONE_IF_NOEXIST -See +See .BR cerebro_set_flags(3) for details on these flags. .br .SH "RETURN VALUES" On success, the respective hostname, port, timeout_len, or flags are -returned returned. +returned returned. For \fBcerebro_get_hostname\fR, NULL is returned on error. For \fBcerebro_get_port()\fR, \fBcerebro_get_timeout_len()\fR, and diff --git a/man/cerebro_get_metric_data.3 b/man/cerebro_get_metric_data.3 index 79e15c62..adc5388d 100644 --- a/man/cerebro_get_metric_data.3 +++ b/man/cerebro_get_metric_data.3 @@ -32,9 +32,9 @@ cerebro_get_metric_data \- retrieve cerebro metric data .BI "cerebro_nodelist_t cerebro_get_metric_data(cerebro_t handle, const char *metric_name);" .br .SH "DESCRIPTION" -\fBcerebro_get_metric_data()\fR retrieves metric data for the metric +\fBcerebro_get_metric_data()\fR retrieves metric data for the metric \fImetric_name\fR from -the +the .B cerebrod metric server and returns it in a cerebro nodelist. The cerebro nodelist can then be operated on by the cerebro nodelist routines. @@ -52,8 +52,8 @@ The default metrics available through the .B cerebrod metric server are: -CEREBRO_METRIC_CLUSTER_NODES - Retrieve all nodes known to -.B cerebrod. +CEREBRO_METRIC_CLUSTER_NODES - Retrieve all nodes known to +.B cerebrod. No metric value is returned for this metric. CEREBRO_METRIC_UPDOWN_STATE - Retrieve the up vs. down state of all @@ -69,7 +69,7 @@ returned, and an error code is returned in \fIhandle\fR. The error code can be retrieved via .BR cerebro_errnum(3) , and a description of the error code can be retrieved via -.BR cerebro_strerror(3). +.BR cerebro_strerror(3). .br .SH "ERRORS" .TP @@ -87,7 +87,7 @@ Invalid parameter passed in. Invalid hostname specified. .TP .B CEREBRO_ERR_CONNECT -Error connecting to +Error connecting to .B cerebrod metric server. .TP diff --git a/man/cerebro_get_metric_names.3 b/man/cerebro_get_metric_names.3 index 7820fdf5..f835fbe6 100644 --- a/man/cerebro_get_metric_names.3 +++ b/man/cerebro_get_metric_names.3 @@ -32,7 +32,7 @@ cerebro_get_metric_names \- retrieve available cerebro metric names .BI "cerebro_namelist_t cerebro_get_metric_names(cerebro_t handle);" .br .SH "DESCRIPTION" -\fBcerebro_get_metric_names()\fR retrieves a list of metric names available for +\fBcerebro_get_metric_names()\fR retrieves a list of metric names available for retrieval with .B cerebro_get_metric_data(3). The metric names are returned in a cerebro namelist. The cerebro @@ -42,7 +42,7 @@ The default behavior of \fBcerebro_get_metric_names()\fR can be altered by setting alternate defaults using .B cerebro_set_hostname(3), or -.B cerebro_set_port(3). +.B cerebro_set_port(3). It can also be altered using the the cerebro configuration file. .br @@ -52,7 +52,7 @@ returned, and an error code is returned in \fIhandle\fR. The error code can be retrieved via .BR cerebro_errnum(3) , and a description of the error code can be retrieved via -.BR cerebro_strerror(3). +.BR cerebro_strerror(3). .br .SH "ERRORS" .TP @@ -70,7 +70,7 @@ Invalid parameter passed in. Invalid hostname specified. .TP .B CEREBRO_ERR_CONNECT -Error connecting to +Error connecting to .B cerebrod metric server. .TP diff --git a/man/cerebro_handle_create.3 b/man/cerebro_handle_create.3 index 2b371dd8..43b1b757 100644 --- a/man/cerebro_handle_create.3 +++ b/man/cerebro_handle_create.3 @@ -25,7 +25,7 @@ .\"############################################################################# .TH CEREBRO_HANDLE_CREATE 3 "May 2005" "LLNL" "LIBCEREBRO" .SH "NAME" -cerebro_handle_create \- create a cerebro handle +cerebro_handle_create \- create a cerebro handle .SH "SYNOPSIS" .B #include .sp diff --git a/man/cerebro_handle_destroy.3 b/man/cerebro_handle_destroy.3 index 003e9ba0..08cc6cc1 100644 --- a/man/cerebro_handle_destroy.3 +++ b/man/cerebro_handle_destroy.3 @@ -39,16 +39,16 @@ Any cerebro nodelists created using the handle will also be destroyed. .SH "RETURN VALUES" On success, 0 is returned. On error, -1 is returned, and an error code is returned in \fIhandle\fR. The error code can be retrieved via -.BR cerebro_errnum(3), -and a description of the error code can be retrieved via -.BR cerebro_strerror(3). +.BR cerebro_errnum(3), +and a description of the error code can be retrieved via +.BR cerebro_strerror(3). .br .SH "ERRORS" .TP .B CEREBRO_ERR_NULLHANDLE The \fIhandle\fR parameter is NULL. .TP -.B CEREBRO_ERR_MAGIC_NUMBER +.B CEREBRO_ERR_MAGIC_NUMBER \fIhandle\fR has an incorrect magic number. \fIhandle\fR does not point to a cerebro_t handle or \fIhandle\fR has already been destroyed. diff --git a/man/cerebro_module.3.in b/man/cerebro_module.3.in index e27dcacb..cb9779ef 100644 --- a/man/cerebro_module.3.in +++ b/man/cerebro_module.3.in @@ -24,7 +24,7 @@ .\" with Cerebro. If not, see . .\"############################################################################# .TH CEREBRO_MODULE 3 "May 2005" "LLNL" "CEREBRO_MODULE" -.SH "NAME" +.SH "NAME" cerebro_module \- Introduction to cerebro modules .SH CLUSTERLIST MODULES @@ -190,6 +190,6 @@ Event modules are searched for in the package library directory, @CEREBRO_MODULE_DIR@. .SH "SEE ALSO" -libcerebro(3), +libcerebro(3), cerebro_module_devel(3), cerebro.conf(5) diff --git a/man/cerebro_module_devel.3.in b/man/cerebro_module_devel.3.in index 7e14a737..c2a61eeb 100644 --- a/man/cerebro_module_devel.3.in +++ b/man/cerebro_module_devel.3.in @@ -296,12 +296,12 @@ The 'cerebrod_heartbeat_frequency_min' and maximum heartbeat frequency for .BR cerebrod(8). -The 'cerebrod_speak' field is a boolean that turns on the +The 'cerebrod_speak' field is a boolean that turns on the .BR cerebrod(8) speaker to send out message packets. The 'cerebrod_speak_message_config' field should store an array of -destinations +destinations .BR cerebrod(8) messages should be to. @@ -318,7 +318,7 @@ threads that should be created in .BR cerebrod(8). The 'cerebrod_listen_message_config' field should store an array of -message destinations +message destinations .BR cerebrod(8) should be listening on. @@ -331,7 +331,7 @@ The 'cerebrod_metric_server' field is a boolean that turns on the metric server to receive metric data requests. The 'cerebrod_metric_server_port' field stores the metric server -port for +port for .BR cerebrod(8). The 'cerebrod_event_server' field is a boolean that turns on the @@ -339,7 +339,7 @@ The 'cerebrod_event_server' field is a boolean that turns on the event server to receive event data requests. The 'cerebrod_event_server_port' field stores the event server -port for +port for .BR cerebrod(8). The 'cerebrod_forward_message_config' field should store an array of @@ -358,7 +358,7 @@ should accept. .if @MANPAGE_DEBUG@ \{ The 'cerebrod_speak_debug' field is a boolean that turns on speaker -debugging for +debugging for .BR cerebrod. The 'cerebrod_listen_debug' field is a boolean that turns on listener @@ -378,7 +378,7 @@ event server debugging for .BR cerebrod. The 'cerebrod_alternate_hostname' field is a string that specifies -an alternate hostname +an alternate hostname .BR cerebrod should assume for testing purposes. \} @@ -506,7 +506,7 @@ The 'get_metric_thread' function returns a pointer of type: typedef void *(*Cerebro_metric_thread_pointer)(void *arg); -which will be executed as a detached thread. +which will be executed as a detached thread. This thread can perform any metric monitoring duties it pleases. Typically the thread is used to watch or monitor for some event and @@ -516,7 +516,7 @@ function below. If no detached thread is required to be executed by this module, NULL should be returned. -If the +If the .B cerebrod daemon was built without threads, the 'get_metric_thread' function will never be called. @@ -596,7 +596,7 @@ The field 'metric_update' should point to a function of the following type: typedef int (*Cerebro_monitor_metric_update)(const char *nodename, unsigned int metric_value_type, unsigned int metric_value_len, void *metric_value); The 'metric_update' function is called whenever the metric is received from a node. -The nodename the metric was received from, metric value type, metric value length, and metric value are passed in as arguments. +The nodename the metric was received from, metric value type, metric value length, and metric value are passed in as arguments. Returns the 0 on success, -1 on error. All of the above functions must be defined in the module and listed in diff --git a/man/cerebro_namelist_length.3 b/man/cerebro_namelist_length.3 index 0484a36b..0fca087c 100644 --- a/man/cerebro_namelist_length.3 +++ b/man/cerebro_namelist_length.3 @@ -99,7 +99,7 @@ On errors, an error code is returned in \fInamelist\fR or .BR cerebro_namelist_errnum(3) or .BR cerebro_namelist_iterator_errnum(3) respectively , and a description of the error code can be retrieved via -.BR cerebro_strerror(3). +.BR cerebro_strerror(3). .br .SH "ERRORS" .TP diff --git a/man/cerebro_nodelist_metric_name.3 b/man/cerebro_nodelist_metric_name.3 index de3cb4c4..5e98793c 100644 --- a/man/cerebro_nodelist_metric_name.3 +++ b/man/cerebro_nodelist_metric_name.3 @@ -142,7 +142,7 @@ On errors, an error code is returned in \fInodelist\fR or .BR cerebro_nodelist_errnum(3) or .BR cerebro_nodelist_iterator_errnum(3) respectively , and a description of the error code can be retrieved via -.BR cerebro_strerror(3). +.BR cerebro_strerror(3). .br .SH "ERRORS" .TP diff --git a/man/cerebro_register_metric.3 b/man/cerebro_register_metric.3 index d144e6a7..85e4e8a5 100644 --- a/man/cerebro_register_metric.3 +++ b/man/cerebro_register_metric.3 @@ -47,16 +47,16 @@ by the local daemon. A metric value will not be propagated until one is set by the \fBcerebro_update_metric_value()\fR function. -\fBcerebro_unregister_metric()\fR unregisters a metric in the local +\fBcerebro_unregister_metric()\fR unregisters a metric in the local .BR cerebrod(8) daemon. \fBcerebro_update_metric_value()\fR updates the current metric value to be -propagated by the +propagated by the .BR cerebrod(8) daemon. -\fBcerebro_resend_metric()\fR resends the specified metric in the next +\fBcerebro_resend_metric()\fR resends the specified metric in the next .BR cerebrod(8) heartbeat. Usually, this function is called to force a metric to be re-propagated. @@ -68,7 +68,7 @@ can speak. \fBcerebro_flush_metric()\fR flushes the currently known metric contents from the .BR cerebrod(8) -daemon. Metrics can only be flushed if the +daemon. Metrics can only be flushed if the .BR cerebrod(8) daemon can listen. diff --git a/man/cerebro_set_hostname.3 b/man/cerebro_set_hostname.3 index 4eee4621..249e85c9 100644 --- a/man/cerebro_set_hostname.3 +++ b/man/cerebro_set_hostname.3 @@ -53,7 +53,7 @@ timeout length will be used. should use. By default, no flags are set. The following flags are available to be set: -CEREBRO_METRIC_FLAGS_UP_ONLY - By default +CEREBRO_METRIC_FLAGS_UP_ONLY - By default .BR cerebro_get_metric_data(3) will return data for every node in the cluster currently monitoring the specified metric. This flag alters this behavior @@ -63,7 +63,7 @@ metric server return only nodes that are currently up. This flag does not apply to any of the default metrics supplied by .BR cerebrod(8). -CEREBRO_METRIC_FLAGS_NONE_IF_DOWN - By default, +CEREBRO_METRIC_FLAGS_NONE_IF_DOWN - By default, .BR cerebro_get_metric_data(3) will return a cluster node even if the data has not been recently updated. This flag alters this behavior to have the @@ -72,7 +72,7 @@ metric server return the node to the user without a metric_value. This flag does not apply to any of the default metrics supplied by .BR cerebrod(8). -CEREBRO_METRIC_FLAGS_NONE_IF_NOT_MONITORED - By default, +CEREBRO_METRIC_FLAGS_NONE_IF_NOT_MONITORED - By default, .BR cerebro_get_metric_data(3) will not return a cluster node if the cluster node is not currently monitoring the specified metric. This flag alters this behavior to diff --git a/man/cerebrod.8.in b/man/cerebrod.8.in index c7dc34b4..dd5fcc69 100644 --- a/man/cerebrod.8.in +++ b/man/cerebrod.8.in @@ -41,18 +41,18 @@ for an overview of the .B Cerebro system. -The +The .B cerebrod daemon can be configured using the cerebro configuration file or having a cerebro configuration loaded. The configuration changes can alter -the features and behavior of the daemon as well as the +the features and behavior of the daemon as well as the .B Cerebro suite of tools and libraries. See the .BR cerebro.conf(5) and -.BR cerebro_module(3) +.BR cerebro_module(3) manpages for additional information on configuration. Depending on the configuration of your cluster, the @@ -62,7 +62,7 @@ daemon may need to be restarted to recognize a new configuration. For example, if additional nodes have been added into your cluster, .B cerebrod may need to be restarted to reload any cluster data files so these -new nodes will be recognized. +new nodes will be recognized. .SH "OPTIONS" .TP diff --git a/man/libcerebro.3 b/man/libcerebro.3 index 3ead0599..11fcdfae 100644 --- a/man/libcerebro.3 +++ b/man/libcerebro.3 @@ -132,9 +132,9 @@ configuration file, clusterlist module, or configuration module may be loaded or called during API calls. Please see the .BR cerebro.conf(5) manpage for information about the cerebro configuration file. Please see -the +the .BR cerebro_module(3) -manpage for information on cerebro modules. +manpage for information on cerebro modules. .SH "FILES" /usr/include/cerebro.h diff --git a/src/cerebro-admin/cerebro-admin.c b/src/cerebro-admin/cerebro-admin.c index 1e2ea72e..07274cad 100644 --- a/src/cerebro-admin/cerebro-admin.c +++ b/src/cerebro-admin/cerebro-admin.c @@ -57,13 +57,13 @@ #define CEREBRO_ADMIN_RESEND 3 #define CEREBRO_ADMIN_FLUSH 4 -/* - * External variables for getopt +/* + * External variables for getopt */ extern char *optarg; extern int optind, opterr, optopt; -/* +/* * Cerebro-Admin Data * * handle - cerebro handle @@ -83,7 +83,7 @@ int64_t metric_value_int64; u_int64_t metric_value_u_int64; void *metric_value_ptr; -/* +/* * _init_cerebro_admin * * initialize globals @@ -97,7 +97,7 @@ _init_cerebro_admin(void) err_exit("%s: cerebro_handle_create()", func); } -/* +/* * _cleanup_cerebro_stat * * cleanup globals @@ -108,13 +108,13 @@ _cleanup_cerebro_stat(void) (void)cerebro_handle_destroy(handle); } -/* +/* * _usage * * output usage and exit */ -static void -_usage(void) +static void +_usage(void) { fprintf(stderr, "Usage: cerebro_admin [OPTIONS] -m [-r | -u | -p | -s]\n" @@ -156,13 +156,13 @@ _usage(void) exit(1); } -/* +/* * _version * * output version and exit */ -static void -_version(void) +static void +_version(void) { fprintf(stderr, "%s %ss\n", PACKAGE, VERSION); exit(1); @@ -194,20 +194,20 @@ _cerebro_set_flags(unsigned int new_flag) } } -/* +/* * _cmdline_parse * * parse all cmdline input */ static void -_cmdline_parse(int argc, char **argv) +_cmdline_parse(int argc, char **argv) { char options[1024]; char *ptr; int c; #if HAVE_GETOPT_LONG - struct option loptions[] = + struct option loptions[] = { {"help", 0, NULL, 'h'}, {"version", 0, NULL, 'v'}, @@ -243,7 +243,7 @@ _cmdline_parse(int argc, char **argv) while ((c = getopt(argc, argv, options)) != -1) #endif { - switch(c) + switch(c) { case 'h': _usage(); @@ -361,7 +361,7 @@ _cmdline_parse(int argc, char **argv) } } -/* +/* * _clean_err_exit * * Check for and output "nice" error messages for certain errnums. If @@ -386,8 +386,8 @@ _clean_err_exit(int errnum) err_exit("Invalid configuration input found"); } -int -main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { const char *func = __FUNCTION__; int rv = 0; @@ -401,13 +401,13 @@ main(int argc, char *argv[]) _init_cerebro_admin(); _cmdline_parse(argc, argv); - + if (operation == CEREBRO_ADMIN_REGISTER) rv = cerebro_register_metric(handle, metric_name); else if (operation == CEREBRO_ADMIN_UNREGISTER) rv = cerebro_unregister_metric(handle, metric_name); else if (operation == CEREBRO_ADMIN_UPDATE) - rv = cerebro_update_metric_value(handle, + rv = cerebro_update_metric_value(handle, metric_name, metric_value_type, metric_value_len, @@ -416,15 +416,15 @@ main(int argc, char *argv[]) rv = cerebro_resend_metric(handle, metric_name); else if (operation == CEREBRO_ADMIN_FLUSH) rv = cerebro_flush_metric(handle, metric_name); - + if (rv < 0) { char *msg = cerebro_strerror(cerebro_errnum(handle)); - + _clean_err_exit(cerebro_errnum(handle)); err_exit("%s: %s", func, msg); } - + _cleanup_cerebro_stat(); exit(0); } diff --git a/src/cerebro-stat/cerebro-stat.c b/src/cerebro-stat/cerebro-stat.c index faf212ae..d544acd2 100644 --- a/src/cerebro-stat/cerebro-stat.c +++ b/src/cerebro-stat/cerebro-stat.c @@ -58,13 +58,13 @@ #define CEREBRO_STAT_NEWLINE 0 #define CEREBRO_STAT_HOSTRANGE 1 -/* - * External variables for getopt +/* + * External variables for getopt */ extern char *optarg; extern int optind, opterr, optopt; -/* +/* * Cerebro-Stat Data * * hostname - hostname to connect to @@ -81,7 +81,7 @@ static int metric_list_flag = 0; static char *metric_name = NULL; static int metric_received_time_flag = 0; -/* +/* * node_metric_data * * Contains node and metric data @@ -94,7 +94,7 @@ struct node_metric_data { void *metric_value; }; -/* +/* * hostrange_data * * Contains hostlist and key data @@ -104,7 +104,7 @@ struct hostrange_data { char *key; }; -/* +/* * _init_cerebro_stat * * initialize globals @@ -118,7 +118,7 @@ _init_cerebro_stat(void) err_exit("%s: cerebro_handle_create()", func); } -/* +/* * _cleanup_cerebro_stat * * cleanup globals @@ -129,13 +129,13 @@ _cleanup_cerebro_stat(void) (void)cerebro_handle_destroy(handle); } -/* +/* * _usage * * output usage and exit */ -static void -_usage(void) +static void +_usage(void) { fprintf(stderr, "Usage: cerebro-stat [OPTIONS] -m \n" @@ -158,7 +158,7 @@ _usage(void) " -t Output metric receive times\n" " -e STRING Monitor the specified event\n" " -z List all available events that can be monitored\n", - CEREBRO_STAT_NONE_STRING, + CEREBRO_STAT_NONE_STRING, CEREBRO_STAT_NONE_STRING); #if CEREBRO_DEBUG fprintf(stderr, @@ -169,19 +169,19 @@ _usage(void) exit(1); } -/* +/* * _version * * output version and exit */ -static void -_version(void) +static void +_version(void) { fprintf(stderr, "%s %s\n", PACKAGE, VERSION); exit(1); } -/* +/* * _cerebro_set_flags * * Set a cerebro flag @@ -207,13 +207,13 @@ _cerebro_set_flags(unsigned int new_flag) } } -/* +/* * _cmdline_parse * * parse all cmdline input */ static void -_cmdline_parse(int argc, char **argv) +_cmdline_parse(int argc, char **argv) { const char *func = __FUNCTION__; char options[1024]; @@ -221,7 +221,7 @@ _cmdline_parse(int argc, char **argv) int c; #if HAVE_GETOPT_LONG - struct option loptions[] = + struct option loptions[] = { {"help", 0, NULL, 'h'}, {"version", 0, NULL, 'v'}, @@ -250,17 +250,17 @@ _cmdline_parse(int argc, char **argv) #if CEREBRO_DEBUG strcat(options, "d"); #endif /* CEREBRO_DEBUG */ - + /* turn off output messages printed by getopt_long */ opterr = 0; - + #if HAVE_GETOPT_LONG while ((c = getopt_long(argc, argv, options, loptions, NULL)) != -1) #else while ((c = getopt(argc, argv, options)) != -1) #endif { - switch(c) + switch(c) { case 'h': _usage(); @@ -331,12 +331,12 @@ _cmdline_parse(int argc, char **argv) + (event_name ? 1 : 0) + (event_list_flag ? 1 : 0)) > 1) err_exit("Specify one of --event-list, --event, --metric-list, and --metric options"); - + if (!event_name && !event_list_flag && !metric_list_flag && !metric_name) _usage(); } -/* +/* * _clean_err_exit * * Check for and output "nice" error messages for certain errnums. If @@ -385,7 +385,7 @@ _event_list(void) _clean_err_exit(cerebro_errnum(handle)); err_exit("%s: cerebro_get_event_names: %s", func, msg); } - + if (!(mitr = cerebro_namelist_iterator_create(m))) { char *msg = cerebro_strerror(cerebro_namelist_errnum(m)); @@ -410,7 +410,7 @@ _event_list(void) err_exit("%s: cerebro_namelist_iterator_next: %s", func, msg); } } - + litr = List_iterator_create(l); while ((str = list_next(litr))) @@ -443,7 +443,7 @@ _metric_list(void) _clean_err_exit(cerebro_errnum(handle)); err_exit("%s: cerebro_get_metric_names: %s", func, msg); } - + if (!(mitr = cerebro_namelist_iterator_create(m))) { char *msg = cerebro_strerror(cerebro_namelist_errnum(m)); @@ -468,7 +468,7 @@ _metric_list(void) err_exit("%s: cerebro_namelist_iterator_next: %s", func, msg); } } - + litr = List_iterator_create(l); while ((str = list_next(litr))) @@ -479,7 +479,7 @@ _metric_list(void) (void)cerebro_namelist_destroy(m); } -/* +/* * _metric_value_str * * Get the metric value string @@ -488,7 +488,7 @@ static void _metric_value_str(unsigned int mtype, unsigned int mlen, void *mvalue, - char *buf, + char *buf, unsigned int buflen) { const char *func = __FUNCTION__; @@ -549,12 +549,12 @@ _metric_value_str(unsigned int mtype, else if (mtype == CEREBRO_DATA_VALUE_TYPE_U_INT64) rv = snprintf(buf, buflen, "%lu", *((u_int64_t *)mvalue)); #endif /* SIZEOF_LONG == 8 */ - + if (rv >= buflen) err_exit("%s: truncated output: %d", func, mlen); } -/* +/* * _cluster_nodes_output * * Output cluster nodes @@ -587,10 +587,10 @@ _cluster_nodes_output(List l) Hostlist_sort(hl); Hostlist_uniq(hl); - + memset(hstr, '\0', CEREBRO_STAT_BUFLEN); Hostlist_ranged_string(hl, CEREBRO_STAT_BUFLEN, hstr); - + fprintf(stdout, "%s\n", hstr); } @@ -599,7 +599,7 @@ _cluster_nodes_output(List l) Hostlist_destroy(hl); } -/* +/* * _newline_output * * Output metric data, one node per line @@ -627,7 +627,7 @@ _newline_output(List l) if (metric_received_time_flag) { char tbuf[CEREBRO_STAT_BUFLEN]; - + memset(tbuf, '\0', CEREBRO_STAT_BUFLEN); if (data->metric_value_received_time) { @@ -648,7 +648,7 @@ _newline_output(List l) /* No need to destroy list iterator, caller will destroy List */ } -/* +/* * _hostrange_data_destroy * * Free hostrange_data structures @@ -666,9 +666,9 @@ _hostrange_data_destroy(void *data) Free(hd); } -/* +/* * _hostrange_output_data - * + * * Callback for hash_for_each to output a hostrange for a metric data */ static int @@ -680,7 +680,7 @@ _hostrange_output_data(void *data, const void *key, void *arg) assert(data && key); hd = (struct hostrange_data *)data; - + memset(hstr, '\0', CEREBRO_STAT_BUFLEN); Hostlist_sort(hd->hl); Hostlist_ranged_string(hd->hl, CEREBRO_STAT_BUFLEN, hstr); @@ -689,7 +689,7 @@ _hostrange_output_data(void *data, const void *key, void *arg) return 1; } -/* +/* * _hostrange_output * * Output metric data in hostrange format. The algorithm involves @@ -716,7 +716,7 @@ _hostrange_output(List l) err_exit("%s: invalid count", func); #endif /* CEREBRO_DEBUG */ - h = Hash_create(count, + h = Hash_create(count, (hash_key_f)hash_key_string, (hash_cmp_f)strcmp, (hash_del_f)_hostrange_data_destroy); @@ -730,8 +730,8 @@ _hostrange_output(List l) _metric_value_str(data->metric_value_type, data->metric_value_len, - data->metric_value, - buf, + data->metric_value, + buf, CEREBRO_STAT_BUFLEN); if (!(hd = Hash_find(h, buf))) @@ -770,7 +770,7 @@ _event_data(void) _clean_err_exit(cerebro_errnum(handle)); err_exit("%s: cerebro_event_register: %s", func, msg); } - + while (1) { struct pollfd pfd; @@ -779,7 +779,7 @@ _event_data(void) pfd.fd = fd; pfd.events = POLLIN; pfd.revents = 0; - + n = Poll(&pfd, 1, -1); if (n && pfd.revents & POLLIN) @@ -801,29 +801,29 @@ _event_data(void) &event_value) < 0) { char *msg = cerebro_strerror(cerebro_errnum(handle)); - + _clean_err_exit(cerebro_errnum(handle)); err_exit("%s: cerebro_event_parse: %s", func, msg); } - + memset(vbuf, '\0', CEREBRO_STAT_BUFLEN); _metric_value_str(event_value_type, event_value_len, event_value, vbuf, CEREBRO_STAT_BUFLEN); - + memset(tbuf, '\0', CEREBRO_STAT_BUFLEN); t = time(NULL); tm = Localtime(&t); strftime(tbuf, CEREBRO_STAT_BUFLEN, "%F %I:%M:%S%P", tm); - + fprintf(stdout, "%s(%s): %s\n", nodename, tbuf, vbuf); - + free(nodename); free(event_value); - } + } } (void)cerebro_event_unregister(handle, fd); @@ -849,7 +849,7 @@ _metric_data(void) _clean_err_exit(cerebro_errnum(handle)); err_exit("%s: cerebro_get_metric_data: %s", func, msg); } - + if (!(nitr = cerebro_nodelist_iterator_create(n))) { char *msg = cerebro_strerror(cerebro_nodelist_errnum(n)); @@ -871,7 +871,7 @@ _metric_data(void) err_exit("%s: cerebro_nodelist_iterator_nodename: %s", func, msg); } - if (cerebro_nodelist_iterator_metric_value(nitr, + if (cerebro_nodelist_iterator_metric_value(nitr, &(data->metric_value_received_time), &(data->metric_value_type), &(data->metric_value_len), @@ -882,7 +882,7 @@ _metric_data(void) } List_append(l, data); - + if (cerebro_nodelist_iterator_next(nitr) < 0) { char *msg = cerebro_strerror(cerebro_nodelist_iterator_errnum(nitr)); @@ -902,8 +902,8 @@ _metric_data(void) (void)cerebro_nodelist_destroy(n); } -int -main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { err_init(argv[0]); err_set_flags(ERROR_STDERR); @@ -914,14 +914,14 @@ main(int argc, char *argv[]) _init_cerebro_stat(); _cmdline_parse(argc, argv); - + /* Checks in _cmdline_parse ensure only one of four below will be called */ - if (event_list_flag + if (event_list_flag || (event_name && !strcmp(event_name, CEREBRO_EVENT_NAMES))) _event_list(); - if (metric_list_flag + if (metric_list_flag || (metric_name && !strcmp(metric_name, CEREBRO_METRIC_METRIC_NAMES))) _metric_list(); diff --git a/src/cerebrod/cerebrod.c b/src/cerebrod/cerebrod.c index 792c3022..2a2c5225 100644 --- a/src/cerebrod/cerebrod.c +++ b/src/cerebrod/cerebrod.c @@ -53,7 +53,7 @@ #include "wrappers.h" #if !WITH_CEREBROD_NO_THREADS -/* +/* * debug_output_mutex * * To coordinate output of debugging info to stderr. @@ -98,13 +98,13 @@ extern pthread_mutex_t event_server_init_lock; extern struct cerebrod_config conf; /* for hostlist library */ -void +void lsd_fatal_error(char *file, int line, char *mesg) { cerebro_err_exit("LSD FATAL ERROR(%s:%d) %s: %s", file, line, mesg, strerror(errno)); } -int +int main(int argc, char **argv) { cerebro_err_init(argv[0]); @@ -121,7 +121,7 @@ main(int argc, char **argv) cerebro_err_set_flags(CEREBRO_ERROR_STDERR); /* Call after daemonization, since daemonization closes currently - * open fds + * open fds */ openlog(argv[0], LOG_ODELAY | LOG_PID, LOG_DAEMON); @@ -214,12 +214,12 @@ main(int argc, char **argv) /* Wait for initialization to complete */ Pthread_mutex_lock(&event_node_timeout_monitor_init_lock); while (!event_node_timeout_monitor_init) - Pthread_cond_wait(&event_node_timeout_monitor_init_cond, + Pthread_cond_wait(&event_node_timeout_monitor_init_cond, &event_node_timeout_monitor_init_lock); Pthread_mutex_unlock(&event_node_timeout_monitor_init_lock); } - /* Start metric controller - see comments at speaker below */ + /* Start metric controller - see comments at speaker below */ if (conf.metric_controller) { pthread_t thread; @@ -234,14 +234,14 @@ main(int argc, char **argv) /* Wait for initialization to complete */ Pthread_mutex_lock(&metric_controller_init_lock); while (!metric_controller_init) - Pthread_cond_wait(&metric_controller_init_cond, + Pthread_cond_wait(&metric_controller_init_cond, &metric_controller_init_lock); Pthread_mutex_unlock(&metric_controller_init_lock); } #endif /* !WITH_CEREBROD_SPEAKER_ONLY */ - /* Start speaker + /* Start speaker * * It may make more logical sense to start the metric controller * after the speaker since metric data cannot be propagated until @@ -257,7 +257,7 @@ main(int argc, char **argv) /* If speak is set, we do not reach this point */ - for (;;) + for (;;) sleep(INT_MAX); return 0; /* NOT REACHED */ diff --git a/src/cerebrod/cerebrod_config.c b/src/cerebrod/cerebrod_config.c index 861a754f..abe5f949 100644 --- a/src/cerebrod/cerebrod_config.c +++ b/src/cerebrod/cerebrod_config.c @@ -61,11 +61,11 @@ #define MULTICAST_CLASS_MIN 224 #define MULTICAST_CLASS_MAX 239 -#define IPADDR_BITS 32 +#define IPADDR_BITS 32 #define IPADDR6_BITS 128 #define INTF_NONE 0 -#define INTF_IP 1 +#define INTF_IP 1 #define INTF_NAME 2 extern char *config_debug_config_file; @@ -73,7 +73,7 @@ extern int config_debug_output; #define CEREBROD_CONFIG_HOSTLIST_BUFLEN 65536 -/* +/* * conf * * cerebrod configuration used by all of cerebrod @@ -109,7 +109,7 @@ _cerebrod_set_config_default(void) conf.listen_message_config[0].port = CEREBROD_LISTEN_MESSAGE_CONFIG_PORT_DEFAULT; conf.listen_message_config[0].network_interface = CEREBROD_LISTEN_MESSAGE_CONFIG_NETWORK_INTERFACE_DEFAULT; conf.listen_message_config_len = 1; - conf.listen_threads = CEREBROD_LISTEN_THREADS_DEFAULT; + conf.listen_threads = CEREBROD_LISTEN_THREADS_DEFAULT; conf.metric_controller = CEREBROD_METRIC_CONTROLLER_DEFAULT; @@ -177,7 +177,7 @@ _version(void) */ static void _cerebrod_cmdline_arguments_parse(int argc, char **argv) -{ +{ char options[100]; int c; @@ -222,7 +222,7 @@ _cerebrod_cmdline_arguments_parse(int argc, char **argv) case '?': default: cerebro_err_exit("unknown command line option '%c'", optopt); - } + } } } @@ -243,7 +243,7 @@ _cerebrod_cmdline_arguments_error_check(void) if (strcmp(conf.config_file, CEREBRO_CONFIG_FILE_DEFAULT) != 0) { struct stat buf; - + if (stat(conf.config_file, &buf) < 0) cerebro_err_exit("config file '%s' not found", conf.config_file); } @@ -274,7 +274,7 @@ _cerebrod_load_config(void) else CEREBROD_EXIT(("load_config: error loading cerebro configuration: errnum=%d", errnum)); } - + if (tconf.cerebrod_heartbeat_frequency_flag) { conf.heartbeat_frequency_min = tconf.cerebrod_heartbeat_frequency_min; @@ -299,7 +299,7 @@ _cerebrod_load_config(void) conf.speak_message_config[i].source_port = CEREBROD_SPEAK_MESSAGE_CONFIG_SOURCE_PORT_DEFAULT; else conf.speak_message_config[i].source_port = tconf.cerebrod_speak_message_config[i].source_port; - + if (!strcmp(tconf.cerebrod_speak_message_config[i].network_interface, CEREBRO_CONFIG_IP_DEFAULT)) conf.speak_message_config[i].network_interface = NULL; else @@ -329,7 +329,7 @@ _cerebrod_load_config(void) conf.listen_message_config[i].port = CEREBROD_LISTEN_MESSAGE_CONFIG_PORT_DEFAULT; else conf.listen_message_config[i].port = tconf.cerebrod_listen_message_config[i].port; - + if (!strcmp(tconf.cerebrod_listen_message_config[i].network_interface, CEREBRO_CONFIG_IP_DEFAULT)) conf.listen_message_config[i].network_interface = NULL; else @@ -367,7 +367,7 @@ _cerebrod_load_config(void) conf.forward_message_config[i].source_port = CEREBROD_FORWARD_MESSAGE_CONFIG_SOURCE_PORT_DEFAULT; else conf.forward_message_config[i].source_port = tconf.cerebrod_forward_message_config[i].source_port; - + if (!strcmp(tconf.cerebrod_forward_message_config[i].network_interface, CEREBRO_CONFIG_IP_DEFAULT)) conf.forward_message_config[i].network_interface = NULL; else @@ -382,7 +382,7 @@ _cerebrod_load_config(void) char *ptr; hostptr = Strdup(tconf.cerebrod_forward_message_config[i].host[j]); - + /* Shorten hostname if necessary */ if ((ptr = strchr(hostptr, '.'))) *ptr = '\0'; @@ -416,7 +416,7 @@ _cerebrod_load_config(void) /* Shorten hostname if necessary */ if ((ptr = strchr(hostptr, '.'))) *ptr = '\0'; - + if (!hostlist_push(conf.forward_host_accept, hostptr)) cerebro_err_exit("host '%s' improperly formatted"); Free(hostptr); @@ -466,7 +466,7 @@ _cerebrod_load_config(void) #endif /* CEREBRO_DEBUG */ } -/* +/* * _cerebrod_config_error_check_ip * * Check for valid ip address or hostname passed in by user @@ -487,7 +487,7 @@ _cerebrod_config_error_check_ip(char *ip) } } -/* +/* * _cerebrod_config_error_check_network_interface * * Check for valid network interface IP address @@ -503,12 +503,12 @@ _cerebrod_config_error_check_network_interface(char *network_interface) { char *ipaddr_cpy = Strdup(network_interface); char *tok; - + tok = strtok(ipaddr_cpy, "/"); if (!Inet_pton(AF_INET, tok, &addr_temp)) - cerebro_err_exit("network interface IP address '%s' invalid", + cerebro_err_exit("network interface IP address '%s' invalid", network_interface); - + Free(ipaddr_cpy); } else @@ -529,29 +529,29 @@ static void _cerebrod_config_error_check(void) { int i; - + if (conf.heartbeat_frequency_min <= 0) - cerebro_err_exit("heartbeat frequency min '%d' invalid", + cerebro_err_exit("heartbeat frequency min '%d' invalid", conf.heartbeat_frequency_min); if (conf.heartbeat_frequency_max <= 0) - cerebro_err_exit("heartbeat frequency max '%d' invalid", + cerebro_err_exit("heartbeat frequency max '%d' invalid", conf.heartbeat_frequency_max); - + if (conf.speak_message_config_len) { for (i = 0; i < conf.speak_message_config_len; i++) { _cerebrod_config_error_check_ip(conf.speak_message_config[i].ip); - + if (conf.speak_message_config[i].destination_port <= 0) - cerebro_err_exit("speak message destination port '%d' invalid", + cerebro_err_exit("speak message destination port '%d' invalid", conf.speak_message_config[i].destination_port); - + if (conf.speak_message_config[i].source_port <= 0) - cerebro_err_exit("speak message source port '%d' invalid", + cerebro_err_exit("speak message source port '%d' invalid", conf.speak_message_config[i].source_port); - + _cerebrod_config_error_check_network_interface(conf.speak_message_config[i].network_interface); } } @@ -566,9 +566,9 @@ _cerebrod_config_error_check(void) _cerebrod_config_error_check_ip(conf.listen_message_config[i].ip); if (conf.listen_message_config[i].port <= 0) - cerebro_err_exit("listen message port '%d' invalid", + cerebro_err_exit("listen message port '%d' invalid", conf.listen_message_config[i].port); - + _cerebrod_config_error_check_network_interface(conf.listen_message_config[i].network_interface); } } @@ -589,15 +589,15 @@ _cerebrod_config_error_check(void) for (i = 0; i < conf.forward_message_config_len; i++) { _cerebrod_config_error_check_ip(conf.forward_message_config[i].ip); - + if (conf.forward_message_config[i].destination_port <= 0) - cerebro_err_exit("forward message destination port '%d' invalid", + cerebro_err_exit("forward message destination port '%d' invalid", conf.forward_message_config[i].destination_port); - + if (conf.forward_message_config[i].source_port <= 0) - cerebro_err_exit("forward message source port '%d' invalid", + cerebro_err_exit("forward message source port '%d' invalid", conf.forward_message_config[i].source_port); - + _cerebrod_config_error_check_network_interface(conf.forward_message_config[i].network_interface); } } @@ -607,19 +607,19 @@ _cerebrod_config_error_check(void) } -/* +/* * achu: A significant portion of the network code below is from from - * Unix Network Programming, by R. Stevens, Chapter 16 + * Unix Network Programming, by R. Stevens, Chapter 16 */ /* * _get_if_conf * * Retrieve network interface configuration. - * + * * Return buffer of local network interface configurations. */ -static void +static void _get_if_conf(void **buf, struct ifconf *ifc, int fd) { int lastlen = -1, len = sizeof(struct ifreq) * 100; @@ -694,8 +694,8 @@ _get_ifr_len(struct ifreq *ifr) */ static void _calculate_in_addr_and_index(int is_multicast, - char *intf, - struct in_addr *in_addr, + char *intf, + struct in_addr *in_addr, int *index) { void *buf = NULL, *ptr = NULL; @@ -704,12 +704,12 @@ _calculate_in_addr_and_index(int is_multicast, struct ifconf ifc; int intf_type; - /* + /* * There are three possible formats for the interface input: * * - No interface specified (i.e. null) - * - IP address or subnet specified - * - Interface name specified + * - IP address or subnet specified + * - Interface name specified */ if (!intf) @@ -722,21 +722,21 @@ _calculate_in_addr_and_index(int is_multicast, { char *intf_cpy = Strdup(intf); char *s_mask, *ptr, *tok; - + tok = strtok(intf_cpy, "/"); if (!Inet_pton(AF_INET, tok, &addr_temp)) cerebro_err_exit("network interface IP '%s' invalid", intf); - + if (!(s_mask = strtok(NULL, ""))) cerebro_err_exit("subnet mask not specified in '%s'", intf); else { mask = strtol(s_mask, &ptr, 10); - if ((ptr != (s_mask + strlen(s_mask))) + if ((ptr != (s_mask + strlen(s_mask))) || (mask < 1 || mask > IPADDR_BITS)) cerebro_err_exit("subnet mask in '%s' invalid", intf); } - + Free(intf_cpy); } else @@ -746,16 +746,16 @@ _calculate_in_addr_and_index(int is_multicast, cerebro_err_exit("network interface IP '%s' invalid", intf); mask = IPADDR_BITS; } - + conf_masked_ip = htonl(addr_temp.s_addr) >> (IPADDR_BITS - mask); - + intf_type = INTF_IP; } else intf_type = INTF_NAME; assert(in_addr && index); - + /* Special Case */ if (intf_type == INTF_NONE && !is_multicast) { @@ -767,24 +767,24 @@ _calculate_in_addr_and_index(int is_multicast, _get_if_conf(&buf, &ifc, fd); - for (ptr = buf; ptr < buf + ifc.ifc_len; ) + for (ptr = buf; ptr < buf + ifc.ifc_len; ) { struct sockaddr_in *sinptr; struct ifreq ifr_tmp; struct ifreq *ifr; int len; - + ifr = (struct ifreq *)ptr; - + len = _get_ifr_len(ifr); - + ptr += sizeof(ifr->ifr_name) + len; - + /* Don't bother continuing if this isn't the right interface */ if (intf_type == INTF_NAME) { char ifr_name_buf[IFNAMSIZ+1]; - + /* Guarantee NUL termination */ memset(ifr_name_buf, '\0', IFNAMSIZ+1); memcpy(ifr_name_buf, ifr->ifr_name, IFNAMSIZ); @@ -821,17 +821,17 @@ _calculate_in_addr_and_index(int is_multicast, /* NUL termination not required, don't use strncpy() wrapper */ memset(&ifr_tmp, '\0', sizeof(struct ifreq)); strncpy(ifr_tmp.ifr_name, ifr->ifr_name, IFNAMSIZ); - + if(ioctl(fd, SIOCGIFINDEX, &ifr_tmp) < 0) CEREBROD_EXIT(("ioctl: %s", strerror(errno))); - + sinptr = (struct sockaddr_in *)&ifr->ifr_addr; in_addr->s_addr = sinptr->sin_addr.s_addr; *index = ifr_tmp.ifr_ifindex; found_interface++; break; } - + if (!found_interface) { if (is_multicast) @@ -848,7 +848,7 @@ _calculate_in_addr_and_index(int is_multicast, Close(fd); } -/* +/* * _cerebrod_ip_is_multicast * * Return 1 if the ip address is multicast, 0 if not @@ -874,7 +874,7 @@ _cerebrod_ip_is_multicast(char *ip) if (ptr != (tok + strlen(tok))) cerebro_err_exit("IP address '%s' invalid", ip); #endif - + if (ip_class >= MULTICAST_CLASS_MIN && ip_class <= MULTICAST_CLASS_MAX) rv = 1; else @@ -906,10 +906,10 @@ _cerebrod_calculate_configuration_data(void) { /* Determine if the message destination is single or multi casted */ conf.speak_message_config[i].ip_is_multicast = _cerebrod_ip_is_multicast(conf.speak_message_config[i].ip); - + /* Calculate the destination ip */ - if (!Inet_pton(AF_INET, - conf.speak_message_config[i].ip, + if (!Inet_pton(AF_INET, + conf.speak_message_config[i].ip, &conf.speak_message_config[i].ip_in_addr)) { hent = Gethostbyname(conf.speak_message_config[i].ip); @@ -932,10 +932,10 @@ _cerebrod_calculate_configuration_data(void) { /* Determine if the message destination is single or multi casted */ conf.listen_message_config[i].ip_is_multicast = _cerebrod_ip_is_multicast(conf.listen_message_config[i].ip); - + /* Calculate the destination ip */ - if (!Inet_pton(AF_INET, - conf.listen_message_config[i].ip, + if (!Inet_pton(AF_INET, + conf.listen_message_config[i].ip, &conf.listen_message_config[i].ip_in_addr)) { hent = Gethostbyname(conf.listen_message_config[i].ip); @@ -975,10 +975,10 @@ _cerebrod_calculate_configuration_data(void) { /* Determine if the message destination is single or multi casted */ conf.forward_message_config[i].ip_is_multicast = _cerebrod_ip_is_multicast(conf.forward_message_config[i].ip); - + /* Calculate the destination ip */ - if (!Inet_pton(AF_INET, - conf.forward_message_config[i].ip, + if (!Inet_pton(AF_INET, + conf.forward_message_config[i].ip, &conf.forward_message_config[i].ip_in_addr)) { hent = Gethostbyname(conf.forward_message_config[i].ip); @@ -1005,7 +1005,7 @@ static void _cerebrod_configuration_data_error_check(void) { int i; - + #if 0 /* XXX: I don't think this is valid any longer, we could be speaking * to a specific IP address but not listening for it so I'm going to @@ -1025,14 +1025,14 @@ _cerebrod_configuration_data_error_check(void) fd = Socket(AF_INET, SOCK_DGRAM, 0); _get_if_conf(&buf, &ifc, fd); - + if (!Inet_pton(AF_INET, conf.message_destination_ip, &addr_temp)) cerebro_err_exit("message destination IP address '%s' " "improperly format", conf.message_destination_ip); /* Check all interfaces */ for(ptr = buf; ptr < buf + ifc.ifc_len;) - { + { struct sockaddr_in *sinptr; int len; @@ -1041,18 +1041,18 @@ _cerebrod_configuration_data_error_check(void) len = _get_ifr_len(ifr); ptr += sizeof(ifr->ifr_name) + len; - + sinptr = (struct sockaddr_in *)&ifr->ifr_addr; - - if (!memcmp((void *)&addr_temp, - (void *)&sinptr->sin_addr, + + if (!memcmp((void *)&addr_temp, + (void *)&sinptr->sin_addr, sizeof(struct in_addr))) { found_interface++; break; } } - + Free(buf); Close(fd); @@ -1068,12 +1068,12 @@ _cerebrod_configuration_data_error_check(void) if (conf.metric_server_port == conf.speak_message_config[i].source_port) cerebro_err_exit("metric server port '%d' cannot be identical " "to a speak message source port", conf.metric_server_port); - + if (conf.metric_server_port == conf.speak_message_config[i].destination_port) cerebro_err_exit("metric server port '%d' cannot be identical " "to a speak message destination port", conf.metric_server_port); } - + for (i = 0; i < conf.listen_message_config_len; i++) { if (conf.metric_server_port == conf.listen_message_config[i].port) @@ -1086,7 +1086,7 @@ _cerebrod_configuration_data_error_check(void) "to event server port", conf.metric_server_port); } - /* If we are forwarding data, make sure to forward only to hosts that + /* If we are forwarding data, make sure to forward only to hosts that * aren't the localhost. */ if (conf.forward_message_config_len) @@ -1099,36 +1099,36 @@ _cerebrod_configuration_data_error_check(void) struct ifreq *ifr; void *buf = NULL, *ptr = NULL; int fd, found_interface = 0; - + fd = Socket(AF_INET, SOCK_DGRAM, 0); _get_if_conf(&buf, &ifc, fd); - + /* Check all interfaces */ for(ptr = buf; ptr < buf + ifc.ifc_len;) - { + { struct sockaddr_in *sinptr; int len; - + ifr = (struct ifreq *)ptr; - + len = _get_ifr_len(ifr); - + ptr += sizeof(ifr->ifr_name) + len; - + sinptr = (struct sockaddr_in *)&ifr->ifr_addr; - - if (!memcmp((void *)&conf.forward_message_config[i].ip_in_addr, - (void *)&sinptr->sin_addr, + + if (!memcmp((void *)&conf.forward_message_config[i].ip_in_addr, + (void *)&sinptr->sin_addr, sizeof(struct in_addr))) { found_interface++; break; } } - + Free(buf); Close(fd); - + if (found_interface) conf.forward_message_config[i].ip_is_local = 1; } @@ -1140,7 +1140,7 @@ _cerebrod_configuration_data_error_check(void) * * Dump configuration data */ -static void +static void _cerebrod_config_dump(void) { char hbuf[CEREBROD_CONFIG_HOSTLIST_BUFLEN]; @@ -1150,7 +1150,7 @@ _cerebrod_config_dump(void) return; fprintf(stderr, "**************************************\n"); - fprintf(stderr, "* Cerebrod Configuration:\n"); + fprintf(stderr, "* Cerebrod Configuration:\n"); fprintf(stderr, "* -------------------------------\n"); fprintf(stderr, "* Command Line Options\n"); fprintf(stderr, "* -------------------------------\n"); @@ -1200,7 +1200,7 @@ _cerebrod_config_dump(void) if (conf.forward_message_config[i].hosts) { memset(hbuf, '\0', CEREBROD_CONFIG_HOSTLIST_BUFLEN); - Hostlist_ranged_string(conf.forward_message_config[i].hosts, + Hostlist_ranged_string(conf.forward_message_config[i].hosts, CEREBROD_CONFIG_HOSTLIST_BUFLEN, hbuf); fprintf(stderr, "* forward[%d]: hosts: \"%s\"\n", i, hbuf); diff --git a/src/cerebrod/cerebrod_config.h b/src/cerebrod/cerebrod_config.h index 52282219..8a22bb8f 100644 --- a/src/cerebrod/cerebrod_config.h +++ b/src/cerebrod/cerebrod_config.h @@ -117,7 +117,7 @@ struct forward_message_config { }; /* - * struct cerebrod_config + * struct cerebrod_config * * configuration structure and data used by all of cerebrod. */ @@ -130,7 +130,7 @@ struct cerebrod_config /* Set by the user in the configuration file */ int heartbeat_frequency_min; int heartbeat_frequency_max; - int speak; + int speak; struct speak_message_config speak_message_config[CEREBRO_CONFIG_SPEAK_MESSAGE_CONFIG_MAX]; int speak_message_config_len; int speak_message_ttl; @@ -170,7 +170,7 @@ struct cerebrod_config /* * cerebrod_config_setup - * + * * perform all cerebrod configuration. Includes command line parsing, * config module loading, and configuration file parsing */ diff --git a/src/cerebrod/cerebrod_daemon.c b/src/cerebrod/cerebrod_daemon.c index 181c0ac5..34f67232 100644 --- a/src/cerebrod/cerebrod_daemon.c +++ b/src/cerebrod/cerebrod_daemon.c @@ -45,24 +45,24 @@ cerebrod_daemon_init(void) /* Based on code in Unix network programming by R. Stevens */ pid_t pid; int i; - + pid = Fork(); if (pid != 0) /* Terminate Parent */ exit(0); - + setsid(); - + Signal(SIGHUP, SIG_IGN); - + pid = Fork(); if (pid != 0) /* Terminate 1st Child */ exit(0); Chdir("/"); - + Umask(0); - + /* Don't use Close() wrapper, we don't want to exit on error */ for (i = 0; i < 64; i++) - close(i); + close(i); } diff --git a/src/cerebrod/cerebrod_daemon.h b/src/cerebrod/cerebrod_daemon.h index 97855bd8..3b5f9fb0 100644 --- a/src/cerebrod/cerebrod_daemon.h +++ b/src/cerebrod/cerebrod_daemon.h @@ -28,7 +28,7 @@ #ifndef _CEREBROD_DAEMON_H #define _CEREBROD_DAEMON_H -/* +/* * cerebrod_daemon_init * * daemonize the cerebrod process diff --git a/src/cerebrod/cerebrod_debug.h b/src/cerebrod/cerebrod_debug.h index 5bc54093..b1e3446f 100644 --- a/src/cerebrod/cerebrod_debug.h +++ b/src/cerebrod/cerebrod_debug.h @@ -37,7 +37,7 @@ #if CEREBRO_DEBUG #define CEREBROD_DBG(msg) CEREBRO_DBG(msg) - + #else /* !CEREBRO_DEBUG */ #define CEREBROD_DBG(msg) \ diff --git a/src/cerebrod/cerebrod_event_node_timeout_monitor.c b/src/cerebrod/cerebrod_event_node_timeout_monitor.c index 25a5b13b..c7df2be8 100644 --- a/src/cerebrod/cerebrod_event_node_timeout_monitor.c +++ b/src/cerebrod/cerebrod_event_node_timeout_monitor.c @@ -56,7 +56,7 @@ extern struct cerebrod_config conf; extern pthread_mutex_t debug_output_mutex; -/* +/* * event_node_timeout_monitor_init * event_node_timeout_monitor_init_cond * event_node_timeout_monitor_init_lock @@ -157,7 +157,7 @@ cerebrod_event_node_timeout_monitor(void *arg) List_sort(event_node_timeout_data, _event_node_timeout_data_compare); nodesitr = List_iterator_create(event_node_timeout_data); - + while ((ntd = list_next(nodesitr))) { struct cerebrod_event_module_timeout_data *mtd; @@ -181,14 +181,14 @@ cerebrod_event_node_timeout_monitor(void *arg) Pthread_mutex_unlock(&debug_output_mutex); } - if ((modules_list = Hash_find(event_module_timeout_index, + if ((modules_list = Hash_find(event_module_timeout_index, mtd->timeout_str))) { struct cerebrod_event_module *event_module; ListIterator modulesitr; modulesitr = List_iterator_create(modules_list); - + while ((event_module = list_next(modulesitr))) { struct cerebro_event *event = NULL; @@ -197,7 +197,7 @@ cerebrod_event_node_timeout_monitor(void *arg) Pthread_mutex_lock(&event_module->event_lock); if ((rv = event_module_node_timeout(event_handle, event_module->index, - ntd->nodename, + ntd->nodename, &event)) < 0) { CEREBROD_DBG(("event_module_node_timeout")); diff --git a/src/cerebrod/cerebrod_event_node_timeout_monitor.h b/src/cerebrod/cerebrod_event_node_timeout_monitor.h index 84d405f9..ba439b6f 100644 --- a/src/cerebrod/cerebrod_event_node_timeout_monitor.h +++ b/src/cerebrod/cerebrod_event_node_timeout_monitor.h @@ -28,7 +28,7 @@ #ifndef _CEREBROD_EVENT_NODE_TIMEOUT_H #define _CEREBROD_EVENT_NODE_TIMEOUT_H -/* +/* * cerebrod_event_node_timeout_monitor * * Runs the cerebrod event node timeout monitor. This thread will @@ -36,7 +36,7 @@ * must be notified. * * Passed no argument - * + * * Executed in detached state, no return value. */ void *cerebrod_event_node_timeout_monitor(void *); diff --git a/src/cerebrod/cerebrod_event_server.c b/src/cerebrod/cerebrod_event_server.c index 8352b384..168f4455 100644 --- a/src/cerebrod/cerebrod_event_server.c +++ b/src/cerebrod/cerebrod_event_server.c @@ -64,7 +64,7 @@ extern pthread_mutex_t debug_output_mutex; #define CEREBROD_EVENT_SERVER_BACKLOG 10 -/* +/* * event_server_init * event_server_init_cond * event_server_init_lock @@ -76,7 +76,7 @@ int event_server_init = 0; pthread_cond_t event_server_init_cond = PTHREAD_COND_INITIALIZER; pthread_mutex_t event_server_init_lock = PTHREAD_MUTEX_INITIALIZER; -/* +/* * event_queue_monitor_init * event_queue_monitor_init_cond * event_queue_monitor_init_lock @@ -88,7 +88,7 @@ int event_queue_monitor_init = 0; pthread_cond_t event_queue_monitor_init_cond = PTHREAD_COND_INITIALIZER; pthread_mutex_t event_queue_monitor_init_lock = PTHREAD_MUTEX_INITIALIZER; -/* +/* * event_connections * event_connections_index * event_connections_lock @@ -98,7 +98,7 @@ pthread_mutex_t event_queue_monitor_init_lock = PTHREAD_MUTEX_INITIALIZER; List event_connections = NULL; hash_t event_connections_index = NULL; pthread_mutex_t event_connections_lock = PTHREAD_MUTEX_INITIALIZER; - + extern List event_names; extern List event_queue; @@ -119,7 +119,7 @@ cerebrod_queue_event(struct cerebro_event *event, unsigned int index) ets->event_name = event->event_name; ets->index = index; ets->event = event; - + List_append(event_queue, ets); Pthread_cond_signal(&event_queue_cond); @@ -149,7 +149,7 @@ _event_queue_monitor_initialize(void) Pthread_mutex_unlock(&event_queue_monitor_init_lock); } -/* +/* * _event_dump * * Output event debugging info @@ -229,7 +229,7 @@ _event_dump(struct cerebro_event *event) } } -/* +/* * _event_marshall * * marshall event packet @@ -243,7 +243,7 @@ _event_marshall(struct cerebro_event *event, { int bufPtrlen, n, c = 0; char *bufPtr; - + assert(event && buf && buflen >= CEREBRO_EVENT_HEADER_LEN); memset(buf, '\0', buflen); @@ -285,10 +285,10 @@ cerebrod_event_queue_monitor(void *arg) temp_event_queue = List_create((ListDelF)cerebrod_event_to_send_destroy); - /* + /* * achu: The listener and thus event update initialization is * started after this thread is started. So the and event_index may - * not be set up the first time this loop is reached. + * not be set up the first time this loop is reached. * * However, it must be set after the condition is signaled, b/c the * listener (and thus event update code) and event node timeout @@ -328,15 +328,15 @@ cerebrod_event_queue_monitor(void *arg) List connections; _event_dump(ets->event); - + Pthread_mutex_lock(&event_connections_lock); if ((connections = Hash_find(event_connections_index, ets->event_name))) { char buf[CEREBRO_MAX_PACKET_LEN]; int elen; - if ((elen = _event_marshall(ets->event, - buf, + if ((elen = _event_marshall(ets->event, + buf, CEREBRO_MAX_PACKET_LEN)) > 0) { ListIterator citr; @@ -375,7 +375,7 @@ cerebrod_event_queue_monitor(void *arg) List_delete(titr); } - + List_iterator_destroy(titr); } @@ -488,14 +488,14 @@ _delete_event_connection_fd(int fd) if (rv != EBUSY) CEREBROD_EXIT(("mutex not locked: rv=%d", rv)); #endif /* CEREBRO_DEBUG */ - + eitr = List_iterator_create(event_connections); while ((ecd = list_next(eitr))) { if (ecd->fd == fd) { List connections; - if ((connections = Hash_find(event_connections_index, + if ((connections = Hash_find(event_connections_index, ecd->event_name))) { ListIterator citr; @@ -504,7 +504,7 @@ _delete_event_connection_fd(int fd) citr = List_iterator_create(connections); while ((fdPtr = list_next(citr))) { - if (*fdPtr == fd) + if (*fdPtr == fd) { List_delete(citr); break; @@ -533,11 +533,11 @@ _event_server_response_marshall(struct cerebro_event_server_response *res, { int bufPtrlen, c = 0; char *bufPtr; - + assert(res && buf && buflen >= CEREBRO_EVENT_SERVER_RESPONSE_LEN); - + memset(buf, '\0', buflen); - + c += Marshall_int32(res->version, buf + c, buflen - c); c += Marshall_u_int32(res->err_code, buf + c, buflen - c); c += Marshall_u_int8(res->end, buf + c, buflen - c); @@ -555,7 +555,7 @@ _event_server_response_marshall(struct cerebro_event_server_response *res, * Return 0 on success, -1 on error */ static int -_event_server_response_send(int fd, +_event_server_response_send(int fd, struct cerebro_event_server_response *res) { char buf[CEREBRO_MAX_PACKET_LEN]; @@ -563,8 +563,8 @@ _event_server_response_send(int fd, assert(fd >= 0 && res); - if ((res_len = _event_server_response_marshall(res, - buf, + if ((res_len = _event_server_response_marshall(res, + buf, CEREBRO_MAX_PACKET_LEN)) < 0) return -1; @@ -585,8 +585,8 @@ _event_server_response_send(int fd, * Return 0 on success, -1 on error */ static int -_event_server_err_only_response(int fd, - int32_t version, +_event_server_err_only_response(int fd, + int32_t version, u_int32_t err_code) { struct cerebro_event_server_response res; @@ -602,8 +602,8 @@ _event_server_err_only_response(int fd, res.err_code = err_code; res.end = CEREBRO_EVENT_SERVER_PROTOCOL_IS_LAST_RESPONSE; - if ((res_len = _event_server_response_marshall(&res, - buf, + if ((res_len = _event_server_response_marshall(&res, + buf, CEREBRO_MAX_PACKET_LEN)) < 0) return -1; @@ -638,7 +638,7 @@ _event_server_request_check_version(const char *buf, if (*version != CEREBRO_EVENT_SERVER_PROTOCOL_VERSION) return -1; - + return 0; } @@ -656,7 +656,7 @@ _event_server_request_unmarshall(struct cerebro_event_server_request *req, { int bufPtrlen, c = 0; char *bufPtr; - + assert(req && buf); bufPtr = req->event_name; @@ -700,7 +700,7 @@ _event_server_request_dump(struct cerebro_event_server_request *req) Pthread_mutex_unlock(&debug_output_mutex); } -/* +/* * _event_names_compare * * Comparison for list_find @@ -848,7 +848,7 @@ _respond_with_event_names(void *arg) assert(arg); fd = *((int *)arg); - + if (!event_names) goto end_response; @@ -1000,7 +1000,7 @@ _event_server_service_connection(int fd) } /* Event names is not changeable - so no need for a lock */ - if (!(event_name_ptr = list_find_first(event_names, + if (!(event_name_ptr = list_find_first(event_names, _event_names_compare, event_name_buf))) { @@ -1009,7 +1009,7 @@ _event_server_service_connection(int fd) CEREBRO_EVENT_SERVER_PROTOCOL_ERR_EVENT_INVALID); goto cleanup; } - + if (!(ecd = (struct cerebrod_event_connection_data *)malloc(sizeof(struct cerebrod_event_connection_data)))) { CEREBROD_ERR(("malloc: %s", strerror(errno))); @@ -1018,10 +1018,10 @@ _event_server_service_connection(int fd) CEREBRO_EVENT_SERVER_PROTOCOL_ERR_INTERNAL_ERROR); goto cleanup; } - + ecd->event_name = event_name_ptr; ecd->fd = fd; - + if (!(fdptr = (int *)malloc(sizeof(int)))) { CEREBROD_ERR(("malloc: %s", strerror(errno))); @@ -1042,7 +1042,7 @@ _event_server_service_connection(int fd) goto cleanup; } - if (!(connections = Hash_find(event_connections_index, + if (!(connections = Hash_find(event_connections_index, ecd->event_name))) { if (!(connections = list_create((ListDelF)free))) @@ -1083,7 +1083,7 @@ _event_server_service_connection(int fd) CEREBRO_EVENT_SERVER_PROTOCOL_ERR_SUCCESS); return; - + cleanup: if (ecd) free(ecd); @@ -1147,7 +1147,7 @@ cerebrod_event_server(void *arg) List_iterator_destroy(eitr); Pthread_mutex_unlock(&event_connections_lock); } - + Poll(pfds, pfdslen, -1); /* Deal with the server fd first */ @@ -1196,7 +1196,7 @@ cerebrod_event_server(void *arg) * our fd. */ - n = fd_read_n(pfds[i].fd, + n = fd_read_n(pfds[i].fd, buf, CEREBRO_MAX_PACKET_LEN); if (n < 0) @@ -1218,7 +1218,7 @@ cerebrod_event_server(void *arg) } } } - + Free(pfds); } diff --git a/src/cerebrod/cerebrod_event_server.h b/src/cerebrod/cerebrod_event_server.h index 0aef0ab3..ec08c718 100644 --- a/src/cerebrod/cerebrod_event_server.h +++ b/src/cerebrod/cerebrod_event_server.h @@ -32,7 +32,7 @@ #include "list.h" -/* +/* * struct cerebrod_event_to_send * * Store information necessary to send out an event @@ -45,7 +45,7 @@ struct cerebrod_event_to_send struct cerebro_event *event; }; -/* +/* * struct cerebrod_event_connection_data * * Store data about current event connections. @@ -74,25 +74,25 @@ struct cerebrod_event_names_response_data */ void cerebrod_queue_event(struct cerebro_event *event, unsigned int index); -/* +/* * cerebrod_event_queue_monitor * * Runs the cerebrod event queue monitor which will send out events * when signaled. * * Passed no argument - * + * * Executed in detached state, no return value. */ void *cerebrod_event_queue_monitor(void *); -/* +/* * cerebrod_event_server * * Runs the cerebrod event server thread * * Passed no argument - * + * * Executed in detached state, no return value. */ void *cerebrod_event_server(void *); diff --git a/src/cerebrod/cerebrod_event_update.c b/src/cerebrod/cerebrod_event_update.c index 5b7723fd..d4ba1b9b 100644 --- a/src/cerebrod/cerebrod_event_update.c +++ b/src/cerebrod/cerebrod_event_update.c @@ -84,7 +84,7 @@ event_modules_t event_handle = NULL; */ hash_t event_index = NULL; -/* +/* * event_module_timeout_index * * Map of timeouts to modules that need to be called @@ -98,7 +98,7 @@ hash_t event_module_timeout_index = NULL; */ List event_names = NULL; -/* +/* * event_module_timeouts * * List of module timeout lengths @@ -106,7 +106,7 @@ List event_names = NULL; List event_module_timeouts = NULL; unsigned int event_module_timeout_min = INT_MAX; -/* +/* * event_node_timeout_data * event_node_timeout_data_index * @@ -118,7 +118,7 @@ hash_t event_node_timeout_data_index = NULL; int event_node_timeout_data_index_numnodes; int event_node_timeout_data_index_size; -/* +/* * event_node_timeout_data_lock * * lock to protect pthread access to both the event_node_timeout_data @@ -172,7 +172,7 @@ _cerebrod_event_module_info_destroy(void *data) Free(event_module); } -/* +/* * _cerebrod_event_module_timeout_data_destroy * * Destroy a monitor_module struct. @@ -181,15 +181,15 @@ static void _cerebrod_event_module_timeout_data_destroy(void *data) { struct cerebrod_event_module_timeout_data *mtd; - + assert(data); - + mtd = (struct cerebrod_event_module_timeout_data *)data; Free(mtd->timeout_str); Free(mtd); } -/* +/* * _event_node_timeout_data_add * * Create entries for the event_node_timeout_data list and index @@ -220,7 +220,7 @@ _event_node_timeout_data_add(const char *nodename, u_int32_t time_now) return 0; } -/* +/* * _event_node_timeout_data_callback * * Callback from Hash_for_each on listener_data to create entries for @@ -237,7 +237,7 @@ _event_node_timeout_data_callback(void *data, const void *key, void *arg) nd = (struct cerebrod_node_data *)data; /* Note: Lock not really necessary b/c this function is called - * during initialization, but it'll make the debug stuff happy + * during initialization, but it'll make the debug stuff happy * when you call _event_node_timeout_data_add(). */ #if CEREBRO_DEBUG @@ -250,7 +250,7 @@ _event_node_timeout_data_callback(void *data, const void *key, void *arg) return 1; } -/* +/* * _event_module_timeout_data_find_callback * * Callback for list_find to find matching timeout @@ -266,7 +266,7 @@ _event_module_timeout_data_find_callback(void *x, void *key) timeout = *((int *)key); mtd = (struct cerebrod_event_module_timeout_data *)x; - + if (mtd->timeout == timeout) return 1; return 0; @@ -297,7 +297,7 @@ _event_module_timeout_data_compare(void *x, void *y) /* * _setup_event_node_timeout_data * - * Setup event timeout calculation data structures. + * Setup event timeout calculation data structures. * * Return 0 on success, -1 on error */ @@ -311,12 +311,12 @@ _setup_event_node_timeout_data(void) assert(listener_data); event_node_timeout_data = List_create(NULL); - event_node_timeout_data_index = Hash_create(EVENT_NODE_TIMEOUT_SIZE_DEFAULT, + event_node_timeout_data_index = Hash_create(EVENT_NODE_TIMEOUT_SIZE_DEFAULT, (hash_key_f)hash_key_string, - (hash_cmp_f)strcmp, + (hash_cmp_f)strcmp, (hash_del_f)NULL); event_node_timeout_data_index_size = EVENT_NODE_TIMEOUT_SIZE_DEFAULT; - + Gettimeofday(&tv, NULL); num = Hash_for_each(listener_data, @@ -510,7 +510,7 @@ cerebrod_event_modules_setup(void) event_module_cleanup(event_handle, i); continue; } - + if ((timeout = event_module_timeout_length(event_handle, i)) < 0) { CEREBROD_DBG(("event_module_timeout_length failed: %s", module_name)); @@ -525,7 +525,7 @@ cerebrod_event_modules_setup(void) Pthread_mutex_init(&(event_module->event_lock), NULL); /* The monitoring module may support multiple metrics */ - + metricPtr = strtok_r(event_module->metric_names, ",", &metricbuf); while (metricPtr) { @@ -541,7 +541,7 @@ cerebrod_event_modules_setup(void) } else List_append(el->event_list, event_module); - + metricPtr = strtok_r(NULL, ",", &metricbuf); } @@ -572,8 +572,8 @@ cerebrod_event_modules_setup(void) struct cerebrod_event_module_timeout_data *mtd; List modules_list; - if (!(mtd = List_find_first(event_module_timeouts, - _event_module_timeout_data_find_callback, + if (!(mtd = List_find_first(event_module_timeouts, + _event_module_timeout_data_find_callback, &timeout))) { char strbuf[64]; @@ -584,12 +584,12 @@ cerebrod_event_modules_setup(void) mtd->timeout_str = Strdup(strbuf); List_append(event_module_timeouts, mtd); - + if (timeout < event_module_timeout_min) event_module_timeout_min = timeout; } - if (!(modules_list = Hash_find(event_module_timeout_index, + if (!(modules_list = Hash_find(event_module_timeout_index, mtd->timeout_str))) { modules_list = List_create((ListDelF)NULL); @@ -602,7 +602,7 @@ cerebrod_event_modules_setup(void) List_append(modules_list, event_module); } } - + List_sort(event_module_timeouts, _event_module_timeout_data_compare); if (!event_index_count) @@ -611,7 +611,7 @@ cerebrod_event_modules_setup(void) if (_setup_event_node_timeout_data() < 0) goto cleanup; - /* + /* * Since the cerebrod listener is started before any of the event * threads (node_timeout, queue_monitor, server), this must be * created in here (which is called by the listener) to avoid a @@ -621,7 +621,7 @@ cerebrod_event_modules_setup(void) event_queue = List_create((ListDelF)cerebrod_event_to_send_destroy); return 1; - + cleanup: if (event_handle) { @@ -641,7 +641,7 @@ cerebrod_event_modules_setup(void) return 0; } -void +void cerebrod_event_add_node_timeout_data(struct cerebrod_node_data *nd, u_int32_t received_time) { @@ -678,7 +678,7 @@ cerebrod_event_add_node_timeout_data(struct cerebrod_node_data *nd, Pthread_mutex_unlock(&event_node_timeout_data_lock); } -void +void cerebrod_event_update_node_received_time(struct cerebrod_node_data *nd, u_int32_t received_time) { @@ -720,7 +720,7 @@ cerebrod_event_modules_update(const char *nodename, #if CEREBRO_DEBUG int rv; #endif /* CEREBRO_DEBUG */ - + assert(nodename && nd && metric_name && mm); if (!event_index) diff --git a/src/cerebrod/cerebrod_event_update.h b/src/cerebrod/cerebrod_event_update.h index 20ec3951..b8d1baea 100644 --- a/src/cerebrod/cerebrod_event_update.h +++ b/src/cerebrod/cerebrod_event_update.h @@ -43,7 +43,7 @@ #include "list.h" -/* +/* * struct cerebrod_event_module_list * * Contains list of event module info list and a lock for thread @@ -68,7 +68,7 @@ struct cerebrod_event_module_info pthread_mutex_t event_lock; }; -/* +/* * struct cerebrod_event_node_timeout_data * * contains information needed for timeout calculations @@ -80,7 +80,7 @@ struct cerebrod_event_node_timeout_data int timeout_occurred; }; -/* +/* * struct cerebrod_event_module_timeout_data * * Store a timeout and it's string @@ -108,7 +108,7 @@ void cerebrod_event_to_send_destroy(void *x); */ int cerebrod_event_modules_setup(void); -/* +/* * cerebrod_event_add_node_timeout_data * * Called to add another node timeout data element to appropriate @@ -117,7 +117,7 @@ int cerebrod_event_modules_setup(void); void cerebrod_event_add_node_timeout_data(struct cerebrod_node_data *nd, u_int32_t received_time); -/* +/* * cerebrod_event_update_node_received_time * * Called to update node timeout data is a cerebrod message was diff --git a/src/cerebrod/cerebrod_listener.c b/src/cerebrod/cerebrod_listener.c index b551983a..ddcf1875 100644 --- a/src/cerebrod/cerebrod_listener.c +++ b/src/cerebrod/cerebrod_listener.c @@ -65,7 +65,7 @@ extern pthread_mutex_t debug_output_mutex; extern clusterlist_module_t clusterlist_handle; -/* +/* * listener_init * listener_init_cond * listener_init_lock @@ -77,7 +77,7 @@ int listener_init = 0; pthread_cond_t listener_init_cond = PTHREAD_COND_INITIALIZER; pthread_mutex_t listener_init_lock = PTHREAD_MUTEX_INITIALIZER; -/* +/* * listener_fds * listener_fds_lock * @@ -86,7 +86,7 @@ pthread_mutex_t listener_init_lock = PTHREAD_MUTEX_INITIALIZER; int listener_fds[CEREBRO_CONFIG_LISTEN_MESSAGE_CONFIG_MAX]; pthread_mutex_t listener_fds_lock = PTHREAD_MUTEX_INITIALIZER; -/* +/* * struct forwarding_info * * forwarding information and a lock to protect concurrent access @@ -107,7 +107,7 @@ struct forwarding_info forwarding_info[CEREBRO_CONFIG_FORWARD_MESSAGE_CONFIG_MAX clusterlist_module_t clusterlist_handle; int found_clusterlist_module = 0; -/* +/* * _listener_setup_socket * * Create and setup the listener socket. Do not use wrappers in this @@ -116,7 +116,7 @@ int found_clusterlist_module = 0; * * In this socket setup function, 'num' is used as the message config * and file descriptor index. - * + * * Returns file descriptor on success, -1 on error */ static int @@ -168,7 +168,7 @@ _listener_setup_socket(int num) memset(&addr, '\0', sizeof(struct sockaddr_in)); addr.sin_family = AF_INET; addr.sin_port = htons(conf.listen_message_config[num].port); - memcpy(&addr.sin_addr, + memcpy(&addr.sin_addr, &conf.listen_message_config[num].ip_in_addr, sizeof(struct in_addr)); if (bind(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) @@ -176,7 +176,7 @@ _listener_setup_socket(int num) CEREBROD_ERR(("bind: %s", strerror(errno))); goto cleanup; } - + return fd; cleanup: @@ -185,7 +185,7 @@ _listener_setup_socket(int num) return -1; } -/* +/* * _forwarding_setup_socket * * Create and setup the forwarding socket. Do not use wrappers in @@ -194,7 +194,7 @@ _listener_setup_socket(int num) * * In this socket setup function, 'num' is used as the message config * and forwarding info index. - * + * * Returns file descriptor on success, -1 on error */ static int @@ -233,7 +233,7 @@ _forwarding_setup_socket(int num) goto cleanup; } - /* Turn off loopback for forwarding, since we already + /* Turn off loopback for forwarding, since we already * have the data. */ optval = 0; @@ -282,11 +282,11 @@ _forwarding_setup_socket(int num) return -1; } -/* +/* * _forwarding_setup * * 'index' is the index of the message config and forwarding info. - * + * * Returns 0 success, -1 on error */ static int @@ -317,7 +317,7 @@ _forwarding_setup(int index) { if (clusterlist_module_get_nodename(clusterlist_handle, node, - nodebuf, + nodebuf, CEREBRO_MAX_NODENAME_LEN+1) < 0) { CEREBROD_DBG(("clusterlist_module_get_nodename: %s", nodebuf)); @@ -328,9 +328,9 @@ _forwarding_setup(int index) } else nodeptr = node; - + Hostlist_push(forwarding_info[index].hosts, nodeptr); - + free(node); } } @@ -368,7 +368,7 @@ _cerebrod_listener_initialize(void) if (!(clusterlist_handle = clusterlist_module_load())) CEREBROD_EXIT(("clusterlist_module_load")); - + if ((found_clusterlist_module = clusterlist_module_found(clusterlist_handle)) < 0) CEREBROD_EXIT(("clusterlist_module_found")); @@ -382,7 +382,7 @@ _cerebrod_listener_initialize(void) fprintf(stderr, "**************************************\n"); fprintf(stderr, "* Cerebro Clusterlist\n"); fprintf(stderr, "* -----------------------\n"); - fprintf(stderr, "* Using Clusterlist: %s\n", + fprintf(stderr, "* Using Clusterlist: %s\n", clusterlist_module_name(clusterlist_handle)); fprintf(stderr, "**************************************\n"); } @@ -405,7 +405,7 @@ _cerebrod_listener_initialize(void) Pthread_mutex_unlock(&listener_init_lock); } -/* +/* * _cerebrod_message_check_version * * Check that the version is correct prior to unmarshalling @@ -422,7 +422,7 @@ _cerebrod_message_check_version(const char *buf, unsigned int buflen) if (version != CEREBROD_MESSAGE_PROTOCOL_VERSION) return -1; - + return 0; } @@ -444,11 +444,11 @@ _cerebrod_message_unmarshall(const char *buf, unsigned int buflen) int i, n, bufPtrlen, c = 0; assert(buf); - + msg = Malloc(sizeof(struct cerebrod_message)); memset(msg, '\0', sizeof(struct cerebrod_message)); - + if (!(n = Unmarshall_int32(&(msg->version), buf + c, buflen - c))) goto cleanup; c += n; @@ -458,7 +458,7 @@ _cerebrod_message_unmarshall(const char *buf, unsigned int buflen) if (!(n = Unmarshall_buffer(bufPtr, bufPtrlen, buf + c, buflen - c))) goto cleanup; c += n; - + if (!(n = Unmarshall_u_int32(&(msg->metrics_len), buf + c, buflen - c))) goto cleanup; c += n; @@ -474,11 +474,11 @@ _cerebrod_message_unmarshall(const char *buf, unsigned int buflen) msg->metrics = NULL; return msg; } - + size = sizeof(struct cerebrod_message_metric *)*(msg->metrics_len + 1); msg->metrics = Malloc(size); memset(msg->metrics, '\0', size); - + for (i = 0; i < msg->metrics_len; i++) { char *mname; @@ -486,22 +486,22 @@ _cerebrod_message_unmarshall(const char *buf, unsigned int buflen) mm = Malloc(sizeof(struct cerebrod_message_metric)); memset(mm, '\0', sizeof(struct cerebrod_message_metric)); - + mname = mm->metric_name; mnamelen = sizeof(mm->metric_name); - + if (!(n = Unmarshall_buffer(mname, mnamelen, buf + c, buflen - c))) goto cleanup; c += n; - + if ((n = unmarshall_data_type_len(&(mm->metric_value_type), &(mm->metric_value_len), - buf + c, + buf + c, buflen - c, NULL)) < 0) goto cleanup; c += n; - + if (check_data_type_len(mm->metric_value_type, mm->metric_value_len) < 0) goto cleanup; @@ -509,7 +509,7 @@ _cerebrod_message_unmarshall(const char *buf, unsigned int buflen) if (mm->metric_value_len) { mm->metric_value = Malloc(mm->metric_value_len); - if ((n = unmarshall_data_value(mm->metric_value_type, + if ((n = unmarshall_data_value(mm->metric_value_type, mm->metric_value_len, mm->metric_value, mm->metric_value_len, @@ -608,15 +608,15 @@ cerebrod_listener(void *arg) { if (FD_ISSET(listener_fds[i], &readfds)) { - if ((recv_len = recvfrom(listener_fds[i], - buf, - CEREBRO_MAX_PACKET_LEN, - 0, - NULL, + if ((recv_len = recvfrom(listener_fds[i], + buf, + CEREBRO_MAX_PACKET_LEN, + 0, + NULL, NULL)) < 0) - listener_fds[i] = cerebrod_reinit_socket(listener_fds[i], + listener_fds[i] = cerebrod_reinit_socket(listener_fds[i], i, - _listener_setup_socket, + _listener_setup_socket, "listener: recvfrom"); break; } @@ -646,7 +646,7 @@ cerebrod_listener(void *arg) } _cerebrod_message_dump(msg, "Received Message"); - + /* Guarantee ending '\0' character */ memset(nodename_buf, '\0', CEREBRO_MAX_NODENAME_LEN+1); memcpy(nodename_buf, msg->nodename, CEREBRO_MAX_NODENAME_LEN); @@ -673,25 +673,25 @@ cerebrod_listener(void *arg) } else /* must assume it is in the cluster */ - /* Note, there is no need to handle 'forward_host_accept' under this case, + /* Note, there is no need to handle 'forward_host_accept' under this case, * since we don't know if it is in the cluster or not anyways. */ in_cluster_flag = 1; - + if (!in_cluster_flag) { CEREBROD_DBG(("received non-cluster packet: %s", nodename_buf)); cerebrod_message_destroy(msg); continue; } - + memset(nodename_key, '\0', CEREBRO_MAX_NODENAME_LEN+1); if (found_clusterlist_module) { if (clusterlist_module_get_nodename(clusterlist_handle, nodename_buf, - nodename_key, + nodename_key, CEREBRO_MAX_NODENAME_LEN+1) < 0) { CEREBROD_DBG(("clusterlist_module_get_nodename: %s", nodename_buf)); @@ -722,21 +722,21 @@ cerebrod_listener(void *arg) struct sockaddr_in msgaddr; unsigned int addrlen; int rv; - + memset(&msgaddr, '\0', sizeof(struct sockaddr_in)); msgaddr.sin_family = AF_INET; msgaddr.sin_port = htons(conf.forward_message_config[i].destination_port); memcpy(&msgaddr.sin_addr, &conf.forward_message_config[i].ip_in_addr, sizeof(struct in_addr)); - + addr = (struct sockaddr *)&msgaddr; addrlen = sizeof(struct sockaddr_in); - + _cerebrod_message_dump(msg, "Forwarding Message"); Pthread_mutex_lock(&forwarding_info[i].lock); - + if ((rv = sendto(forwarding_info[i].fd, buf, recv_len, @@ -752,7 +752,7 @@ cerebrod_listener(void *arg) else CEREBROD_ERR(("sendto: invalid bytes sent")); } - + Pthread_mutex_unlock(&forwarding_info[i].lock); } } diff --git a/src/cerebrod/cerebrod_listener.h b/src/cerebrod/cerebrod_listener.h index 073c69bf..6b3b0aca 100644 --- a/src/cerebrod/cerebrod_listener.h +++ b/src/cerebrod/cerebrod_listener.h @@ -28,13 +28,13 @@ #ifndef _CEREBROD_LISTENER_H #define _CEREBROD_LISTENER_H -/* +/* * cerebrod_listener * * Runs a cerebrod listening thread * * Passed no argument - * + * * Executed in detached state, no return value. */ void *cerebrod_listener(void *); diff --git a/src/cerebrod/cerebrod_listener_data.c b/src/cerebrod/cerebrod_listener_data.c index 8ff07344..a8a0d05c 100644 --- a/src/cerebrod/cerebrod_listener_data.c +++ b/src/cerebrod/cerebrod_listener_data.c @@ -91,14 +91,14 @@ hash_t listener_data = NULL; int listener_data_numnodes; int listener_data_size; -/* +/* * listener_data_lock * * lock to protect pthread access to listener_data */ pthread_mutex_t listener_data_lock = PTHREAD_MUTEX_INITIALIZER; -/* +/* * metric_names * metric_names_size * @@ -108,7 +108,7 @@ hash_t metric_names = NULL; int metric_names_size; int metric_names_count; -/* +/* * metric_name_defaults * metric_name_defaults_count * @@ -122,7 +122,7 @@ char *metric_name_defaults[] = { }; int metric_name_defaults_count = 3; -/* +/* * metric_names_lock * * lock to protect pthread access to the metric_name index @@ -146,23 +146,23 @@ metric_data_create(const char *metric_name) return md; } -void +void metric_data_destroy(void *data) { struct cerebrod_metric_data *md; assert(data); - + md = (struct cerebrod_metric_data *)data; Free(md->metric_name); Free(md->metric_value); Free(md); } -/* +/* * _cerebrod_node_data_create_and_init * - * Create and initialize a cerebrod_node_data + * Create and initialize a cerebrod_node_data * */ static struct cerebrod_node_data * @@ -180,9 +180,9 @@ _cerebrod_node_data_create_and_init(const char *nodename) Pthread_mutex_init(&(nd->node_data_lock), NULL); if (conf.metric_server) { - nd->metric_data = Hash_create(LISTENER_DATA_METRIC_DATA_SIZE_DEFAULT, + nd->metric_data = Hash_create(LISTENER_DATA_METRIC_DATA_SIZE_DEFAULT, (hash_key_f)hash_key_string, - (hash_cmp_f)strcmp, + (hash_cmp_f)strcmp, (hash_del_f)metric_data_destroy); nd->metric_data_size = LISTENER_DATA_METRIC_DATA_SIZE_DEFAULT; } @@ -200,7 +200,7 @@ metric_name_data_create(const char *metric_name, u_int32_t metric_origin) { struct cerebrod_metric_name_data *mnd; - assert(metric_name + assert(metric_name && (metric_origin >= CEREBROD_METRIC_LISTENER_ORIGIN_DEFAULT && metric_origin <= CEREBROD_METRIC_LISTENER_ORIGIN_MONITORED)); @@ -226,7 +226,7 @@ metric_name_data_destroy(void *data) struct cerebrod_metric_name_data *mnd; assert(data); - + mnd = (struct cerebrod_metric_name_data *)data; if (mnd->metric_origin & CEREBROD_METRIC_LISTENER_ORIGIN_MONITORED) @@ -234,7 +234,7 @@ metric_name_data_destroy(void *data) Free(mnd); } -void +void cerebrod_listener_data_initialize(void) { int numnodes = 0; @@ -242,7 +242,7 @@ cerebrod_listener_data_initialize(void) pthread_mutex_lock(&listener_data_init_lock); if (listener_data_init) goto out; - + if (!conf.listen) CEREBROD_EXIT(("listen server not setup")); @@ -270,7 +270,7 @@ cerebrod_listener_data_initialize(void) (hash_key_f)hash_key_string, (hash_cmp_f)strcmp, (hash_del_f)NULL); - + /* If the clusterlist module contains nodes, retrieve all of these * nodes and put them into the cerebrod_listener_data list. All updates * will involve updating data rather than involve insertion. @@ -286,7 +286,7 @@ cerebrod_listener_data_initialize(void) for (i = 0; i < numnodes; i++) { struct cerebrod_node_data *nd; - + nd = _cerebrod_node_data_create_and_init(nodes[i]); Hash_insert(listener_data, nd->nodename, nd); @@ -300,11 +300,11 @@ cerebrod_listener_data_initialize(void) if (conf.metric_server) { int i; - + metric_names_size = metric_name_defaults_count + LISTENER_DATA_METRIC_NAMES_SIZE_DEFAULT; - metric_names = Hash_create(metric_names_size, - (hash_key_f)hash_key_string, - (hash_cmp_f)strcmp, + metric_names = Hash_create(metric_names_size, + (hash_key_f)hash_key_string, + (hash_cmp_f)strcmp, (hash_del_f)metric_name_data_destroy); metric_names_count = 0; @@ -331,7 +331,7 @@ cerebrod_listener_data_initialize(void) Pthread_mutex_unlock(&listener_data_init_lock); } -/* +/* * _output_node_data_insert * * Output debugging info about a recently inserted node @@ -340,7 +340,7 @@ static void _output_node_data_insert(struct cerebrod_node_data *nd) { assert(nd); - + if (!(conf.debug && conf.listen_debug)) return; @@ -351,7 +351,7 @@ _output_node_data_insert(struct cerebrod_node_data *nd) Pthread_mutex_unlock(&debug_output_mutex); } -/* +/* * _output_node_data_update * * Output debugging info about a recently updated node @@ -360,7 +360,7 @@ static void _output_node_data_update(struct cerebrod_node_data *nd) { assert(nd); - + if (!(conf.debug && conf.listen_debug)) return; @@ -381,14 +381,14 @@ _metric_data_dump(void *data, const void *key, void *arg) { struct cerebrod_metric_data *md; char *nodename, *buf; - + assert(data && key && arg); - + md = (struct cerebrod_metric_data *)data; nodename = (char *)arg; - + fprintf(stderr, "* %s: metric name=%s type=%d len=%d ", - nodename, md->metric_name, md->metric_value_type, + nodename, md->metric_name, md->metric_value_type, md->metric_value_len); if (md->metric_value_type == CEREBRO_DATA_VALUE_TYPE_INT32) @@ -436,16 +436,16 @@ _node_data_dump(void *x, const void *key, void *arg) struct cerebrod_node_data *nd; assert(x); - + nd = (struct cerebrod_node_data *)x; Pthread_mutex_lock(&(nd->node_data_lock)); if (nd->discovered && conf.metric_server_debug) { int num; - + fprintf(stderr, "* %s: discovered=%d\n", nd->nodename, nd->discovered); - fprintf(stderr, "* %s: last_received_time=%u\n", + fprintf(stderr, "* %s: last_received_time=%u\n", nd->nodename, nd->last_received_time); if (nd->metric_data) @@ -455,7 +455,7 @@ _node_data_dump(void *x, const void *key, void *arg) fprintf(stderr, "* invalid dump count: num=%d data count=%d\n", num, nd->metric_data_count); else - fprintf(stderr, "* %s: metric_data_count=%d\n", + fprintf(stderr, "* %s: metric_data_count=%d\n", nd->nodename, nd->metric_data_count); } } @@ -485,7 +485,7 @@ _listener_data_dump(void) if (listener_data_numnodes > 0) { int num; - + num = Hash_for_each(listener_data, _node_data_dump, NULL); if (num != listener_data_numnodes) fprintf(stderr, "* invalid dump count: num=%d numnodes=%d\n", @@ -538,7 +538,7 @@ _metric_names_dump(void) Pthread_mutex_unlock(&metric_names_lock); } -/* +/* * _metric_data_update * * Update the data of a particular metric. The struct @@ -554,7 +554,7 @@ _metric_data_update(struct cerebrod_node_data *nd, #if CEREBRO_DEBUG int rv; #endif /* CEREBRO_DEBUG */ - + assert(nd && metric_name && mm); /* If metric server isn't running, metric_names is NULL */ @@ -569,7 +569,7 @@ _metric_data_update(struct cerebrod_node_data *nd, if (rv != EBUSY) CEREBROD_EXIT(("mutex not locked: rv=%d", rv)); #endif /* CEREBRO_DEBUG */ - + if (!(md = Hash_find(nd->metric_data, metric_name))) { /* Re-hash if our hash is getting too small */ @@ -590,7 +590,7 @@ _metric_data_update(struct cerebrod_node_data *nd, CEREBROD_DBG(("metric type modified: old=%d new=%d", md->metric_value_type, mm->metric_value_type)); } - + md->metric_value_received_time = received_time; md->metric_value_type = mm->metric_value_type; @@ -609,7 +609,7 @@ _metric_data_update(struct cerebrod_node_data *nd, memcpy(md->metric_value, mm->metric_value, mm->metric_value_len); } -void +void cerebrod_listener_data_update(char *nodename, struct cerebrod_message *msg, u_int32_t received_time) @@ -641,7 +641,7 @@ cerebrod_listener_data_update(char *nodename, listener_data_numnodes++; cerebrod_event_add_node_timeout_data(nd, received_time); - + /* Ok to call debug output function, since * listener_data_lock is locked. */ @@ -649,7 +649,7 @@ cerebrod_listener_data_update(char *nodename, } Pthread_mutex_unlock(&listener_data_lock); - /* + /* * The below loop used to be in _metric_data_update(). It was removed * b/c a race was discovered in debug mode. * @@ -673,21 +673,21 @@ cerebrod_listener_data_update(char *nodename, { char metric_name_buf[CEREBRO_MAX_METRIC_NAME_LEN+1]; struct cerebrod_message_metric *mm = msg->metrics[i]; - + /* Guarantee ending '\0' character */ memset(metric_name_buf, '\0', CEREBRO_MAX_METRIC_NAME_LEN+1); memcpy(metric_name_buf, mm->metric_name, CEREBRO_MAX_METRIC_NAME_LEN); - + if (!strlen(metric_name_buf)) { CEREBROD_DBG(("null message_data metric_name received")); continue; } - + if (!Hash_find(metric_names, metric_name_buf)) { struct cerebrod_metric_name_data *mnd; - + /* Re-hash if our hash is getting too small */ if ((metric_names_count + 1) > (metric_names_size*2)) cerebrod_rehash(&metric_names, @@ -695,10 +695,10 @@ cerebrod_listener_data_update(char *nodename, LISTENER_DATA_METRIC_NAMES_INCREMENT, metric_names_count, &metric_names_lock); - + mnd = metric_name_data_create(metric_name_buf, CEREBROD_METRIC_LISTENER_ORIGIN_MONITORED); - + Hash_insert(metric_names, mnd->metric_name, mnd); metric_names_count++; } diff --git a/src/cerebrod/cerebrod_listener_data.h b/src/cerebrod/cerebrod_listener_data.h index da230069..8c56e90d 100644 --- a/src/cerebrod/cerebrod_listener_data.h +++ b/src/cerebrod/cerebrod_listener_data.h @@ -42,14 +42,14 @@ #include "hash.h" -/* +/* * Flags to define if a metric is a default metric, or something * the listener received. */ #define CEREBROD_METRIC_LISTENER_ORIGIN_DEFAULT 0x00000001 #define CEREBROD_METRIC_LISTENER_ORIGIN_MONITORED 0x00000002 -/* +/* * struct cerebrod_metric_data * * Contains metric data for a node @@ -92,7 +92,7 @@ struct cerebrod_event_module pthread_mutex_t event_lock; }; -/* +/* * struct cerebrod_metric_name_data * * contains metric name and origin @@ -103,7 +103,7 @@ struct cerebrod_metric_name_data u_int32_t metric_origin; }; -/* +/* * struct cerebrod_event_node_timeout * * contains information needed for timeout calculations @@ -115,7 +115,7 @@ struct cerebrod_event_node_timeout unsigned int timeout_occurred; }; -/* +/* * struct cerebrod_timeout_data * * Store a timeout and it's string @@ -126,7 +126,7 @@ struct cerebrod_timeout_data char *timeout_str; }; -/* +/* * metric_data_create * * create metric name data @@ -135,14 +135,14 @@ struct cerebrod_timeout_data */ struct cerebrod_metric_data *metric_data_create(const char *metric_name); -/* +/* * metric_data_destroy * * destroy metric name data */ void metric_data_destroy(void *data); -/* +/* * metric_name_data_create * * create metric name data @@ -152,21 +152,21 @@ void metric_data_destroy(void *data); struct cerebrod_metric_name_data *metric_name_data_create(const char *metric_name, u_int32_t metric_origin); -/* +/* * metric_name_data_destroy * * destroy metric name data */ void metric_name_data_destroy(void *data); -/* +/* * cerebrod_listener_data_initialize * * Initialize listener_data structures */ void cerebrod_listener_data_initialize(void); -/* +/* * cerebrod_listener_data_update * * Update listener_data with information from a cerebrod message diff --git a/src/cerebrod/cerebrod_message.c b/src/cerebrod/cerebrod_message.c index b8e2e86c..0f13ebf3 100644 --- a/src/cerebrod/cerebrod_message.c +++ b/src/cerebrod/cerebrod_message.c @@ -84,9 +84,9 @@ cerebrod_message_dump(struct cerebrod_message *msg) exit(1); } #endif /* !WITH_CEREBROD_NO_THREADS */ - + fprintf(stderr, "**************************************\n"); - fprintf(stderr, "* Cerebrod Message:\n"); + fprintf(stderr, "* Cerebrod Message:\n"); fprintf(stderr, "* -------------------\n"); fprintf(stderr, "* version: %d\n", msg->version); fprintf(stderr, "* nodename: \"%s\"\n", msg->nodename); @@ -95,58 +95,58 @@ cerebrod_message_dump(struct cerebrod_message *msg) for (i = 0; i < msg->metrics_len; i++) { char *buf; - + fprintf(stderr, "* %s: metric type = %d, len = %d ", - msg->metrics[i]->metric_name, + msg->metrics[i]->metric_name, msg->metrics[i]->metric_value_type, msg->metrics[i]->metric_value_len); - + switch(msg->metrics[i]->metric_value_type) { case CEREBRO_DATA_VALUE_TYPE_NONE: break; case CEREBRO_DATA_VALUE_TYPE_INT32: - fprintf(stderr, "value = %d", + fprintf(stderr, "value = %d", *((int32_t *)msg->metrics[i]->metric_value)); break; case CEREBRO_DATA_VALUE_TYPE_U_INT32: - fprintf(stderr, "value = %u", + fprintf(stderr, "value = %u", *((u_int32_t *)msg->metrics[i]->metric_value)); break; case CEREBRO_DATA_VALUE_TYPE_FLOAT: - fprintf(stderr, "value = %f", + fprintf(stderr, "value = %f", *((float *)msg->metrics[i]->metric_value)); break; case CEREBRO_DATA_VALUE_TYPE_DOUBLE: - fprintf(stderr, "value = %f", + fprintf(stderr, "value = %f", *((double *)msg->metrics[i]->metric_value)); break; case CEREBRO_DATA_VALUE_TYPE_STRING: /* Watch for NUL termination */ buf = Malloc(msg->metrics[i]->metric_value_len + 1); memset(buf, '\0', msg->metrics[i]->metric_value_len + 1); - memcpy(buf, - msg->metrics[i]->metric_value, + memcpy(buf, + msg->metrics[i]->metric_value, msg->metrics[i]->metric_value_len); fprintf(stderr, "value = %s", buf); Free(buf); break; #if SIZEOF_LONG == 4 case CEREBRO_DATA_VALUE_TYPE_INT64: - fprintf(stderr, "value = %lld", + fprintf(stderr, "value = %lld", *((int64_t *)msg->metrics[i]->metric_value)); break; case CEREBRO_DATA_VALUE_TYPE_U_INT64: - fprintf(stderr, "value = %llu", + fprintf(stderr, "value = %llu", *((u_int64_t *)msg->metrics[i]->metric_value)); break; #else /* SIZEOF_LONG == 8 */ case CEREBRO_DATA_VALUE_TYPE_INT64: - fprintf(stderr, "value = %ld", + fprintf(stderr, "value = %ld", *((int64_t *)msg->metrics[i]->metric_value)); break; case CEREBRO_DATA_VALUE_TYPE_U_INT64: - fprintf(stderr, "value = %lu", + fprintf(stderr, "value = %lu", *((u_int64_t *)msg->metrics[i]->metric_value)); break; #endif /* SIZEOF_LONG == 8 */ diff --git a/src/cerebrod/cerebrod_message.h b/src/cerebrod/cerebrod_message.h index df2486f7..535beade 100644 --- a/src/cerebrod/cerebrod_message.h +++ b/src/cerebrod/cerebrod_message.h @@ -37,7 +37,7 @@ */ void cerebrod_message_destroy(struct cerebrod_message *msg); -/* +/* * cerebrod_message_dump * * dump contents of a message packet. Should be called with diff --git a/src/cerebrod/cerebrod_metric_controller.c b/src/cerebrod/cerebrod_metric_controller.c index 48772847..8c58ff66 100644 --- a/src/cerebrod/cerebrod_metric_controller.c +++ b/src/cerebrod/cerebrod_metric_controller.c @@ -74,14 +74,14 @@ extern struct cerebrod_config conf; extern pthread_mutex_t debug_output_mutex; -/* +/* * Speaker Data */ extern List metric_list; extern int metric_list_size; extern pthread_mutex_t metric_list_lock; -/* +/* * Listener Data */ extern hash_t listener_data; @@ -141,7 +141,7 @@ _metric_controller_setup_socket(int num) { struct sockaddr_un addr; int fd; - + if ((fd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) { CEREBROD_ERR(("socket: %s", strerror(errno))); @@ -160,25 +160,25 @@ _metric_controller_setup_socket(int num) if (errno != ENOENT) CEREBROD_EXIT(("unlink: %s", strerror(errno))); } - + memset(&addr, '\0', sizeof(struct sockaddr_un)); addr.sun_family = AF_LOCAL; - strncpy(addr.sun_path, - CEREBRO_METRIC_CONTROL_PATH, + strncpy(addr.sun_path, + CEREBRO_METRIC_CONTROL_PATH, sizeof(addr.sun_path)); - + if (bind(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) { CEREBROD_ERR(("bind: %s", strerror(errno))); goto cleanup; } - + if (listen(fd, CEREBROD_METRIC_CONTROLLER_BACKLOG) < 0) { CEREBROD_ERR(("listen: %s", strerror(errno))); goto cleanup; } - + return fd; cleanup: @@ -195,8 +195,8 @@ _metric_controller_setup_socket(int num) * Returns 0 if version is correct, -1 if not */ static int -_metric_control_request_check_version(const char *buf, - unsigned int buflen, +_metric_control_request_check_version(const char *buf, + unsigned int buflen, int32_t *version) { assert(buflen >= sizeof(int32_t) && version); @@ -227,9 +227,9 @@ _metric_control_request_header_unmarshall(struct cerebro_metric_control_request { int bufPtrlen, c = 0; char *bufPtr; - + assert(req && buf); - + bufPtr = req->metric_name; bufPtrlen = sizeof(req->metric_name); c += Unmarshall_int32(&(req->version), buf + c, buflen - c); @@ -238,10 +238,10 @@ _metric_control_request_header_unmarshall(struct cerebro_metric_control_request c += Unmarshall_buffer(bufPtr, bufPtrlen, buf + c, buflen - c); c += Unmarshall_u_int32(&(req->metric_value_type), buf + c, buflen - c); c += Unmarshall_u_int32(&(req->metric_value_len), buf + c, buflen - c); - + if (c != CEREBRO_METRIC_CONTROL_REQUEST_HEADER_LEN) return -1; - + return 0; } @@ -268,7 +268,7 @@ _metric_control_response_marshall(struct cerebro_metric_control_response *res, } -/* +/* * _metric_control_request_dump * * dump contents of a metric controller request @@ -282,7 +282,7 @@ _metric_control_request_dump(struct cerebro_metric_control_request *req) if (!(conf.debug && conf.metric_controller_debug)) return; - + Pthread_mutex_lock(&debug_output_mutex); fprintf(stderr, "**************************************\n"); fprintf(stderr, "* Metric Controller Request Received:\n"); @@ -300,7 +300,7 @@ _metric_control_request_dump(struct cerebro_metric_control_request *req) Pthread_mutex_unlock(&debug_output_mutex); } -/* +/* * _send_metric_control_response * * Send metric control responses with the appropriate err code @@ -325,7 +325,7 @@ _send_metric_control_response(int fd, int32_t version, u_int32_t err_code) buflen = CEREBRO_MAX_PACKET_LEN; if ((res_len = _metric_control_response_marshall(&res, buf, buflen)) < 0) return -1; - + if (fd_write_n(fd, buf, res_len) < 0) { CEREBROD_ERR(("fd_write_n: %s", strerror(errno))); @@ -335,7 +335,7 @@ _send_metric_control_response(int fd, int32_t version, u_int32_t err_code) return 0; } -/* +/* * _find_speaker_metric_info * * Find metric_info for 'metric_name' in the metric_list @@ -367,11 +367,11 @@ _find_speaker_metric_info(const char *metric_name) break; } List_iterator_destroy(itr); - + return metric_info; } -/* +/* * _find_metric_name * * Find the metric name in the metric list @@ -386,11 +386,11 @@ _find_metric_name(void *x, void *key) assert(x); metric_info = (struct cerebrod_speaker_metric_info *)x; - + return (!strcmp(metric_info->metric_name, (char *)key)) ? 1 : 0; } -/* +/* * _register_metric * * Register a new metric @@ -418,7 +418,7 @@ _register_metric(int fd, int32_t version, const char *metric_name) metric_info = Malloc(sizeof(struct cerebrod_speaker_metric_info)); metric_info->metric_name = Strdup(metric_name); metric_info->metric_origin = CEREBROD_METRIC_SPEAKER_ORIGIN_USERSPACE; - /* + /* * Setting next_call_time to UINT_MAX means the data will never * be sent. */ @@ -436,7 +436,7 @@ _register_metric(int fd, int32_t version, const char *metric_name) return rv; } -/* +/* * _unregister_metric * * Unregister a existing metric @@ -479,7 +479,7 @@ _unregister_metric(int fd, int32_t version, const char *metric_name) return rv; } -/* +/* * _receive_metric_value * * Receive the metric value from the fd @@ -487,8 +487,8 @@ _unregister_metric(int fd, int32_t version, const char *metric_name) * Returns 0 on success, -1 on error */ static int -_receive_metric_value(int fd, - int32_t version, +_receive_metric_value(int fd, + int32_t version, struct cerebro_metric_control_request *req) { char *vbuf = NULL, *mvalue = NULL; @@ -498,7 +498,7 @@ _receive_metric_value(int fd, assert(fd >= 0 && req && req->metric_value_len); vbuf = Malloc(req->metric_value_len); - + if ((vbytes_read = receive_data(fd, req->metric_value_len, vbuf, @@ -511,7 +511,7 @@ _receive_metric_value(int fd, CEREBRO_METRIC_CONTROL_PROTOCOL_ERR_PACKET_INVALID); goto cleanup; } - + if (vbytes_read != req->metric_value_len) { _send_metric_control_response(fd, @@ -519,7 +519,7 @@ _receive_metric_value(int fd, CEREBRO_METRIC_CONTROL_PROTOCOL_ERR_PACKET_INVALID); goto cleanup; } - + mvalue = Malloc(req->metric_value_len); mtype = req->metric_value_type; @@ -533,16 +533,16 @@ _receive_metric_value(int fd, vbytes_read, NULL)) < 0) goto cleanup; - + req->metric_value = mvalue; - + rv = 0; cleanup: Free(vbuf); return rv; } -/* +/* * _send_message_now * * Send the metric info now rather than waiting for the next message @@ -550,7 +550,7 @@ _receive_metric_value(int fd, * Returns 0 on success, -1 on error */ static int -_send_message_now(int fd, +_send_message_now(int fd, int32_t version, const char *metric_name, u_int32_t metric_value_type, @@ -562,8 +562,8 @@ _send_message_now(int fd, char nodename[CEREBRO_MAX_NODENAME_LEN+1]; int rv = -1; - assert(fd >= 0 - && metric_name + assert(fd >= 0 + && metric_name && conf.speak); if (!(msg = (struct cerebrod_message *)malloc(sizeof(struct cerebrod_message)))) @@ -574,7 +574,7 @@ _send_message_now(int fd, CEREBRO_METRIC_CONTROL_PROTOCOL_ERR_INTERNAL_ERROR); goto cleanup; } - + memset(nodename, '\0', CEREBRO_MAX_NODENAME_LEN+1); if (gethostname(nodename, CEREBRO_MAX_NODENAME_LEN) < 0) { @@ -584,7 +584,7 @@ _send_message_now(int fd, CEREBRO_METRIC_CONTROL_PROTOCOL_ERR_INTERNAL_ERROR); goto cleanup; } - + msg->version = CEREBROD_MESSAGE_PROTOCOL_VERSION; memcpy(msg->nodename, nodename, CEREBRO_MAX_NODENAME_LEN); @@ -611,7 +611,7 @@ _send_message_now(int fd, /* need not overflow */ strncpy(mm->metric_name, metric_name, CEREBRO_MAX_METRIC_NAME_LEN); - + mm->metric_value_type = metric_value_type; mm->metric_value_len = metric_value_len; mm->metric_value = metric_value; @@ -640,7 +640,7 @@ _send_message_now(int fd, return rv; } -/* +/* * _update_metric * * Update the metric type, len, and data for a metric @@ -648,8 +648,8 @@ _send_message_now(int fd, * Returns 0 on success, -1 on error */ static int -_update_metric(int fd, - int32_t version, +_update_metric(int fd, + int32_t version, const char *metric_name, struct cerebro_metric_control_request *req) { @@ -682,9 +682,9 @@ _update_metric(int fd, if (_receive_metric_value(fd, version, req) < 0) goto cleanup; } - + Pthread_mutex_lock(&metric_list_lock); - + if (!(metric_info = _find_speaker_metric_info(metric_name))) { _send_metric_control_response(fd, @@ -693,7 +693,7 @@ _update_metric(int fd, Pthread_mutex_unlock(&metric_list_lock); goto cleanup; } - + if (!(metric_info->metric_origin & CEREBROD_METRIC_SPEAKER_ORIGIN_USERSPACE)) { _send_metric_control_response(fd, @@ -701,7 +701,7 @@ _update_metric(int fd, CEREBRO_METRIC_CONTROL_PROTOCOL_ERR_METRIC_INVALID); Pthread_mutex_unlock(&metric_list_lock); goto cleanup; - } + } if (metric_info->metric_value) Free(metric_info->metric_value); @@ -724,7 +724,7 @@ _update_metric(int fd, if (req->flags & CEREBRO_METRIC_CONTROL_FLAGS_SEND_NOW) { - if (_send_message_now(fd, + if (_send_message_now(fd, version, metric_name, req->metric_value_type, @@ -740,7 +740,7 @@ _update_metric(int fd, return -1; } -/* +/* * _resend_metric * * Resend a metric by setting the next call time to 0 @@ -748,21 +748,21 @@ _update_metric(int fd, * Returns 0 on success, -1 on error */ static int -_resend_metric(int fd, - int32_t version, +_resend_metric(int fd, + int32_t version, const char *metric_name, struct cerebro_metric_control_request *req) { struct cerebrod_speaker_metric_info *metric_info; u_int32_t metric_value_type = 0, metric_value_len = 0; void *metric_value_copy = NULL; - + int rv = -1; assert(fd >= 0 && metric_name && req && conf.speak); Pthread_mutex_lock(&metric_list_lock); - + if (!(metric_info = _find_speaker_metric_info(metric_name))) { _send_metric_control_response(fd, @@ -771,7 +771,7 @@ _resend_metric(int fd, Pthread_mutex_unlock(&metric_list_lock); goto cleanup; } - + if (!(metric_info->metric_origin & CEREBROD_METRIC_SPEAKER_ORIGIN_MODULE || metric_info->metric_origin & CEREBROD_METRIC_SPEAKER_ORIGIN_USERSPACE)) { @@ -781,7 +781,7 @@ _resend_metric(int fd, Pthread_mutex_unlock(&metric_list_lock); goto cleanup; } - + /* If we have to send it now, don't bother waiting for a message * to come along later by setting next_call_time to UINT_MAX. */ @@ -793,7 +793,7 @@ _resend_metric(int fd, metric_value_type = metric_info->metric_value_type; metric_value_len = metric_info->metric_value_len; metric_value_copy = (void *)Malloc(metric_info->metric_value_len); - memcpy(metric_value_copy, + memcpy(metric_value_copy, metric_info->metric_value, metric_info->metric_value_len); } @@ -805,7 +805,7 @@ _resend_metric(int fd, if (req->flags & CEREBRO_METRIC_CONTROL_FLAGS_SEND_NOW) { - if (_send_message_now(fd, + if (_send_message_now(fd, version, metric_name, metric_value_type, @@ -821,7 +821,7 @@ _resend_metric(int fd, return rv; } -/* +/* * _flush_metric_data * * Flush metric data from the node @@ -838,7 +838,7 @@ _flush_metric_data(void *x, const void *key, void *arg) #endif /* CEREBRO_DEBUG */ assert(x && arg); - + nd = (struct cerebrod_node_data *)x; metric_name = (char *)arg; @@ -848,7 +848,7 @@ _flush_metric_data(void *x, const void *key, void *arg) if (rv != EBUSY) CEREBROD_EXIT(("mutex not locked: rv=%d", rv)); #endif /* CEREBRO_DEBUG */ - + Pthread_mutex_lock(&(nd->node_data_lock)); if (Hash_find(nd->metric_data, metric_name)) { @@ -867,10 +867,10 @@ _flush_metric_data(void *x, const void *key, void *arg) return 0; } -/* +/* * _flush_metric * - * Flush a metric + * Flush a metric * * Returns 0 on success, -1 on error */ @@ -878,8 +878,8 @@ static int _flush_metric(int fd, int32_t version, const char *metric_name) { struct cerebrod_metric_name_data *mnd; - - /* + + /* * Algorithm note, flushing means flushing the *current* known * contents. It does not stop any update attempts currently in * progress. @@ -929,7 +929,7 @@ _flush_metric(int fd, int32_t version, const char *metric_name) return -1; } -/* +/* * _speaker_metric_names_dump * * Dump the currently known/registered metric names @@ -979,9 +979,9 @@ _metric_controller_service_connection(void *arg) int32_t version; fd = *((int *)arg); - + memset(&req, '\0', sizeof(struct cerebro_metric_control_request)); - + if ((recv_len = receive_data(fd, CEREBRO_METRIC_CONTROL_REQUEST_HEADER_LEN, buf, @@ -989,7 +989,7 @@ _metric_controller_service_connection(void *arg) CEREBRO_METRIC_CONTROL_PROTOCOL_CLIENT_TIMEOUT_LEN, NULL)) < 0) goto cleanup; - + if (recv_len < sizeof(version)) goto cleanup; @@ -1000,7 +1000,7 @@ _metric_controller_service_connection(void *arg) CEREBRO_METRIC_CONTROL_PROTOCOL_ERR_VERSION_INVALID); goto cleanup; } - + if (recv_len < CEREBRO_METRIC_CONTROL_REQUEST_HEADER_LEN) { _send_metric_control_response(fd, @@ -1008,7 +1008,7 @@ _metric_controller_service_connection(void *arg) CEREBRO_METRIC_CONTROL_PROTOCOL_ERR_PACKET_INVALID); goto cleanup; } - + if (_metric_control_request_header_unmarshall(&req, buf, recv_len) < 0) { _send_metric_control_response(fd, @@ -1022,7 +1022,7 @@ _metric_controller_service_connection(void *arg) /* Guarantee ending '\0' character */ memset(metric_name_buf, '\0', CEREBRO_MAX_METRIC_NAME_LEN+1); memcpy(metric_name_buf, req.metric_name, CEREBRO_MAX_METRIC_NAME_LEN); - + if (!strlen(metric_name_buf)) { _send_metric_control_response(fd, @@ -1031,28 +1031,28 @@ _metric_controller_service_connection(void *arg) goto cleanup; } - if (req.command == CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_REGISTER + if (req.command == CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_REGISTER && conf.speak) { if (_register_metric(fd, version, metric_name_buf) < 0) goto cleanup; _speaker_metric_names_dump(); } - else if (req.command == CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_UNREGISTER + else if (req.command == CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_UNREGISTER && conf.speak) { if (_unregister_metric(fd, version, metric_name_buf) < 0) goto cleanup; _speaker_metric_names_dump(); } - else if (req.command == CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_UPDATE + else if (req.command == CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_UPDATE && conf.speak) { if (_update_metric(fd, version, metric_name_buf, &req) < 0) goto cleanup; _speaker_metric_names_dump(); } - else if (req.command == CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_RESEND + else if (req.command == CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_RESEND && conf.speak) { if (_resend_metric(fd, version, metric_name_buf, &req) < 0) @@ -1104,7 +1104,7 @@ cerebrod_metric_controller(void *arg) unsigned int client_addr_len; int fd, *arg; struct sockaddr_un client_addr; - + client_addr_len = sizeof(struct sockaddr_un); if ((fd = accept(controller_fd, (struct sockaddr *)&client_addr, @@ -1113,7 +1113,7 @@ cerebrod_metric_controller(void *arg) 0, _metric_controller_setup_socket, "metric_controller: accept"); - + if (fd < 0) continue; diff --git a/src/cerebrod/cerebrod_metric_server.c b/src/cerebrod/cerebrod_metric_server.c index f5dde059..46d3b85e 100644 --- a/src/cerebrod/cerebrod_metric_server.c +++ b/src/cerebrod/cerebrod_metric_server.c @@ -109,12 +109,12 @@ _metric_server_initialize(void) */ static int _metric_server_request_unmarshall(struct cerebro_metric_server_request *req, - const char *buf, + const char *buf, unsigned int buflen) { int bufPtrlen, c = 0; char *bufPtr; - + assert(req && buf); bufPtr = req->metric_name; @@ -129,8 +129,8 @@ _metric_server_request_unmarshall(struct cerebro_metric_server_request *req, return 0; } - -/* + +/* * _metric_server_request_dump * * dump contents of a metric server request @@ -144,7 +144,7 @@ _metric_server_request_dump(struct cerebro_metric_server_request *req) if (!(conf.debug && conf.metric_server_debug)) return; - + Pthread_mutex_lock(&debug_output_mutex); fprintf(stderr, "**************************************\n"); fprintf(stderr, "* Metric Server Request Received:\n"); @@ -160,7 +160,7 @@ _metric_server_request_dump(struct cerebro_metric_server_request *req) Pthread_mutex_unlock(&debug_output_mutex); } -/* +/* * _metric_server_request_check_version * * Check that the version is correct prior to unmarshalling @@ -168,12 +168,12 @@ _metric_server_request_dump(struct cerebro_metric_server_request *req) * Returns 0 if version is correct, -1 if not */ static int -_metric_server_request_check_version(const char *buf, - unsigned int buflen, +_metric_server_request_check_version(const char *buf, + unsigned int buflen, int32_t *version) { assert(buflen >= sizeof(int32_t) && version); - + if (!Unmarshall_int32(version, buf, buflen)) { CEREBROD_DBG(("version could not be unmarshalled")); @@ -195,7 +195,7 @@ _metric_server_request_check_version(const char *buf, */ static int _metric_server_response_marshall(struct cerebro_metric_server_response *res, - char *buf, + char *buf, unsigned int buflen) { int bufPtrlen, n, c = 0; @@ -213,7 +213,7 @@ _metric_server_response_marshall(struct cerebro_metric_server_response *res, c += Marshall_buffer(bufPtr, bufPtrlen, buf + c, buflen - c); c += Marshall_u_int32(res->metric_value_received_time, buf + c, buflen - c); - if ((n = marshall_data(res->metric_value_type, + if ((n = marshall_data(res->metric_value_type, res->metric_value_len, res->metric_value, buf + c, @@ -237,11 +237,11 @@ _metric_server_response_marshall(struct cerebro_metric_server_response *res, */ static int _metric_server_err_response_marshall(struct cerebro_metric_server_err_response *err_res, - char *buf, + char *buf, unsigned int buflen) { int len = 0; - + assert(err_res && buf && buflen >= CEREBRO_METRIC_SERVER_ERR_RESPONSE_LEN); memset(buf, '\0', buflen); @@ -291,7 +291,7 @@ _metric_server_response_send(int fd, struct cerebro_metric_server_response *res) * Return 0 on success, -1 on error */ static int -_metric_server_err_response_send(int fd, +_metric_server_err_response_send(int fd, struct cerebro_metric_server_err_response *res) { char buf[CEREBRO_MAX_PACKET_LEN]; @@ -302,7 +302,7 @@ _metric_server_err_response_send(int fd, buflen = CEREBRO_MAX_PACKET_LEN; if ((res_len = _metric_server_err_response_marshall(res, buf, buflen)) < 0) return -1; - + if (fd_write_n(fd, buf, res_len) < 0) { CEREBROD_ERR(("fd_write_n: %s", strerror(errno))); @@ -312,7 +312,7 @@ _metric_server_err_response_send(int fd, return 0; } -/* +/* * _metric_server_respond_with_error * * respond to the metric_server_request with an error @@ -327,7 +327,7 @@ _metric_server_respond_with_error(int fd, int32_t version, u_int32_t err_code) assert(fd >= 0 && err_code >= CEREBRO_METRIC_SERVER_PROTOCOL_ERR_VERSION_INVALID && err_code <= CEREBRO_METRIC_SERVER_PROTOCOL_ERR_INTERNAL_ERROR); - + memset(&res, '\0', CEREBRO_METRIC_SERVER_ERR_RESPONSE_LEN); res.version = version; res.err_code = err_code; @@ -338,7 +338,7 @@ _metric_server_respond_with_error(int fd, int32_t version, u_int32_t err_code) return 0; } -/* +/* * _metric_server_response_create * * Create a metric server response and add it to the list of responses @@ -358,20 +358,20 @@ _metric_server_response_create(char *name, struct cerebro_metric_server_response *res = NULL; assert(name && max_name_len && responses); - - if ((metric_value_type == CEREBRO_DATA_VALUE_TYPE_NONE + + if ((metric_value_type == CEREBRO_DATA_VALUE_TYPE_NONE && metric_value_len) - || (metric_value_type != CEREBRO_DATA_VALUE_TYPE_NONE + || (metric_value_type != CEREBRO_DATA_VALUE_TYPE_NONE && !metric_value_len)) { - CEREBROD_DBG(("bogus metric: type=%d len=%d", + CEREBROD_DBG(("bogus metric: type=%d len=%d", metric_value_type, metric_value_len)); return -1; } if ((metric_value_len && !metric_value) || (!metric_value_len && metric_value)) { - CEREBROD_DBG(("bogus metric: len=%d value=%p", + CEREBROD_DBG(("bogus metric: len=%d value=%p", metric_value_len, metric_value)); return -1; } @@ -398,7 +398,7 @@ _metric_server_response_create(char *name, res->metric_value_received_time = metric_value_received_time; res->metric_value_type = metric_value_type; res->metric_value_len = metric_value_len; - + if (metric_value_len) { if (!(res->metric_value = (void *)malloc(metric_value_len))) @@ -408,7 +408,7 @@ _metric_server_response_create(char *name, } memcpy(res->metric_value, metric_value, metric_value_len); } - + if (!list_append(responses, res)) { CEREBROD_ERR(("list_append: %s", strerror(errno))); @@ -427,7 +427,7 @@ _metric_server_response_create(char *name, return -1; } -/* +/* * _metric_names_callback * * Callback function to create metric name responses @@ -447,7 +447,7 @@ _metric_names_callback(void *data, const void *key, void *arg) mnd = (struct cerebrod_metric_name_data *)data; ed = (struct cerebrod_metric_name_evaluation_data *)arg; - + #if CEREBRO_DEBUG /* Should be called with lock already set */ rv = Pthread_mutex_trylock(&metric_names_lock); @@ -455,7 +455,7 @@ _metric_names_callback(void *data, const void *key, void *arg) CEREBROD_EXIT(("mutex not locked: rv=%d", rv)); #endif /* CEREBRO_DEBUG */ - if (_metric_server_response_create(mnd->metric_name, + if (_metric_server_response_create(mnd->metric_name, CEREBRO_MAX_METRIC_NAME_LEN, 0, CEREBRO_DATA_VALUE_TYPE_NONE, @@ -467,7 +467,7 @@ _metric_names_callback(void *data, const void *key, void *arg) return 0; } -/* +/* * _metric_data_evaluate * * Callback function for list_for_each, to determine if a node data @@ -489,7 +489,7 @@ _metric_data_evaluate(void *x, const void *key, void *arg) nd = (struct cerebrod_node_data *)x; ed = (struct cerebrod_metric_data_evaluation_data *)arg; - + #if CEREBRO_DEBUG /* Should be called with lock already set */ rv = Pthread_mutex_trylock(&listener_data_lock); @@ -542,7 +542,7 @@ _metric_data_evaluate(void *x, const void *key, void *arg) return -1; } } - else + else { if (ed->req->flags & CEREBRO_METRIC_DATA_FLAGS_UP_ONLY && !((ed->time_now - nd->last_received_time) < ed->req->timeout_len)) @@ -564,7 +564,7 @@ _metric_data_evaluate(void *x, const void *key, void *arg) } goto out; } - + if ((md = Hash_find(nd->metric_data, ed->metric_name))) { if (_metric_server_response_create(nd->nodename, @@ -602,9 +602,9 @@ _metric_data_evaluate(void *x, const void *key, void *arg) return 0; } -/* +/* * _send_end_response - * + * * Send end metric server response * * Returns 0 on success, -1 on error @@ -626,7 +626,7 @@ _send_end_response(int fd) return 0; } -/* +/* * _metric_server_response_send_callback * * Callback function to send all responses @@ -648,7 +648,7 @@ _metric_server_response_send_callback(void *x, void *arg) return 0; } -/* +/* * _responses_send_all * * Send responses @@ -662,8 +662,8 @@ _responses_send_all(int fd, List responses) if (List_count(responses)) { - if (list_for_each(responses, - _metric_server_response_send_callback, + if (list_for_each(responses, + _metric_server_response_send_callback, &fd) < 0) return -1; } @@ -671,7 +671,7 @@ _responses_send_all(int fd, List responses) return 0; } -/* +/* * _respond_with_metric_names * * Return 0 on success, -1 on error @@ -688,7 +688,7 @@ _respond_with_metric_names(int fd) memset(&ed, '\0', sizeof(struct cerebrod_metric_name_evaluation_data)); Pthread_mutex_lock(&metric_names_lock); - + if (!Hash_count(metric_names)) { Pthread_mutex_unlock(&metric_names_lock); @@ -699,8 +699,8 @@ _respond_with_metric_names(int fd) { CEREBROD_ERR(("list_create: %s", strerror(errno))); Pthread_mutex_unlock(&metric_names_lock); - _metric_server_respond_with_error(fd, - CEREBRO_METRIC_SERVER_PROTOCOL_VERSION, + _metric_server_respond_with_error(fd, + CEREBRO_METRIC_SERVER_PROTOCOL_VERSION, CEREBRO_METRIC_SERVER_PROTOCOL_ERR_INTERNAL_ERROR); goto cleanup; } @@ -739,7 +739,7 @@ _respond_with_metric_names(int fd) return rv; } -/* +/* * _metric_data_response_destroy * * destroy a metric server data response @@ -750,20 +750,20 @@ _metric_data_response_destroy(void *x) struct cerebro_metric_server_response *res; assert(x); - + res = (struct cerebro_metric_server_response *)x; free(res->metric_value); free(res); } -/* +/* * _respond_with_nodes * * Return 0 on success, -1 on error */ static int -_respond_with_nodes(int fd, - struct cerebro_metric_server_request *req, +_respond_with_nodes(int fd, + struct cerebro_metric_server_request *req, char *metric_name) { struct cerebrod_metric_data_evaluation_data ed; @@ -776,7 +776,7 @@ _respond_with_nodes(int fd, memset(&ed, '\0', sizeof(struct cerebrod_metric_data_evaluation_data)); Pthread_mutex_lock(&listener_data_lock); - + if (!Hash_count(listener_data)) { Pthread_mutex_unlock(&listener_data_lock); @@ -831,7 +831,7 @@ _respond_with_nodes(int fd, return rv; } -/* +/* * _metric_server_service_connection * * Thread to service a connection from a client to retrieve metric @@ -855,7 +855,7 @@ _metric_server_service_connection(void *arg) memset(&req, '\0', sizeof(struct cerebro_metric_server_request)); - if ((recv_len = receive_data(fd, + if ((recv_len = receive_data(fd, CEREBRO_METRIC_SERVER_REQUEST_PACKET_LEN, buf, CEREBRO_MAX_PACKET_LEN, @@ -868,7 +868,7 @@ _metric_server_service_connection(void *arg) if (_metric_server_request_check_version(buf, recv_len, &version) < 0) { - _metric_server_respond_with_error(fd, + _metric_server_respond_with_error(fd, version, CEREBRO_METRIC_SERVER_PROTOCOL_ERR_VERSION_INVALID); goto cleanup; @@ -876,7 +876,7 @@ _metric_server_service_connection(void *arg) if (recv_len != CEREBRO_METRIC_SERVER_REQUEST_PACKET_LEN) { - _metric_server_respond_with_error(fd, + _metric_server_respond_with_error(fd, version, CEREBRO_METRIC_SERVER_PROTOCOL_ERR_PACKET_INVALID); goto cleanup; @@ -884,11 +884,11 @@ _metric_server_service_connection(void *arg) if (_metric_server_request_unmarshall(&req, buf, recv_len) < 0) { - _metric_server_respond_with_error(fd, + _metric_server_respond_with_error(fd, version, CEREBRO_METRIC_SERVER_PROTOCOL_ERR_PACKET_INVALID); goto cleanup; - } + } _metric_server_request_dump(&req); @@ -914,10 +914,10 @@ _metric_server_service_connection(void *arg) goto cleanup; } Pthread_mutex_unlock(&metric_names_lock); - + if (!req.timeout_len) req.timeout_len = CEREBRO_METRIC_SERVER_TIMEOUT_LEN_DEFAULT; - + if (!strcmp(metric_name_buf, CEREBRO_METRIC_METRIC_NAMES)) { if (_respond_with_metric_names(fd) < 0) @@ -1008,28 +1008,28 @@ cerebrod_metric_server(void *arg) unsigned int client_addr_len; int fd, *arg; struct sockaddr_in client_addr; - + client_addr_len = sizeof(struct sockaddr_in); if ((fd = accept(server_fd, - (struct sockaddr *)&client_addr, + (struct sockaddr *)&client_addr, &client_addr_len)) < 0) - server_fd = cerebrod_reinit_socket(server_fd, + server_fd = cerebrod_reinit_socket(server_fd, 0, - _metric_server_setup_socket, + _metric_server_setup_socket, "metric_server: accept"); - + if (fd < 0) continue; - + /* Pass off connection to thread */ Pthread_attr_init(&attr); Pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); Pthread_attr_setstacksize(&attr, CEREBROD_THREAD_STACKSIZE); arg = Malloc(sizeof(int)); *arg = fd; - Pthread_create(&thread, - &attr, - _metric_server_service_connection, + Pthread_create(&thread, + &attr, + _metric_server_service_connection, (void *)arg); Pthread_attr_destroy(&attr); } diff --git a/src/cerebrod/cerebrod_metric_server.h b/src/cerebrod/cerebrod_metric_server.h index 1f971c8a..f490c555 100644 --- a/src/cerebrod/cerebrod_metric_server.h +++ b/src/cerebrod/cerebrod_metric_server.h @@ -31,7 +31,7 @@ #include "cerebro/cerebro_metric_server_protocol.h" #include "list.h" - + /* * struct cerebrod_metric_name_evaluation_data * diff --git a/src/cerebrod/cerebrod_monitor_update.c b/src/cerebrod/cerebrod_monitor_update.c index 05208cd8..9315268b 100644 --- a/src/cerebrod/cerebrod_monitor_update.c +++ b/src/cerebrod/cerebrod_monitor_update.c @@ -66,7 +66,7 @@ extern pthread_mutex_t debug_output_mutex; extern pthread_mutex_t listener_data_init_lock; -/* +/* * monitor_handle * * monitoring module handles @@ -81,7 +81,7 @@ monitor_modules_t monitor_handle = NULL; */ hash_t monitor_index = NULL; -/* +/* * _cerebrod_monitor_module_info_destroy * * Destroy a monitor_module_info struct. @@ -90,9 +90,9 @@ static void _cerebrod_monitor_module_info_destroy(void *data) { struct cerebrod_monitor_module_info *monitor_module; - + assert(data); - + monitor_module = (struct cerebrod_monitor_module_info *)data; Free(monitor_module->metric_names); Free(monitor_module); @@ -115,7 +115,7 @@ _cerebrod_monitor_module_list_destroy(void *data) Free(ml); } -/* +/* * Under almost any circumstance, don't return a -1 error, cerebro can * go on without loading monitor modules. The listener_data_init_lock * should already be set. @@ -160,16 +160,16 @@ cerebrod_monitor_modules_setup(void) } goto cleanup; } - + /* Each monitor module may wish to monitor multiple metrics. We'll * assume there will never be more than 2 metrics per monitor module, and * that will be enough to avoid all hash collisions. */ monitor_index_len = monitor_module_count * 2; - monitor_index = Hash_create(monitor_index_len, - (hash_key_f)hash_key_string, - (hash_cmp_f)strcmp, + monitor_index = Hash_create(monitor_index_len, + (hash_key_f)hash_key_string, + (hash_cmp_f)strcmp, (hash_del_f)_cerebrod_monitor_module_list_destroy); for (i = 0; i < monitor_module_count; i++) @@ -237,7 +237,7 @@ cerebrod_monitor_modules_setup(void) Pthread_mutex_init(&(monitor_module->monitor_lock), NULL); /* The monitoring module may support multiple metrics */ - + metricPtr = strtok_r(monitor_module->metric_names, ",", &metricbuf); while (metricPtr) { @@ -253,7 +253,7 @@ cerebrod_monitor_modules_setup(void) } else List_append(ml->monitor_list, monitor_module); - + metricPtr = strtok_r(NULL, ",", &metricbuf); } } @@ -277,7 +277,7 @@ cerebrod_monitor_modules_setup(void) return 0; } -/* +/* * cerebrod_monitor_modules_update * * Send metric data to the appropriate monitor modules, if necessary. @@ -294,7 +294,7 @@ cerebrod_monitor_modules_update(const char *nodename, #if CEREBRO_DEBUG int rv; #endif /* CEREBRO_DEBUG */ - + assert(nodename && nd && metric_name && mm); if (!monitor_index) diff --git a/src/cerebrod/cerebrod_monitor_update.h b/src/cerebrod/cerebrod_monitor_update.h index 41677f45..3fda595d 100644 --- a/src/cerebrod/cerebrod_monitor_update.h +++ b/src/cerebrod/cerebrod_monitor_update.h @@ -65,7 +65,7 @@ struct cerebrod_monitor_module_list pthread_mutex_t monitor_list_lock; }; -/* +/* * cerebrod_monitor_modules_setup * * Setup monitor modules. @@ -74,7 +74,7 @@ struct cerebrod_monitor_module_list */ int cerebrod_monitor_modules_setup(void); -/* +/* * cerebrod_monitor_update * * Accepts recently gathered metric data to be passed to monitor modules. diff --git a/src/cerebrod/cerebrod_speaker.c b/src/cerebrod/cerebrod_speaker.c index 5b230774..ee6fa4ae 100644 --- a/src/cerebrod/cerebrod_speaker.c +++ b/src/cerebrod/cerebrod_speaker.c @@ -70,7 +70,7 @@ extern pthread_mutex_t debug_output_mutex; */ static char cerebrod_nodename[CEREBRO_MAX_NODENAME_LEN+1]; -/* +/* * next_send_times * * Stores information on the next time to send information @@ -96,7 +96,7 @@ int speaker_fds[CEREBRO_CONFIG_SPEAK_MESSAGE_CONFIG_MAX]; unsigned int speaker_fds_len = 0; pthread_mutex_t speaker_fds_lock = PTHREAD_MUTEX_INITIALIZER; -/* +/* * _speaker_setup_socket * * Create and setup a speaker socket. Do not use wrappers in this @@ -105,7 +105,7 @@ pthread_mutex_t speaker_fds_lock = PTHREAD_MUTEX_INITIALIZER; * * In this socket setup function, 'num' is used as the message config * and file descriptor index. - * + * * Returns file descriptor on success, -1 on error */ static int @@ -127,14 +127,14 @@ _speaker_setup_socket(int num) struct ip_mreqn imr; memset(&imr, '\0', sizeof(struct ip_mreqn)); - memcpy(&imr.imr_multiaddr, + memcpy(&imr.imr_multiaddr, &conf.speak_message_config[num].ip_in_addr, sizeof(struct in_addr)); - memcpy(&imr.imr_address, + memcpy(&imr.imr_address, &conf.speak_message_config[num].network_interface_in_addr, sizeof(struct in_addr)); imr.imr_ifindex = conf.speak_message_config[num].network_interface_index; - + optlen = sizeof(struct ip_mreqn); if (setsockopt(fd, SOL_IP, IP_MULTICAST_IF, &imr, optlen) < 0) { @@ -174,7 +174,7 @@ _speaker_setup_socket(int num) memcpy(&addr.sin_addr, &conf.speak_message_config[num].network_interface_in_addr, sizeof(struct in_addr)); - if (bind(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) + if (bind(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) { CEREBROD_ERR(("bind: %s", strerror(errno))); goto cleanup; @@ -267,10 +267,10 @@ _speaker_initialize(void) cerebrod_speaker_data_initialize(); next_send_times = List_create((ListDelF)_Free); - /* + /* * We will always atleast send a heartbeat, so initialize * the next_send_times list with this information. - * + * * Initialize the next_send_time to send a heartbeat immediately. */ nst = (struct cerebrod_next_send_time *)Malloc(sizeof(struct cerebrod_next_send_time)); @@ -339,12 +339,12 @@ _cerebrod_message_create(struct cerebrod_next_send_time *nst, *message_len += CEREBROD_MESSAGE_HEADER_LEN; if (nst->next_send_type & CEREBROD_SPEAKER_NEXT_SEND_TYPE_HEARTBEAT) - cerebrod_speaker_data_get_heartbeat_metric_data(msg, - message_len, + cerebrod_speaker_data_get_heartbeat_metric_data(msg, + message_len, more_data_to_send); else if (nst->next_send_type & CEREBROD_SPEAKER_NEXT_SEND_TYPE_MODULE) - cerebrod_speaker_data_get_module_metric_data(msg, - message_len, + cerebrod_speaker_data_get_module_metric_data(msg, + message_len, nst->index, more_data_to_send); @@ -359,22 +359,22 @@ _cerebrod_message_create(struct cerebrod_next_send_time *nst, * Returns length written to buffer on success, -1 on error */ int -_message_marshall(struct cerebrod_message *msg, - char *buf, +_message_marshall(struct cerebrod_message *msg, + char *buf, unsigned int buflen) { char *bufPtr; int i, bufPtrlen, c = 0; - + assert(msg && buf && buflen >= CEREBROD_MESSAGE_HEADER_LEN); - + bufPtr = msg->nodename; bufPtrlen = sizeof(msg->nodename); memset(buf, '\0', buflen); c += Marshall_int32(msg->version, buf + c, buflen - c); c += Marshall_buffer(bufPtr, bufPtrlen, buf + c, buflen - c); c += Marshall_u_int32(msg->metrics_len, buf + c, buflen - c); - + if (!msg->metrics_len) return c; @@ -405,7 +405,7 @@ _message_marshall(struct cerebrod_message *msg, mtype = CEREBRO_DATA_VALUE_TYPE_NONE; } - if ((n = marshall_data(mtype, + if ((n = marshall_data(mtype, mlen, mvalue, buf + c, @@ -414,14 +414,14 @@ _message_marshall(struct cerebrod_message *msg, goto cleanup; c += n; } - + return c; cleanup: return -1; } -/* +/* * _cerebrod_message_dump * * Dump contents of message packet @@ -438,7 +438,7 @@ _cerebrod_message_dump(struct cerebrod_message *msg) Pthread_mutex_lock(&debug_output_mutex); #endif /* !WITH_CEREBROD_NO_THREADS */ fprintf(stderr, "**************************************\n"); - fprintf(stderr, "* Sending Message\n"); + fprintf(stderr, "* Sending Message\n"); fprintf(stderr, "* -----------------------\n"); cerebrod_message_dump(msg); fprintf(stderr, "**************************************\n"); @@ -456,42 +456,42 @@ _cerebrod_message_send(struct cerebrod_message* msg, unsigned int msglen) assert(msg); assert(msglen); /* atleast the header must be there */ - + buf = Malloc(msglen + 1); - + if ((buflen = _message_marshall(msg, buf, msglen)) < 0) { Free(buf); return; } - + Pthread_mutex_lock(&speaker_fds_lock); for (i = 0; i < speaker_fds_len; i++) { struct sockaddr *addr; struct sockaddr_in msgaddr; unsigned int addrlen; - + memset(&msgaddr, '\0', sizeof(struct sockaddr_in)); msgaddr.sin_family = AF_INET; msgaddr.sin_port = htons(conf.speak_message_config[i].destination_port); - memcpy(&msgaddr.sin_addr, - &conf.speak_message_config[i].ip_in_addr, + memcpy(&msgaddr.sin_addr, + &conf.speak_message_config[i].ip_in_addr, sizeof(struct in_addr)); - + addr = (struct sockaddr *)&msgaddr; addrlen = sizeof(struct sockaddr_in); if ((rv = sendto(speaker_fds[i], - buf, + buf, buflen, 0, - addr, + addr, addrlen)) != msglen) { if (rv < 0) - speaker_fds[i] = cerebrod_reinit_socket(speaker_fds[i], + speaker_fds[i] = cerebrod_reinit_socket(speaker_fds[i], i, - _speaker_setup_socket, + _speaker_setup_socket, "speaker: sendto"); else CEREBROD_ERR(("sendto: invalid bytes sent")); @@ -676,7 +676,7 @@ cerebrod_send_message(struct cerebrod_message *msg) } _cerebrod_message_dump(msg); - + _cerebrod_message_send(msg, msglen); cleanup: diff --git a/src/cerebrod/cerebrod_speaker.h b/src/cerebrod/cerebrod_speaker.h index fe4fa4d1..c27dd535 100644 --- a/src/cerebrod/cerebrod_speaker.h +++ b/src/cerebrod/cerebrod_speaker.h @@ -30,14 +30,14 @@ #include "cerebro/cerebrod_message_protocol.h" -/* +/* * Flags to define if a metric should be sent with cerebrod heartbeat * or by themselves. */ #define CEREBROD_SPEAKER_NEXT_SEND_TYPE_HEARTBEAT 0x1 #define CEREBROD_SPEAKER_NEXT_SEND_TYPE_MODULE 0x2 -/* +/* * struct cerebrod_next_send_time * * Store information on when to next send information @@ -52,18 +52,18 @@ struct cerebrod_next_send_time int index; }; -/* +/* * cerebrod_speaker * * Runs the cerebrod speaker thread * * Passed no argument - * + * * Executed in detached state, no return value. */ void *cerebrod_speaker(void *); -/* +/* * cerebrod_send_message * * Sends a message. Called by metric modules when necessary. diff --git a/src/cerebrod/cerebrod_speaker_data.c b/src/cerebrod/cerebrod_speaker_data.c index 75323584..4536b887 100644 --- a/src/cerebrod/cerebrod_speaker_data.c +++ b/src/cerebrod/cerebrod_speaker_data.c @@ -98,7 +98,7 @@ int metric_list_size = 0; pthread_mutex_t metric_list_lock = PTHREAD_MUTEX_INITIALIZER; #endif /* !WITH_CEREBROD_NO_THREADS */ -/* +/* * _setup_metric_modules * * Setup metric modules. Under almost any circumstance, don't return a @@ -132,13 +132,13 @@ _setup_metric_modules(void) CEREBROD_DBG(("metric_modules_load")); goto cleanup; } - + if ((metric_handle_count = metric_modules_count(metric_handle)) < 0) { CEREBROD_DBG(("metric_module_count failed")); goto cleanup; } - + if (!metric_handle_count) { if (conf.debug && conf.speak_debug) @@ -165,7 +165,7 @@ _setup_metric_modules(void) char *module_name, *metric_name; int metric_period; u_int32_t metric_flags; - + module_name = metric_module_name(metric_handle, i); if (conf.metric_module_exclude_len) @@ -181,7 +181,7 @@ _setup_metric_modules(void) break; } } - + if (found_exclude) { if (conf.debug && conf.speak_debug) @@ -200,7 +200,7 @@ _setup_metric_modules(void) continue; } } - + if (conf.debug && conf.speak_debug) { #if !WITH_CEREBROD_NO_THREADS @@ -255,7 +255,7 @@ _setup_metric_modules(void) metric_module_cleanup(metric_handle, i); continue; } - + metric_info = Malloc(sizeof(struct cerebrod_speaker_metric_info)); /* No need to Strdup() the name in this case */ metric_info->metric_name = metric_name; @@ -265,14 +265,14 @@ _setup_metric_modules(void) metric_info->metric_flags = metric_flags; metric_info->index = i; - /* + /* * If metric period is < 0, it presumably never will be sent * (metric is likely handled by a metric_thread), so set * next_call_time to UINT_MAX. * * If this is a metric that will be piggy-backed on heartbeats, * then initialize next_call_time to 0, so the data is sent on - * the first heartbeat + * the first heartbeat * * If this is a metric that will not be piggy-backed on * heartbeats, set the next_call_time to UINT_MAX. Let the @@ -283,16 +283,16 @@ _setup_metric_modules(void) metric_info->next_call_time = UINT_MAX; else metric_info->next_call_time = 0; - + List_append(metric_list, metric_info); metric_list_size++; #if !WITH_CEREBROD_NO_THREADS if ((threadPtr = metric_module_get_metric_thread(metric_handle, i))) - { + { pthread_t thread; pthread_attr_t attr; - + Pthread_attr_init(&attr); Pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); Pthread_attr_setstacksize(&attr, CEREBROD_THREAD_STACKSIZE); @@ -301,7 +301,7 @@ _setup_metric_modules(void) } #endif /* !WITH_CEREBROD_NO_THREADS */ } - + if (!metric_list_size) goto cleanup; @@ -320,7 +320,7 @@ _setup_metric_modules(void) return 0; } -/* +/* * _destroy_speaker_metric_info * * Deallocate speaker_metric_info structure @@ -329,7 +329,7 @@ static void _destroy_speaker_metric_info(void *x) { struct cerebrod_speaker_metric_info *metric_info; - + assert(x); metric_info = (struct cerebrod_speaker_metric_info *)x; @@ -340,7 +340,7 @@ _destroy_speaker_metric_info(void *x) if (metric_info->metric_value) Free(metric_info->metric_value); } - + Free(metric_info); } @@ -354,7 +354,7 @@ cerebrod_speaker_data_initialize(void) goto out; #if !WITH_CEREBROD_NO_THREADS - /* + /* * Must lock in this initialization routine, b/c the update thread * in a metric module may call the update state function. */ @@ -398,11 +398,11 @@ _next_call_time_cmp(void *x, void *y) return 0; else if (a->next_call_time < b->next_call_time) return -1; - else + else return 1; } -void +void cerebrod_speaker_data_metric_list_sort(void) { #if CEREBRO_DEBUG @@ -425,7 +425,7 @@ cerebrod_speaker_data_metric_list_sort(void) List_sort(metric_list, _next_call_time_cmp); } -/* +/* * _get_module_metric_value * * Get the metric value data from a module @@ -453,7 +453,7 @@ _get_module_metric_value(unsigned int index) /* need not overflow */ strncpy(mm->metric_name, metric_name, CEREBRO_MAX_METRIC_NAME_LEN); - + if (metric_module_get_metric_value(metric_handle, index, &mtype, @@ -464,13 +464,13 @@ _get_module_metric_value(unsigned int index) goto cleanup; } - if (mtype == CEREBRO_DATA_VALUE_TYPE_STRING + if (mtype == CEREBRO_DATA_VALUE_TYPE_STRING && mlen > CEREBRO_MAX_DATA_STRING_LEN) { CEREBROD_DBG(("truncate metric string: %d", mlen)); mlen = CEREBRO_MAX_DATA_STRING_LEN; } - + if (mtype == CEREBRO_DATA_VALUE_TYPE_STRING && !mlen) { CEREBROD_DBG(("adjusting metric type to none")); @@ -490,11 +490,11 @@ _get_module_metric_value(unsigned int index) else mm->metric_value = NULL; metric_module_destroy_metric_value(metric_handle, index, mvalue); - + return mm; cleanup: - + if (mvalue) metric_module_destroy_metric_value(metric_handle, index, mvalue); @@ -504,11 +504,11 @@ _get_module_metric_value(unsigned int index) Free(mm->metric_value); Free(mm); } - + return NULL; } -/* +/* * _get_userspace_metric_value * * Get the metric value data supplied by a userspace program @@ -539,8 +539,8 @@ _get_userspace_metric_value(struct cerebrod_speaker_metric_info *metric_info) memset(mm, '\0', sizeof(struct cerebrod_message_metric)); /* need not overflow */ - strncpy(mm->metric_name, - metric_info->metric_name, + strncpy(mm->metric_name, + metric_info->metric_name, CEREBRO_MAX_METRIC_NAME_LEN); mm->metric_value_type = metric_info->metric_value_type; @@ -548,8 +548,8 @@ _get_userspace_metric_value(struct cerebrod_speaker_metric_info *metric_info) if (mm->metric_value_len) { mm->metric_value = Malloc(metric_info->metric_value_len); - memcpy(mm->metric_value, - metric_info->metric_value, + memcpy(mm->metric_value, + metric_info->metric_value, metric_info->metric_value_len); } else @@ -567,7 +567,7 @@ _get_userspace_metric_value(struct cerebrod_speaker_metric_info *metric_info) return NULL; } -void +void cerebrod_speaker_data_get_heartbeat_metric_data(struct cerebrod_message *msg, unsigned int *message_len, int *more_data_to_send) @@ -600,10 +600,10 @@ cerebrod_speaker_data_get_heartbeat_metric_data(struct cerebrod_message *msg, memset(msg->metrics, '\0', sizeof(struct cerebrod_message_metric *)*(metric_list_size + 1)); Gettimeofday(&tv, NULL); - + itr = List_iterator_create(metric_list); while ((metric_info = list_next(itr))) - { + { struct cerebrod_message_metric *mm = NULL; if (tv.tv_sec <= metric_info->next_call_time) @@ -625,7 +625,7 @@ cerebrod_speaker_data_get_heartbeat_metric_data(struct cerebrod_message *msg, { *more_data_to_send = 1; goto sort_out; - } + } else { *message_len += CEREBROD_MESSAGE_METRIC_HEADER_LEN; @@ -640,7 +640,7 @@ cerebrod_speaker_data_get_heartbeat_metric_data(struct cerebrod_message *msg, if (metric_info->metric_period < 0) metric_info->next_call_time = UINT_MAX; - /* + /* * Metric period stays at 0 for metrics that need to be * propagated every time */ @@ -650,7 +650,7 @@ cerebrod_speaker_data_get_heartbeat_metric_data(struct cerebrod_message *msg, if (metric_info->metric_origin & CEREBROD_METRIC_SPEAKER_ORIGIN_USERSPACE) metric_info->next_call_time = UINT_MAX; - } + } sort_out: List_iterator_destroy(itr); cerebrod_speaker_data_metric_list_sort(); @@ -661,7 +661,7 @@ cerebrod_speaker_data_get_heartbeat_metric_data(struct cerebrod_message *msg, return; } -void +void cerebrod_speaker_data_get_module_metric_data(struct cerebrod_message *msg, unsigned int *message_len, unsigned int index, @@ -670,7 +670,7 @@ cerebrod_speaker_data_get_module_metric_data(struct cerebrod_message *msg, struct cerebrod_message_metric *mm = NULL; assert(msg && message_len && more_data_to_send); - + assert(metric_handle && metric_list && metric_list_size); if (!speaker_data_init) @@ -696,7 +696,7 @@ cerebrod_speaker_data_get_module_metric_data(struct cerebrod_message *msg, msg->metrics[msg->metrics_len] = mm; msg->metrics_len++; } - + #if !WITH_CEREBROD_NO_THREADS Pthread_mutex_unlock(&metric_list_lock); #endif /* !WITH_CEREBROD_NO_THREADS */ diff --git a/src/cerebrod/cerebrod_speaker_data.h b/src/cerebrod/cerebrod_speaker_data.h index df93ccd5..5813ead9 100644 --- a/src/cerebrod/cerebrod_speaker_data.h +++ b/src/cerebrod/cerebrod_speaker_data.h @@ -29,7 +29,7 @@ #define _CEREBROD_SPEAKER_DATA_H #include - + #include "cerebro/cerebro_metric_module.h" #include "cerebro/cerebrod_message_protocol.h" @@ -73,7 +73,7 @@ struct cerebrod_speaker_metric_info */ void cerebrod_speaker_data_initialize(void); -/* +/* * cerebrod_speaker_data_metric_list_sort * * Sort the metric list @@ -85,7 +85,7 @@ void cerebrod_speaker_data_metric_list_sort(void); * * Store metric data into the heartbeat */ -void cerebrod_speaker_data_get_heartbeat_metric_data(struct cerebrod_message *msg, +void cerebrod_speaker_data_get_heartbeat_metric_data(struct cerebrod_message *msg, unsigned int *message_len, int *more_data_to_send); @@ -94,7 +94,7 @@ void cerebrod_speaker_data_get_heartbeat_metric_data(struct cerebrod_message *ms * * Store metric data into the message */ -void cerebrod_speaker_data_get_module_metric_data(struct cerebrod_message *msg, +void cerebrod_speaker_data_get_module_metric_data(struct cerebrod_message *msg, unsigned int *message_len, unsigned int index, int *more_data_to_send); diff --git a/src/cerebrod/cerebrod_util.c b/src/cerebrod/cerebrod_util.c index f5785e36..5cdd54b9 100644 --- a/src/cerebrod/cerebrod_util.c +++ b/src/cerebrod/cerebrod_util.c @@ -50,7 +50,7 @@ extern struct cerebrod_config conf; #if !WITH_CEREBROD_SPEAKER_ONLY -/* +/* * _hash_removeall * * callback for hash_for_each that inserts entries into the new hash. @@ -69,7 +69,7 @@ _hash_reinsert(void *data, const void *key, void *arg) return 1; } -/* +/* * _hash_removeall * * callback for hash_remove_if that returns 1, signifying the removal @@ -103,12 +103,12 @@ cerebrod_rehash(hash_t *old_hash, #endif /* CEREBRO_DEBUG */ *hash_size += hash_size_increment; - + new_hash = Hash_create(*hash_size, (hash_key_f)hash_key_string, (hash_cmp_f)strcmp, (hash_del_f)_Free); - + if (Hash_for_each(*old_hash, _hash_reinsert, &new_hash) != hash_num) CEREBROD_EXIT(("invalid reinsert: hash_num=%d", hash_num)); @@ -123,18 +123,18 @@ cerebrod_rehash(hash_t *old_hash, #endif /* !WITH_CEREBROD_SPEAKER_ONLY */ int -cerebrod_reinit_socket(int old_fd, +cerebrod_reinit_socket(int old_fd, int num, - Cerebrod_socket_setup socket_setup, + Cerebrod_socket_setup socket_setup, char *msg) { int fd = old_fd; assert(socket_setup && msg); - if (errno == EINVAL - || errno == EBADF - || errno == ENODEV + if (errno == EINVAL + || errno == EBADF + || errno == ENODEV || errno == ENETDOWN || errno == ENETUNREACH || old_fd < 0) diff --git a/src/cerebrod/cerebrod_util.h b/src/cerebrod/cerebrod_util.h index ebde4f9b..8e5465fc 100644 --- a/src/cerebrod/cerebrod_util.h +++ b/src/cerebrod/cerebrod_util.h @@ -38,7 +38,7 @@ #include "hash.h" -/* +/* * cerebrod_rehash * * rehash the contents of old_hash into a new hash. Caller is @@ -52,10 +52,10 @@ * * Returns new_hash in 'old_hash', and new hash size in 'hash_size'. */ -void cerebrod_rehash(hash_t *old_hash, - int *hash_size, +void cerebrod_rehash(hash_t *old_hash, + int *hash_size, int hash_size_increment, - int hash_num, + int hash_num, pthread_mutex_t *hash_mutex); /* @@ -65,7 +65,7 @@ void cerebrod_rehash(hash_t *old_hash, */ typedef int (*Cerebrod_socket_setup)(int num); -/* +/* * cerebrod_reinit_socket * * This function helps various looping network servers or clients @@ -74,7 +74,7 @@ typedef int (*Cerebrod_socket_setup)(int num); * For networking errnos EINVAL, EBADF, ENODEV, we assume the network * device has been temporarily brought down then back up. For * example, this can occur if the administrator runs - * '/etc/init.d/network restart'. + * '/etc/init.d/network restart'. * * If old_fd < 0, the network device just isn't back up yet from * the previous time we got an errno EINVAL, EBADF, or @@ -82,11 +82,11 @@ typedef int (*Cerebrod_socket_setup)(int num); * * The num is passed to the socket_setup function. For some socket * setup functions, they num will be a dummy value that is never used. - * + * * Returns new (or possibly old) fd on success, -1 on error */ int -cerebrod_reinit_socket(int old_fd, +cerebrod_reinit_socket(int old_fd, int num, Cerebrod_socket_setup socket_setup, char *msg); diff --git a/src/libs/cerebro/cerebro.c b/src/libs/cerebro/cerebro.c index 5546ecf9..a28ec3a2 100644 --- a/src/libs/cerebro/cerebro.c +++ b/src/libs/cerebro/cerebro.c @@ -81,7 +81,7 @@ cerebro_handle_create(void) if (!(handle = (cerebro_t)malloc(sizeof(struct cerebro)))) goto cleanup; - + memset(handle, '\0', sizeof(struct cerebro)); handle->magic = CEREBRO_MAGIC_NUMBER; handle->errnum = CEREBRO_ERR_SUCCESS; @@ -91,7 +91,7 @@ cerebro_handle_create(void) handle->flags = 0; handle->loaded_state = 0; memset(&(handle->config_data), '\0', sizeof(struct cerebro_config)); - + if (!(handle->namelists = list_create((ListDelF)cerebro_namelist_destroy))) goto cleanup; @@ -142,7 +142,7 @@ cerebro_handle_destroy(cerebro_t handle) handle->nodelists = NULL; list_destroy(handle->event_fds); handle->event_fds = NULL; - + handle->errnum = CEREBRO_ERR_SUCCESS; handle->magic = ~CEREBRO_MAGIC_NUMBER; free(handle); @@ -160,7 +160,7 @@ cerebro_errnum(cerebro_t handle) return handle->errnum; } -int +int cerebro_namelist_errnum(cerebro_namelist_t namelist) { if (!namelist) @@ -171,7 +171,7 @@ cerebro_namelist_errnum(cerebro_namelist_t namelist) return namelist->errnum; } -int +int cerebro_namelist_iterator_errnum(cerebro_namelist_iterator_t namelistItr) { if (!namelistItr) @@ -182,7 +182,7 @@ cerebro_namelist_iterator_errnum(cerebro_namelist_iterator_t namelistItr) return namelistItr->errnum; } -int +int cerebro_nodelist_errnum(cerebro_nodelist_t nodelist) { if (!nodelist) @@ -193,7 +193,7 @@ cerebro_nodelist_errnum(cerebro_nodelist_t nodelist) return nodelist->errnum; } -int +int cerebro_nodelist_iterator_errnum(cerebro_nodelist_iterator_t nodelistItr) { if (!nodelistItr) @@ -222,7 +222,7 @@ cerebro_get_hostname(cerebro_t handle) return handle->hostname; } -int +int cerebro_set_hostname(cerebro_t handle, const char *hostname) { if (_cerebro_handle_check(handle) < 0) @@ -242,7 +242,7 @@ cerebro_set_hostname(cerebro_t handle, const char *hostname) return 0; } -int +int cerebro_get_port(cerebro_t handle) { if (_cerebro_handle_check(handle) < 0) @@ -251,7 +251,7 @@ cerebro_get_port(cerebro_t handle) return handle->port; } -int +int cerebro_set_port(cerebro_t handle, unsigned int port) { if (_cerebro_handle_check(handle) < 0) @@ -261,7 +261,7 @@ cerebro_set_port(cerebro_t handle, unsigned int port) return 0; } -int +int cerebro_get_timeout_len(cerebro_t handle) { if (_cerebro_handle_check(handle) < 0) @@ -270,7 +270,7 @@ cerebro_get_timeout_len(cerebro_t handle) return handle->timeout_len; } -int +int cerebro_set_timeout_len(cerebro_t handle, unsigned int timeout_len) { if (_cerebro_handle_check(handle) < 0) @@ -280,7 +280,7 @@ cerebro_set_timeout_len(cerebro_t handle, unsigned int timeout_len) return 0; } -int +int cerebro_get_flags(cerebro_t handle) { if (_cerebro_handle_check(handle) < 0) @@ -289,7 +289,7 @@ cerebro_get_flags(cerebro_t handle) return handle->flags; } -int +int cerebro_set_flags(cerebro_t handle, unsigned int flags) { if (_cerebro_handle_check(handle) < 0) diff --git a/src/libs/cerebro/cerebro_api.h b/src/libs/cerebro/cerebro_api.h index da183086..32be9b30 100644 --- a/src/libs/cerebro/cerebro_api.h +++ b/src/libs/cerebro/cerebro_api.h @@ -24,7 +24,7 @@ * You should have received a copy of the GNU General Public License along * with Cerebro. If not, see . \*****************************************************************************/ - + #ifndef _CEREBRO_API_H #define _CEREBRO_API_H @@ -36,7 +36,7 @@ #include "list.h" -/* +/* * CEREBRO_MAGIC_NUMBER * * Magic number for cerebro handle @@ -47,12 +47,12 @@ #define CEREBRO_NODELIST_MAGIC_NUMBER 0xF00F4567 #define CEREBRO_NODELIST_ITERATOR_MAGIC_NUMBER 0xF00F5678 -/* +/* * Cerebro loaded state flags */ #define CEREBRO_CONFIG_LOADED 0x00000001 -/* +/* * struct cerebro * * Used globally as cerebro handle @@ -71,7 +71,7 @@ struct cerebro { List event_fds; }; -/* +/* * struct cerebro_namelist * * Used for nodelist interface @@ -84,7 +84,7 @@ struct cerebro_namelist { struct cerebro *handle; }; -/* +/* * struct cerebro_namelist_iterator * * Used for nodelist iterator interface @@ -97,7 +97,7 @@ struct cerebro_namelist_iterator { struct cerebro_namelist *namelist; }; -/* +/* * struct cerebro_nodelist_data * * Stores a nodename and a value @@ -110,7 +110,7 @@ struct cerebro_nodelist_data { void *metric_value; }; -/* +/* * struct cerebro_nodelist * * Used for nodelist interface @@ -124,7 +124,7 @@ struct cerebro_nodelist { struct cerebro *handle; }; -/* +/* * struct cerebro_nodelist_iterator * * Used for nodelist iterator interface diff --git a/src/libs/cerebro/cerebro_config_util.c b/src/libs/cerebro/cerebro_config_util.c index 04b9c6e3..eb5189cf 100644 --- a/src/libs/cerebro/cerebro_config_util.c +++ b/src/libs/cerebro/cerebro_config_util.c @@ -44,7 +44,7 @@ #include "config_util.h" #include "debug.h" -int +int _cerebro_load_config(cerebro_t handle) { unsigned int errnum; @@ -54,7 +54,7 @@ _cerebro_load_config(cerebro_t handle) if (handle->loaded_state & CEREBRO_CONFIG_LOADED) return 0; - + memset(&(handle->config_data), '\0', sizeof(struct cerebro_config)); if (load_config(&(handle->config_data), &errnum) < 0) { @@ -62,19 +62,19 @@ _cerebro_load_config(cerebro_t handle) handle->errnum = errnum; return -1; } - + handle->loaded_state |= CEREBRO_CONFIG_LOADED; return 0; } -int +int _cerebro_unload_config(cerebro_t handle) { if (_cerebro_handle_check(handle) < 0) return -1; memset(&(handle->config_data), '\0', sizeof(struct cerebro_config)); - + handle->loaded_state &= ~CEREBRO_CONFIG_LOADED; return 0; } diff --git a/src/libs/cerebro/cerebro_config_util.h b/src/libs/cerebro/cerebro_config_util.h index a35e050e..ad1f2f48 100644 --- a/src/libs/cerebro/cerebro_config_util.h +++ b/src/libs/cerebro/cerebro_config_util.h @@ -30,7 +30,7 @@ #include "cerebro.h" -/* +/* * _cerebro_load_config * * Read and load config file data @@ -39,7 +39,7 @@ */ int _cerebro_load_config(cerebro_t handle); -/* +/* * _cerebro_unload_config * * Unload config file info diff --git a/src/libs/cerebro/cerebro_event.c b/src/libs/cerebro/cerebro_event.c index 63c9ba45..116e9a3c 100644 --- a/src/libs/cerebro/cerebro_event.c +++ b/src/libs/cerebro/cerebro_event.c @@ -66,16 +66,16 @@ _event_server_request_marshall(cerebro_t handle, { int n, bufPtrlen, c = 0; char *bufPtr; - + if (!buf || buflen < CEREBRO_EVENT_SERVER_REQUEST_PACKET_LEN) { CEREBRO_DBG(("invalid parameters")); handle->errnum = CEREBRO_ERR_INTERNAL; return -1; } - + memset(buf, '\0', buflen); - + if ((n = marshall_int32(req->version, buf + c, buflen - c)) <= 0) { CEREBRO_DBG(("marshall_int32")); @@ -83,7 +83,7 @@ _event_server_request_marshall(cerebro_t handle, return -1; } c += n; - + bufPtr = req->event_name; bufPtrlen = sizeof(req->event_name); if ((n = marshall_buffer(bufPtr, bufPtrlen, buf + c, buflen - c)) <= 0) @@ -93,7 +93,7 @@ _event_server_request_marshall(cerebro_t handle, return -1; } c += n; - + if ((n = marshall_u_int32(req->flags, buf + c, buflen - c)) <= 0) { CEREBRO_DBG(("marshall_u_int32")); @@ -138,7 +138,7 @@ _event_server_request_send(cerebro_t handle, buf, CEREBRO_MAX_PACKET_LEN)) < 0) return -1; - + if (fd_write_n(fd, buf, req_len) < 0) { CEREBRO_DBG(("fd_write_n: %s", strerror(errno))); @@ -196,28 +196,28 @@ _event_server_err_check(cerebro_t handle, int n, len = 0; int32_t version; u_int32_t err_code; - + if ((n = unmarshall_int32(&version, buf + len, buflen - len)) < 0) { CEREBRO_DBG(("unmarshall_int32")); handle->errnum = CEREBRO_ERR_INTERNAL; return -1; } - + if (!n) { handle->errnum = CEREBRO_ERR_PROTOCOL; return -1; } len += n; - + if ((n = unmarshall_u_int32(&err_code, buf + len, buflen - len)) < 0) { CEREBRO_DBG(("unmarshall_u_int32")); handle->errnum = CEREBRO_ERR_INTERNAL; return -1; } - + if (!n) { handle->errnum = CEREBRO_ERR_PROTOCOL; @@ -230,7 +230,7 @@ _event_server_err_check(cerebro_t handle, handle->errnum = CEREBRO_ERR_VERSION_INCOMPATIBLE; return -1; } - + if (err_code != CEREBRO_EVENT_SERVER_PROTOCOL_ERR_SUCCESS) { handle->errnum = _event_server_protocol_err_code_conversion(err_code); @@ -300,17 +300,17 @@ _event_server_response_unmarshall(cerebro_t handle, return -1; } c += n; - + if (c != CEREBRO_EVENT_SERVER_RESPONSE_LEN) { handle->errnum = CEREBRO_ERR_PROTOCOL; return -1; } - + return 0; } -/* +/* * _event_connection * * Make a connection given the parameters @@ -358,7 +358,7 @@ _event_connection(cerebro_t handle, return -1; } -/* +/* * _setup_event_connection * * Setup an event connection @@ -380,7 +380,7 @@ _setup_event_connection(cerebro_t handle, const char *event_name) if (_cerebro_load_config(handle) < 0) return -1; - + /* No flags available for events right now, so nothing to handle */ flags = 0; @@ -424,13 +424,13 @@ _setup_event_connection(cerebro_t handle, const char *event_name) continue; break; } - + if (i >= handle->config_data.cerebro_event_server_len) { handle->errnum = CEREBRO_ERR_CONNECT; goto cleanup; } - + if (fd < 0) goto cleanup; } @@ -445,7 +445,7 @@ _setup_event_connection(cerebro_t handle, const char *event_name) port = CEREBRO_EVENT_SERVER_PORT; else port = handle->port; - + if ((fd = _event_connection(handle, event_name, hostname, @@ -501,7 +501,7 @@ _get_event_names(cerebro_t handle, char buf[CEREBRO_MAX_PACKET_LEN]; int bytes_read; unsigned int errnum; - + if ((bytes_read = receive_data(fd, CEREBRO_EVENT_SERVER_RESPONSE_LEN, buf, @@ -512,29 +512,29 @@ _get_event_names(cerebro_t handle, handle->errnum = errnum; goto cleanup; } - + if (bytes_read < CEREBRO_EVENT_SERVER_RESPONSE_LEN) { handle->errnum = CEREBRO_ERR_PROTOCOL; goto cleanup; } - + if (_event_server_err_check(handle, buf, bytes_read) < 0) goto cleanup; - + if (_event_server_response_unmarshall(handle, &res, buf, bytes_read) < 0) goto cleanup; - + if (res.end == CEREBRO_EVENT_SERVER_PROTOCOL_IS_LAST_RESPONSE) break; - + /* Guarantee ending '\0' character */ memset(event_name_buf, '\0', CEREBRO_MAX_EVENT_NAME_LEN+1); memcpy(event_name_buf, res.event_name, CEREBRO_MAX_EVENT_NAME_LEN); - + if (_cerebro_namelist_append(namelist, event_name_buf) < 0) goto cleanup; } @@ -560,7 +560,7 @@ cerebro_get_event_names(cerebro_t handle) if ((fd = _setup_event_connection(handle, CEREBRO_EVENT_NAMES)) < 0) goto cleanup; - + if (_get_event_names(handle, fd, namelist) < 0) goto cleanup; @@ -594,7 +594,7 @@ cerebro_event_register(cerebro_t handle, const char *event_name) handle->errnum = CEREBRO_ERR_PARAMETERS; goto cleanup; } - + if ((fd = _setup_event_connection(handle, event_name)) < 0) goto cleanup; @@ -614,7 +614,7 @@ cerebro_event_register(cerebro_t handle, const char *event_name) handle->errnum = CEREBRO_ERR_PROTOCOL; goto cleanup; } - + if (_event_server_err_check(handle, buf, bytes_read) < 0) goto cleanup; @@ -634,7 +634,7 @@ cerebro_event_register(cerebro_t handle, const char *event_name) handle->errnum = CEREBRO_ERR_SUCCESS; return fd; - + cleanup: /* ignore potential error, we're in the error path already */ if (fd >= 0) @@ -644,7 +644,7 @@ cerebro_event_register(cerebro_t handle, const char *event_name) return -1; } -/* +/* * _event_fd_find * * Callback for finding an fd in a list @@ -664,7 +664,7 @@ _event_fd_find(void *x, void *key) return 0; } -int +int cerebro_event_unregister(cerebro_t handle, int fd) { if (_cerebro_handle_check(handle) < 0) @@ -811,7 +811,7 @@ _event_value_unmarshall(cerebro_t handle, return -1; } #endif /* CEREBRO_DEBUG */ - + etype = event->event_value_type; elen = event->event_value_len; @@ -849,7 +849,7 @@ _event_value_unmarshall(cerebro_t handle, } int -cerebro_event_parse(cerebro_t handle, +cerebro_event_parse(cerebro_t handle, int fd, char **nodename, unsigned int *event_value_type, @@ -863,7 +863,7 @@ cerebro_event_parse(cerebro_t handle, unsigned int errnum; char *vbuf = NULL; void *event_value_ptr = NULL; - + memset(&event, '\0', sizeof(struct cerebro_event)); if (_cerebro_handle_check(handle) < 0) @@ -874,7 +874,7 @@ cerebro_event_parse(cerebro_t handle, handle->errnum = CEREBRO_ERR_PARAMETERS; goto cleanup; } - + if (!list_find_first(handle->event_fds, _event_fd_find, &fd)) @@ -882,7 +882,7 @@ cerebro_event_parse(cerebro_t handle, handle->errnum = CEREBRO_ERR_PARAMETERS; goto cleanup; } - + pfd.fd = fd; pfd.events = POLLIN; pfd.revents = 0; @@ -893,7 +893,7 @@ cerebro_event_parse(cerebro_t handle, handle->errnum = CEREBRO_ERR_INTERNAL; goto cleanup; } - + if (!n) { handle->errnum = CEREBRO_ERR_EVENT_NOT_RECEIVED; @@ -916,7 +916,7 @@ cerebro_event_parse(cerebro_t handle, handle->errnum = errnum; goto cleanup; } - + if (bytes_read < CEREBRO_EVENT_HEADER_LEN) { handle->errnum = CEREBRO_ERR_PROTOCOL; @@ -932,7 +932,7 @@ cerebro_event_parse(cerebro_t handle, bytes_read) < 0) goto cleanup; - if (check_data_type_len(event.event_value_type, + if (check_data_type_len(event.event_value_type, event.event_value_len) < 0) { handle->errnum = CEREBRO_ERR_PROTOCOL; @@ -957,13 +957,13 @@ cerebro_event_parse(cerebro_t handle, handle->errnum = errnum; goto cleanup; } - + if (vbytes_read != event.event_value_len) { handle->errnum = CEREBRO_ERR_PROTOCOL; goto cleanup; - } - + } + if (event_value) { if (_event_value_unmarshall(handle, @@ -972,7 +972,7 @@ cerebro_event_parse(cerebro_t handle, vbuf, vbytes_read) < 0) goto cleanup; - + event.event_value = event_value_ptr; event_value_ptr = NULL; } @@ -990,7 +990,7 @@ cerebro_event_parse(cerebro_t handle, /* To ensure null string at end */ memset(nodename_buf, '\0', CEREBRO_MAX_NODENAME_LEN + 1); memcpy(nodename_buf, event.nodename, CEREBRO_MAX_NODENAME_LEN); - + if (!(*nodename = strdup(nodename_buf))) { handle->errnum = CEREBRO_ERR_OUTMEM; @@ -1000,7 +1000,7 @@ cerebro_event_parse(cerebro_t handle, if (event_value_type) *event_value_type = event.event_value_type; - + if (event_value_len) *event_value_len = event.event_value_len; @@ -1013,7 +1013,7 @@ cerebro_event_parse(cerebro_t handle, handle->errnum = CEREBRO_ERR_SUCCESS; return 0; - + cleanup: if (vbuf) free(vbuf); diff --git a/src/libs/cerebro/cerebro_metric_control.c b/src/libs/cerebro/cerebro_metric_control.c index d4785075..2b944292 100644 --- a/src/libs/cerebro/cerebro_metric_control.c +++ b/src/libs/cerebro/cerebro_metric_control.c @@ -53,7 +53,7 @@ #include "data_util.h" #include "network_util.h" -/* +/* * _setup_metric_control_fd * * Setup the metric control file descriptor @@ -197,7 +197,7 @@ _metric_control_request_marshall(cerebro_t handle, return -1; } c += n; - + return c; } @@ -211,7 +211,7 @@ _metric_control_request_marshall(cerebro_t handle, static int _metric_control_request_send(cerebro_t handle, int fd, - int command, + int command, const char *metric_name, unsigned int metric_value_type, unsigned int metric_value_len, @@ -241,13 +241,13 @@ _metric_control_request_send(cerebro_t handle, CEREBRO_DBG(("truncate metric string: %d", metric_value_len)); metric_value_len = CEREBRO_MAX_DATA_STRING_LEN; } - + if (metric_value_type == CEREBRO_DATA_VALUE_TYPE_STRING && !metric_value_len) { CEREBRO_DBG(("adjusting metric type to none")); metric_value_type = CEREBRO_DATA_VALUE_TYPE_NONE; - } + } } if (!handle->flags) @@ -265,7 +265,7 @@ _metric_control_request_send(cerebro_t handle, } else flags = handle->flags; - + memset(&req, '\0', sizeof(struct cerebro_metric_control_request)); req.version = CEREBRO_METRIC_CONTROL_PROTOCOL_VERSION; req.command = command; @@ -275,12 +275,12 @@ _metric_control_request_send(cerebro_t handle, req.metric_value_len = metric_value_len; req.metric_value = metric_value; - if ((req_len = _metric_control_request_marshall(handle, - &req, - buf, + if ((req_len = _metric_control_request_marshall(handle, + &req, + buf, CEREBRO_MAX_PACKET_LEN)) < 0) return -1; - + if (fd_write_n(fd, buf, req_len) < 0) { CEREBRO_DBG(("fd_write_n: %s", strerror(errno))); @@ -299,8 +299,8 @@ _metric_control_request_send(cerebro_t handle, * Returns 0 on success, -1 on error */ static int -_metric_control_response_check(cerebro_t handle, - const char *buf, +_metric_control_response_check(cerebro_t handle, + const char *buf, unsigned int buflen) { int n, len = 0; @@ -334,7 +334,7 @@ _metric_control_response_check(cerebro_t handle, return -1; } len += n; - + if (version != CEREBRO_METRIC_CONTROL_PROTOCOL_VERSION) { handle->errnum = CEREBRO_ERR_VERSION_INCOMPATIBLE; @@ -346,7 +346,7 @@ _metric_control_response_check(cerebro_t handle, handle->errnum = _metric_control_protocol_err_code_conversion(err_code); return -1; } - + return 0; } @@ -364,7 +364,7 @@ _metric_control_response_receive(cerebro_t handle, int fd) unsigned int errnum; int bytes_read; - if ((bytes_read = receive_data(fd, + if ((bytes_read = receive_data(fd, CEREBRO_METRIC_CONTROL_RESPONSE_LEN, buf, CEREBRO_MAX_PACKET_LEN, @@ -374,7 +374,7 @@ _metric_control_response_receive(cerebro_t handle, int fd) handle->errnum = errnum; return -1; } - + if (bytes_read != CEREBRO_METRIC_CONTROL_RESPONSE_LEN) { handle->errnum = CEREBRO_ERR_PROTOCOL; @@ -387,7 +387,7 @@ _metric_control_response_receive(cerebro_t handle, int fd) return 0; } -/* +/* * _cerebro_metric_control * * Common code for cerebro metric control API @@ -395,9 +395,9 @@ _metric_control_response_receive(cerebro_t handle, int fd) * Returns 0 on success, -1 on error */ static int -_cerebro_metric_control(cerebro_t handle, +_cerebro_metric_control(cerebro_t handle, unsigned int command, - const char *metric_name, + const char *metric_name, unsigned int metric_value_type, unsigned int metric_value_len, void *metric_value) @@ -439,23 +439,23 @@ _cerebro_metric_control(cerebro_t handle, return rv; } -int +int cerebro_register_metric(cerebro_t handle, const char *metric_name) { - return _cerebro_metric_control(handle, + return _cerebro_metric_control(handle, CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_REGISTER, - metric_name, + metric_name, CEREBRO_DATA_VALUE_TYPE_NONE, 0, NULL); } -int +int cerebro_unregister_metric(cerebro_t handle, const char *metric_name) { - return _cerebro_metric_control(handle, + return _cerebro_metric_control(handle, CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_UNREGISTER, - metric_name, + metric_name, CEREBRO_DATA_VALUE_TYPE_NONE, 0, NULL); @@ -468,31 +468,31 @@ cerebro_update_metric_value(cerebro_t handle, unsigned int metric_value_len, void *metric_value) { - return _cerebro_metric_control(handle, + return _cerebro_metric_control(handle, CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_UPDATE, - metric_name, + metric_name, metric_value_type, metric_value_len, metric_value); } -int +int cerebro_resend_metric(cerebro_t handle, const char *metric_name) { - return _cerebro_metric_control(handle, + return _cerebro_metric_control(handle, CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_RESEND, - metric_name, + metric_name, CEREBRO_DATA_VALUE_TYPE_NONE, 0, NULL); } -int +int cerebro_flush_metric(cerebro_t handle, const char *metric_name) { - return _cerebro_metric_control(handle, + return _cerebro_metric_control(handle, CEREBRO_METRIC_CONTROL_PROTOCOL_CMD_FLUSH, - metric_name, + metric_name, CEREBRO_DATA_VALUE_TYPE_NONE, 0, NULL); diff --git a/src/libs/cerebro/cerebro_metric_data.c b/src/libs/cerebro/cerebro_metric_data.c index 131535ab..ca9a0c8e 100644 --- a/src/libs/cerebro/cerebro_metric_data.c +++ b/src/libs/cerebro/cerebro_metric_data.c @@ -50,7 +50,7 @@ #include "data_util.h" #include "network_util.h" -/* +/* * _metric_value_unmarshall * * Unmarshall contents of a metric server response @@ -69,9 +69,9 @@ _metric_value_unmarshall(cerebro_t handle, u_int32_t mtype, mlen; #if CEREBRO_DEBUG - if (!res - || res->metric_value_type == CEREBRO_DATA_VALUE_TYPE_NONE - || !metric_value + if (!res + || res->metric_value_type == CEREBRO_DATA_VALUE_TYPE_NONE + || !metric_value || !buf) { CEREBRO_DBG(("invalid parameters")); @@ -96,7 +96,7 @@ _metric_value_unmarshall(cerebro_t handle, } memset(mvalue, '\0', mvalue_len); - if (unmarshall_data_value(mtype, + if (unmarshall_data_value(mtype, mlen, mvalue, mvalue_len, @@ -116,7 +116,7 @@ _metric_value_unmarshall(cerebro_t handle, return -1; } -/* +/* * _receive_metric_value * * Receive the metric value @@ -124,7 +124,7 @@ _metric_value_unmarshall(cerebro_t handle, * Returns 0 on success, -1 on error */ static int -_receive_metric_value(cerebro_t handle, +_receive_metric_value(cerebro_t handle, struct cerebro_metric_server_response *res, int fd) { @@ -145,7 +145,7 @@ _receive_metric_value(cerebro_t handle, handle->errnum = CEREBRO_ERR_OUTMEM; goto cleanup; } - + if ((vbytes_read = receive_data(fd, res->metric_value_len, vbuf, @@ -156,38 +156,38 @@ _receive_metric_value(cerebro_t handle, handle->errnum = errnum; goto cleanup; } - + if (vbytes_read != res->metric_value_len) { handle->errnum = CEREBRO_ERR_PROTOCOL; goto cleanup; } - - if (_metric_value_unmarshall(handle, - res, - &metric_value, - vbuf, + + if (_metric_value_unmarshall(handle, + res, + &metric_value, + vbuf, vbytes_read) < 0) goto cleanup; res->metric_value = metric_value; - + rv = 0; cleanup: free(vbuf); return rv; } -/* +/* * _receive_metric_data_response * * Receive a metric server data response. - * + * * Returns 0 on success, -1 on error */ static int -_receive_metric_data_response(cerebro_t handle, - void *list, +_receive_metric_data_response(cerebro_t handle, + void *list, struct cerebro_metric_server_response *res, unsigned int bytes_read, int fd) @@ -239,14 +239,14 @@ _receive_metric_data_response(cerebro_t handle, memset(nodename_buf, '\0', CEREBRO_MAX_NODENAME_LEN+1); memcpy(nodename_buf, res->name, CEREBRO_MAX_NODENAME_LEN); - if (_cerebro_nodelist_append(nodelist, + if (_cerebro_nodelist_append(nodelist, nodename_buf, res->metric_value_received_time, res->metric_value_type, res->metric_value_len, res->metric_value) < 0) goto cleanup_metric_value; - + rv = 0; cleanup_metric_value: free(res->metric_value); @@ -254,7 +254,7 @@ _receive_metric_data_response(cerebro_t handle, return rv; } -cerebro_nodelist_t +cerebro_nodelist_t cerebro_get_metric_data(cerebro_t handle, const char *metric_name) { struct cerebro_nodelist *nodelist = NULL; @@ -267,22 +267,22 @@ cerebro_get_metric_data(cerebro_t handle, const char *metric_name) handle->errnum = CEREBRO_ERR_PARAMETERS; goto cleanup; } - + if (!(nodelist = _cerebro_nodelist_create(handle, metric_name))) goto cleanup; - + if (_cerebro_metric_get_data(handle, nodelist, metric_name, _receive_metric_data_response) < 0) goto cleanup; - + if (_cerebro_nodelist_sort(nodelist) < 0) goto cleanup; handle->errnum = CEREBRO_ERR_SUCCESS; return nodelist; - + cleanup: if (nodelist) (void)cerebro_nodelist_destroy(nodelist); diff --git a/src/libs/cerebro/cerebro_metric_names.c b/src/libs/cerebro/cerebro_metric_names.c index 8fa63b66..e5644618 100644 --- a/src/libs/cerebro/cerebro_metric_names.c +++ b/src/libs/cerebro/cerebro_metric_names.c @@ -48,11 +48,11 @@ #include "debug.h" #include "marshall.h" -/* +/* * _receive_metric_name_response * * Receive a metric server name response - * + * * Returns 0 on success, -1 on error */ static int @@ -92,11 +92,11 @@ _receive_metric_name_response(cerebro_t handle, handle->errnum = CEREBRO_ERR_PROTOCOL; goto cleanup; } - + /* Guarantee ending '\0' character */ memset(metric_name_buf, '\0', CEREBRO_MAX_METRIC_NAME_LEN+1); memcpy(metric_name_buf, res->name, CEREBRO_MAX_METRIC_NAME_LEN); - + if (_cerebro_namelist_append(namelist, metric_name_buf) < 0) goto cleanup; @@ -106,7 +106,7 @@ _receive_metric_name_response(cerebro_t handle, return -1; } -cerebro_namelist_t +cerebro_namelist_t cerebro_get_metric_names(cerebro_t handle) { struct cerebro_namelist *namelist = NULL; @@ -122,12 +122,12 @@ cerebro_get_metric_names(cerebro_t handle) CEREBRO_METRIC_METRIC_NAMES, _receive_metric_name_response) < 0) goto cleanup; - - - + + + handle->errnum = CEREBRO_ERR_SUCCESS; return namelist; - + cleanup: if (namelist) (void)cerebro_namelist_destroy(namelist); diff --git a/src/libs/cerebro/cerebro_metric_util.c b/src/libs/cerebro/cerebro_metric_util.c index 01aee17e..e1824e75 100644 --- a/src/libs/cerebro/cerebro_metric_util.c +++ b/src/libs/cerebro/cerebro_metric_util.c @@ -198,8 +198,8 @@ _metric_server_request_send(cerebro_t handle, * Returns 0 on success, -1 on error */ static int -_metric_server_response_check(cerebro_t handle, - const char *buf, +_metric_server_response_check(cerebro_t handle, + const char *buf, unsigned int buflen) { int n, len = 0; @@ -233,7 +233,7 @@ _metric_server_response_check(cerebro_t handle, return -1; } len += n; - + if (version != CEREBRO_METRIC_SERVER_PROTOCOL_VERSION) { handle->errnum = CEREBRO_ERR_VERSION_INCOMPATIBLE; @@ -245,7 +245,7 @@ _metric_server_response_check(cerebro_t handle, handle->errnum = _metric_server_protocol_err_code_conversion(err_code); return -1; } - + return 0; } @@ -324,7 +324,7 @@ _metric_server_response_header_unmarshall(cerebro_t handle, return -1; } c += n; - + mlenPtr = &(res->metric_value_len); if ((n = unmarshall_u_int32(mlenPtr, buf + c, buflen - c)) < 0) { @@ -333,7 +333,7 @@ _metric_server_response_header_unmarshall(cerebro_t handle, return -1; } c += n; - + if (c != CEREBRO_METRIC_SERVER_RESPONSE_HEADER_LEN) { handle->errnum = CEREBRO_ERR_PROTOCOL; @@ -344,7 +344,7 @@ _metric_server_response_header_unmarshall(cerebro_t handle, } /* - * _get_metric_data + * _get_metric_data * * Get metric data and store it appropriately * @@ -369,7 +369,7 @@ _get_metric_data(cerebro_t handle, handle->errnum = CEREBRO_ERR_INTERNAL; return -1; } - + if ((fd = low_timeout_connect(hostname, port, CEREBRO_METRIC_SERVER_PROTOCOL_CONNECT_TIMEOUT_LEN, @@ -378,7 +378,7 @@ _get_metric_data(cerebro_t handle, handle->errnum = errnum; goto cleanup; } - + if (_metric_server_request_send(handle, fd, metric_name, @@ -419,19 +419,19 @@ _get_metric_data(cerebro_t handle, goto cleanup; } - if (_metric_server_response_header_unmarshall(handle, - &res, - buf, + if (_metric_server_response_header_unmarshall(handle, + &res, + buf, bytes_read) < 0) goto cleanup; - + if (res.end == CEREBRO_METRIC_SERVER_PROTOCOL_IS_LAST_RESPONSE) break; if (receive_response(handle, list, &res, bytes_read, fd) < 0) goto cleanup; } - + rv = 0; cleanup: /* ignore potential error, just return result */ @@ -439,7 +439,7 @@ _get_metric_data(cerebro_t handle, return rv; } -int +int _cerebro_metric_get_data(cerebro_t handle, void *list, const char *metric_name, @@ -503,7 +503,7 @@ _cerebro_metric_get_data(cerebro_t handle, char *hostname; if (handle->config_data.cerebro_metric_server_flag) - { + { for (i = 0; i < handle->config_data.cerebro_metric_server_len; i++) { if (!strlen(handle->hostname)) @@ -538,13 +538,13 @@ _cerebro_metric_get_data(cerebro_t handle, continue; break; } - + if (i >= handle->config_data.cerebro_metric_server_len) { handle->errnum = CEREBRO_ERR_CONNECT; return -1; } - + if (rv < 0) return -1; } @@ -554,7 +554,7 @@ _cerebro_metric_get_data(cerebro_t handle, hostname = "localhost"; else hostname = handle->hostname; - + if (!handle->port) port = CEREBRO_METRIC_SERVER_PORT; else @@ -583,7 +583,7 @@ _cerebro_metric_get_data(cerebro_t handle, receive_response) < 0) return -1; } - + return 0; } diff --git a/src/libs/cerebro/cerebro_metric_util.h b/src/libs/cerebro/cerebro_metric_util.h index 38bafab4..0a68d1e0 100644 --- a/src/libs/cerebro/cerebro_metric_util.h +++ b/src/libs/cerebro/cerebro_metric_util.h @@ -32,7 +32,7 @@ #include "cerebro/cerebro_metric_server_protocol.h" -/* +/* * Cerebro_metric_receive_response * * Function to call after the metric request has been sent @@ -43,7 +43,7 @@ typedef int (*Cerebro_metric_receive_response)(cerebro_t handle, unsigned int bytes_read, int fd); -/* +/* * _cerebro_metric_get_data * * Connect to the cerebrod metric and receive responses diff --git a/src/libs/cerebro/cerebro_namelist.c b/src/libs/cerebro/cerebro_namelist.c index 2654b299..2b529c43 100644 --- a/src/libs/cerebro/cerebro_namelist.c +++ b/src/libs/cerebro/cerebro_namelist.c @@ -44,17 +44,17 @@ #include "debug.h" #include "list.h" -int +int cerebro_namelist_length(cerebro_namelist_t namelist) { if (_cerebro_namelist_check(namelist) < 0) return -1; - + namelist->errnum = CEREBRO_ERR_SUCCESS; return list_count(namelist->metric_names); } -int +int cerebro_namelist_destroy(cerebro_namelist_t namelist) { cerebro_namelist_t tempnamelist; @@ -75,10 +75,10 @@ cerebro_namelist_destroy(cerebro_namelist_t namelist) if (tempnamelist == namelist) { list_remove(itr); - + namelist->magic = ~CEREBRO_NAMELIST_MAGIC_NUMBER; namelist->errnum = CEREBRO_ERR_SUCCESS; - /* + /* * destroy metric_names first, since it will destroy iterators */ list_destroy(namelist->metric_names); @@ -107,8 +107,8 @@ cerebro_namelist_destroy(cerebro_namelist_t namelist) list_iterator_destroy(itr); return rv; } - -cerebro_namelist_iterator_t + +cerebro_namelist_iterator_t cerebro_namelist_iterator_create(cerebro_namelist_t namelist) { cerebro_namelist_iterator_t namelistItr = NULL; @@ -123,13 +123,13 @@ cerebro_namelist_iterator_create(cerebro_namelist_t namelist) } memset(namelistItr, '\0', sizeof(struct cerebro_namelist_iterator)); namelistItr->magic = CEREBRO_NAMELIST_ITERATOR_MAGIC_NUMBER; - + if (!(namelistItr->itr = list_iterator_create(namelist->metric_names))) { namelist->errnum = CEREBRO_ERR_OUTMEM; goto cleanup; } - + if (!list_append(namelist->iterators, namelistItr)) { CEREBRO_DBG(("list_append: %s", strerror(errno))); @@ -151,8 +151,8 @@ cerebro_namelist_iterator_create(cerebro_namelist_t namelist) } return NULL; } - -/* + +/* * _cerebro_namelist_iterator_check * * Checks for a proper cerebro namelist @@ -162,7 +162,7 @@ cerebro_namelist_iterator_create(cerebro_namelist_t namelist) int _cerebro_namelist_iterator_check(cerebro_namelist_iterator_t namelistItr) { - if (!namelistItr + if (!namelistItr || namelistItr->magic != CEREBRO_NAMELIST_ITERATOR_MAGIC_NUMBER) return -1; @@ -172,7 +172,7 @@ _cerebro_namelist_iterator_check(cerebro_namelist_iterator_t namelistItr) namelistItr->errnum = CEREBRO_ERR_INTERNAL; return -1; } - + if (namelistItr->namelist->magic != CEREBRO_NAMELIST_MAGIC_NUMBER) { CEREBRO_DBG(("namelist destroyed")); @@ -184,19 +184,19 @@ _cerebro_namelist_iterator_check(cerebro_namelist_iterator_t namelistItr) } -int +int cerebro_namelist_iterator_name(cerebro_namelist_iterator_t namelistItr, char **name) { if (_cerebro_namelist_iterator_check(namelistItr) < 0) return -1; - + if (!namelistItr->current) { namelistItr->errnum = CEREBRO_ERR_END_OF_LIST; return -1; } - + if (name) *name = namelistItr->current; return 0; @@ -213,8 +213,8 @@ cerebro_namelist_iterator_next(cerebro_namelist_iterator_t namelistItr) namelistItr->errnum = CEREBRO_ERR_SUCCESS; return (namelistItr->current) ? 1 : 0; } - -int + +int cerebro_namelist_iterator_reset(cerebro_namelist_iterator_t namelistItr) { if (_cerebro_namelist_iterator_check(namelistItr) < 0) @@ -235,7 +235,7 @@ cerebro_namelist_iterator_at_end(cerebro_namelist_iterator_t namelistItr) return (namelistItr->current) ? 0 : 1; } -int +int cerebro_namelist_iterator_destroy(cerebro_namelist_iterator_t namelistItr) { cerebro_namelist_t namelist; @@ -245,7 +245,7 @@ cerebro_namelist_iterator_destroy(cerebro_namelist_iterator_t namelistItr) if (_cerebro_namelist_iterator_check(namelistItr) < 0) return -1; - + namelist = namelistItr->namelist; if (!(itr = list_iterator_create(namelist->iterators))) @@ -253,7 +253,7 @@ cerebro_namelist_iterator_destroy(cerebro_namelist_iterator_t namelistItr) namelistItr->errnum = CEREBRO_ERR_OUTMEM; goto cleanup; } - + while ((tempItr = list_next(itr))) { if (tempItr == namelistItr) @@ -267,7 +267,7 @@ cerebro_namelist_iterator_destroy(cerebro_namelist_iterator_t namelistItr) break; } } - + if (!found) { namelistItr->errnum = CEREBRO_ERR_PARAMETERS; diff --git a/src/libs/cerebro/cerebro_namelist_util.c b/src/libs/cerebro/cerebro_namelist_util.c index f9a9ef0d..93022429 100644 --- a/src/libs/cerebro/cerebro_namelist_util.c +++ b/src/libs/cerebro/cerebro_namelist_util.c @@ -48,7 +48,7 @@ _cerebro_namelist_check(cerebro_namelist_t namelist) { if (!namelist || namelist->magic != CEREBRO_NAMELIST_MAGIC_NUMBER) return -1; - + if (!namelist->metric_names || !namelist->iterators || !namelist->handle) @@ -57,18 +57,18 @@ _cerebro_namelist_check(cerebro_namelist_t namelist) namelist->errnum = CEREBRO_ERR_INTERNAL; return -1; } - + if (namelist->handle->magic != CEREBRO_MAGIC_NUMBER) { CEREBRO_DBG(("handle destroyed")); namelist->errnum = CEREBRO_ERR_MAGIC_NUMBER; return -1; } - + return 0; } -cerebro_namelist_t +cerebro_namelist_t _cerebro_namelist_create(cerebro_t handle) { cerebro_namelist_t namelist = NULL; @@ -103,11 +103,11 @@ _cerebro_namelist_create(cerebro_t handle) handle->errnum = CEREBRO_ERR_INTERNAL; goto cleanup; } - + namelist->handle = handle; return namelist; - + cleanup: if (namelist) { @@ -120,8 +120,8 @@ _cerebro_namelist_create(cerebro_t handle) return NULL; } -int -_cerebro_namelist_append(cerebro_namelist_t namelist, +int +_cerebro_namelist_append(cerebro_namelist_t namelist, const char *metric_name) { char *str = NULL; @@ -148,7 +148,7 @@ _cerebro_namelist_append(cerebro_namelist_t namelist, namelist->errnum = CEREBRO_ERR_INTERNAL; goto cleanup; } - + return 0; cleanup: diff --git a/src/libs/cerebro/cerebro_namelist_util.h b/src/libs/cerebro/cerebro_namelist_util.h index d7b25b15..b89ecb78 100644 --- a/src/libs/cerebro/cerebro_namelist_util.h +++ b/src/libs/cerebro/cerebro_namelist_util.h @@ -40,10 +40,10 @@ */ int _cerebro_namelist_check(cerebro_namelist_t namelist); -/* +/* * _cerebro_namelist_create * - * Create and initialize a namelist + * Create and initialize a namelist * * Returns namelist on success, NULL on error */ @@ -51,7 +51,7 @@ cerebro_namelist_t _cerebro_namelist_create(cerebro_t handle); /* * _cerebro_namelist_append - * + * * Append additional namelist data * * Returns 0 on success, -1 on error diff --git a/src/libs/cerebro/cerebro_nodelist.c b/src/libs/cerebro/cerebro_nodelist.c index 43bf3f18..3d9426c8 100644 --- a/src/libs/cerebro/cerebro_nodelist.c +++ b/src/libs/cerebro/cerebro_nodelist.c @@ -49,22 +49,22 @@ cerebro_nodelist_metric_name(cerebro_nodelist_t nodelist) { if (_cerebro_nodelist_check(nodelist) < 0) return NULL; - + nodelist->errnum = CEREBRO_ERR_SUCCESS; return nodelist->metric_name; } -int +int cerebro_nodelist_length(cerebro_nodelist_t nodelist) { if (_cerebro_nodelist_check(nodelist) < 0) return -1; - + nodelist->errnum = CEREBRO_ERR_SUCCESS; return list_count(nodelist->nodes); } -int +int cerebro_nodelist_destroy(cerebro_nodelist_t nodelist) { cerebro_nodelist_t tempnodelist; @@ -85,10 +85,10 @@ cerebro_nodelist_destroy(cerebro_nodelist_t nodelist) if (tempnodelist == nodelist) { list_remove(itr); - + nodelist->magic = ~CEREBRO_NODELIST_MAGIC_NUMBER; nodelist->errnum = CEREBRO_ERR_SUCCESS; - /* + /* * destroy nodes first, since it will destroy iterators */ list_destroy(nodelist->nodes); @@ -117,8 +117,8 @@ cerebro_nodelist_destroy(cerebro_nodelist_t nodelist) list_iterator_destroy(itr); return rv; } - -cerebro_nodelist_iterator_t + +cerebro_nodelist_iterator_t cerebro_nodelist_iterator_create(cerebro_nodelist_t nodelist) { cerebro_nodelist_iterator_t nodelistItr = NULL; @@ -133,13 +133,13 @@ cerebro_nodelist_iterator_create(cerebro_nodelist_t nodelist) } memset(nodelistItr, '\0', sizeof(struct cerebro_nodelist_iterator)); nodelistItr->magic = CEREBRO_NODELIST_ITERATOR_MAGIC_NUMBER; - + if (!(nodelistItr->itr = list_iterator_create(nodelist->nodes))) { nodelist->errnum = CEREBRO_ERR_OUTMEM; goto cleanup; } - + if (!list_append(nodelist->iterators, nodelistItr)) { CEREBRO_DBG(("list_append: %s", strerror(errno))); @@ -161,8 +161,8 @@ cerebro_nodelist_iterator_create(cerebro_nodelist_t nodelist) } return NULL; } - -/* + +/* * _cerebro_nodelist_iterator_check * * Checks for a proper cerebro nodelist @@ -172,7 +172,7 @@ cerebro_nodelist_iterator_create(cerebro_nodelist_t nodelist) int _cerebro_nodelist_iterator_check(cerebro_nodelist_iterator_t nodelistItr) { - if (!nodelistItr + if (!nodelistItr || nodelistItr->magic != CEREBRO_NODELIST_ITERATOR_MAGIC_NUMBER) return -1; @@ -194,25 +194,25 @@ _cerebro_nodelist_iterator_check(cerebro_nodelist_iterator_t nodelistItr) } -int +int cerebro_nodelist_iterator_nodename(cerebro_nodelist_iterator_t nodelistItr, char **nodename) { if (_cerebro_nodelist_iterator_check(nodelistItr) < 0) return -1; - + if (!nodelistItr->current) { nodelistItr->errnum = CEREBRO_ERR_END_OF_LIST; return -1; } - + if (nodename) *nodename = nodelistItr->current->nodename; return 0; } -int +int cerebro_nodelist_iterator_metric_value(cerebro_nodelist_iterator_t nodelistItr, unsigned int *metric_value_received_time, unsigned int *metric_value_type, @@ -233,10 +233,10 @@ cerebro_nodelist_iterator_metric_value(cerebro_nodelist_iterator_t nodelistItr, if (metric_value_type) *metric_value_type = nodelistItr->current->metric_value_type; - + if (metric_value_len) *metric_value_len = nodelistItr->current->metric_value_len; - + if (metric_value) *metric_value = nodelistItr->current->metric_value; @@ -254,8 +254,8 @@ cerebro_nodelist_iterator_next(cerebro_nodelist_iterator_t nodelistItr) nodelistItr->errnum = CEREBRO_ERR_SUCCESS; return (nodelistItr->current) ? 1 : 0; } - -int + +int cerebro_nodelist_iterator_reset(cerebro_nodelist_iterator_t nodelistItr) { if (_cerebro_nodelist_iterator_check(nodelistItr) < 0) @@ -276,7 +276,7 @@ cerebro_nodelist_iterator_at_end(cerebro_nodelist_iterator_t nodelistItr) return (nodelistItr->current) ? 0 : 1; } -int +int cerebro_nodelist_iterator_destroy(cerebro_nodelist_iterator_t nodelistItr) { cerebro_nodelist_t nodelist; @@ -286,7 +286,7 @@ cerebro_nodelist_iterator_destroy(cerebro_nodelist_iterator_t nodelistItr) if (_cerebro_nodelist_iterator_check(nodelistItr) < 0) return -1; - + nodelist = nodelistItr->nodelist; if (!(itr = list_iterator_create(nodelist->iterators))) @@ -294,7 +294,7 @@ cerebro_nodelist_iterator_destroy(cerebro_nodelist_iterator_t nodelistItr) nodelistItr->errnum = CEREBRO_ERR_OUTMEM; goto cleanup; } - + while ((tempItr = list_next(itr))) { if (tempItr == nodelistItr) @@ -308,7 +308,7 @@ cerebro_nodelist_iterator_destroy(cerebro_nodelist_iterator_t nodelistItr) break; } } - + if (!found) { nodelistItr->errnum = CEREBRO_ERR_PARAMETERS; diff --git a/src/libs/cerebro/cerebro_nodelist_util.c b/src/libs/cerebro/cerebro_nodelist_util.c index e63294e3..c1185d8d 100644 --- a/src/libs/cerebro/cerebro_nodelist_util.c +++ b/src/libs/cerebro/cerebro_nodelist_util.c @@ -68,7 +68,7 @@ _cerebro_nodelist_check(cerebro_nodelist_t nodelist) return 0; } -/* +/* * _cerebro_nodelist_data_destroy * * Free contents of a nodelist data item @@ -77,7 +77,7 @@ static void _cerebro_nodelist_data_destroy(void *x) { struct cerebro_nodelist_data *nd; - + nd = (struct cerebro_nodelist_data *)x; if (nd->metric_value) @@ -85,7 +85,7 @@ _cerebro_nodelist_data_destroy(void *x) free(nd); } -cerebro_nodelist_t +cerebro_nodelist_t _cerebro_nodelist_create(cerebro_t handle, const char *metric_name) { cerebro_nodelist_t nodelist = NULL; @@ -121,11 +121,11 @@ _cerebro_nodelist_create(cerebro_t handle, const char *metric_name) handle->errnum = CEREBRO_ERR_INTERNAL; goto cleanup; } - + nodelist->handle = handle; return nodelist; - + cleanup: if (nodelist) { @@ -138,7 +138,7 @@ _cerebro_nodelist_create(cerebro_t handle, const char *metric_name) return NULL; } -int +int _cerebro_nodelist_append(cerebro_nodelist_t nodelist, const char *nodename, u_int32_t metric_value_received_time, @@ -195,7 +195,7 @@ _cerebro_nodelist_append(cerebro_nodelist_t nodelist, nodelist->errnum = CEREBRO_ERR_INTERNAL; goto cleanup; } - + return 0; cleanup: diff --git a/src/libs/cerebro/cerebro_nodelist_util.h b/src/libs/cerebro/cerebro_nodelist_util.h index 848ea55b..653a6454 100644 --- a/src/libs/cerebro/cerebro_nodelist_util.h +++ b/src/libs/cerebro/cerebro_nodelist_util.h @@ -40,19 +40,19 @@ */ int _cerebro_nodelist_check(cerebro_nodelist_t nodelist); -/* +/* * _cerebro_nodelist_create * - * Create and initialize a nodelist + * Create and initialize a nodelist * * Returns nodelist on success, NULL on error */ -cerebro_nodelist_t _cerebro_nodelist_create(cerebro_t handle, +cerebro_nodelist_t _cerebro_nodelist_create(cerebro_t handle, const char *metric_name); /* * _cerebro_nodelist_append - * + * * Append additional nodelist data * * Returns 0 on success, -1 on error @@ -66,7 +66,7 @@ int _cerebro_nodelist_append(cerebro_nodelist_t nodelist, /* * _cerebro_nodelist_sort - * + * * Sort the nodelist by nodename * * Returns 0 on success, -1 on error diff --git a/src/libs/cerebro/cerebro_util.c b/src/libs/cerebro/cerebro_util.c index bce0d3dd..6c163c13 100644 --- a/src/libs/cerebro/cerebro_util.c +++ b/src/libs/cerebro/cerebro_util.c @@ -38,7 +38,7 @@ #include "debug.h" -int +int _cerebro_handle_check(cerebro_t handle) { if (!handle || handle->magic != CEREBRO_MAGIC_NUMBER) @@ -57,7 +57,7 @@ _cerebro_handle_check(cerebro_t handle) handle->errnum = CEREBRO_ERR_INTERNAL; return -1; } - + return 0; } diff --git a/src/libs/cerebro/cerebro_util.h b/src/libs/cerebro/cerebro_util.h index ae3981cc..7ae4ee61 100644 --- a/src/libs/cerebro/cerebro_util.h +++ b/src/libs/cerebro/cerebro_util.h @@ -28,7 +28,7 @@ #ifndef _CEREBRO_UTIL_H #define _CEREBRO_UTIL_H -/* +/* * _cerebro_handle_check * * Checks for a proper cerebro handle, setting the errnum diff --git a/src/libs/cerebro_error/cerebro_error.c b/src/libs/cerebro_error/cerebro_error.c index b2af7213..2ae8c027 100644 --- a/src/libs/cerebro_error/cerebro_error.c +++ b/src/libs/cerebro_error/cerebro_error.c @@ -46,7 +46,7 @@ static int cerebro_err_initialized = 0; static int cerebro_flags = 0; -void +void cerebro_err_init(char *prog) { if (!prog) @@ -57,13 +57,13 @@ cerebro_err_init(char *prog) cerebro_err_initialized++; } -int +int cerebro_err_get_flags(void) { return cerebro_flags; } -void +void cerebro_err_set_flags(int flags) { int err_flags = 0; @@ -80,14 +80,14 @@ cerebro_err_set_flags(int flags) err_set_flags(err_flags); } -void +void cerebro_err_debug(const char *fmt, ...) { char buffer[CEREBRO_ERROR_STRING_BUFLEN]; va_list ap; if (!cerebro_err_initialized) - return; + return; if (!fmt) return; @@ -99,14 +99,14 @@ cerebro_err_debug(const char *fmt, ...) err_debug(buffer); } -void +void cerebro_err_output(const char *fmt, ...) { char buffer[CEREBRO_ERROR_STRING_BUFLEN]; va_list ap; if (!cerebro_err_initialized) - return; + return; if (!fmt) return; @@ -118,14 +118,14 @@ cerebro_err_output(const char *fmt, ...) err_output(buffer); } -void +void cerebro_err_exit(const char *fmt, ...) { char buffer[CEREBRO_ERROR_STRING_BUFLEN]; va_list ap; if (!cerebro_err_initialized) - return; + return; if (!fmt) return; diff --git a/src/libs/common/error.c b/src/libs/common/error.c index fbf49e11..416b0e6e 100644 --- a/src/libs/common/error.c +++ b/src/libs/common/error.c @@ -38,13 +38,13 @@ #include "error.h" -static char *err_prog = NULL; +static char *err_prog = NULL; static int err_flags = 0; static int exit_value = 1; #define ERROR_BUFLEN 1024 -void +void err_init(char *prog) { char *p = strrchr(prog, '/'); @@ -57,7 +57,7 @@ err_init_exit_value(int val) exit_value = val; } -int +int err_get_flags(void) { assert(err_prog); @@ -65,7 +65,7 @@ err_get_flags(void) return err_flags; } -void +void err_set_flags(int flags) { assert(err_prog); @@ -73,7 +73,7 @@ err_set_flags(int flags) err_flags = flags; } -static void +static void _err(int syslog_level, const char *fmt, va_list ap) { char buf[ERROR_BUFLEN]; @@ -101,7 +101,7 @@ err_debug(const char *fmt, ...) va_end(ap); } -void +void err_output(const char *fmt, ...) { va_list ap; @@ -126,12 +126,12 @@ err_exit(const char *fmt, ...) exit(exit_value); } -/* +/* * lsd_fatal_error * * for lsd libs like list.[ch] and hash.[ch] */ -void +void lsd_fatal_error(char *file, int line, char *mesg) { err_exit("LSD FATAL ERROR(%s:%d) %s: %s", file, line, mesg, strerror(errno)); diff --git a/src/libs/common/error.h b/src/libs/common/error.h index f5356fa5..6ad4140a 100644 --- a/src/libs/common/error.h +++ b/src/libs/common/error.h @@ -43,7 +43,7 @@ #define ERROR_STDERR 0x0002 #define ERROR_SYSLOG 0x0004 -/* +/* * err_init * * Initialize error lib with program name. This is usually the first @@ -59,35 +59,35 @@ void err_init(char *prog); */ void err_init_exit_value(int val); -/* +/* * err_get_flags * * Returns the currently set flags */ int err_get_flags(void); -/* +/* * err_set_flags * * Sets the error lib flags to 'flags'. */ void err_set_flags(int flags); -/* +/* * err_debug * * Output a debug message */ void err_debug(const char *fmt, ...); -/* +/* * err_output * * Output an error message */ void err_output(const char *fmt, ...); -/* +/* * err_exit * * Output an error message and exit diff --git a/src/libs/common/marshall.c b/src/libs/common/marshall.c index 28204fac..e7126819 100644 --- a/src/libs/common/marshall.c +++ b/src/libs/common/marshall.c @@ -24,11 +24,11 @@ * You should have received a copy of the GNU General Public License along * with Cerebro. If not, see . \*****************************************************************************/ - + #if HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */ - + #include #include #if STDC_HEADERS @@ -167,7 +167,7 @@ marshall_u_int64(u_int64_t val, char *buf, unsigned int buflen) return 0; } -int +int marshall_float(float val, char *buf, unsigned int buflen) { if (!buf || sizeof(float) != sizeof(u_int32_t)) @@ -186,11 +186,11 @@ marshall_float(float val, char *buf, unsigned int buflen) } return 0; } - -int + +int marshall_double(double val, char *buf, unsigned int buflen) { - + if (!buf || sizeof(double) != (2*sizeof(u_int32_t))) { errno = EINVAL; @@ -217,9 +217,9 @@ marshall_double(double val, char *buf, unsigned int buflen) int -marshall_buffer(const char *val, - unsigned int vallen, - char *buf, +marshall_buffer(const char *val, + unsigned int vallen, + char *buf, unsigned int buflen) { if (!val || !buf) @@ -364,7 +364,7 @@ unmarshall_u_int64(u_int64_t *val, const char *buf, unsigned int buflen) return 0; } -int +int unmarshall_float(float *val, const char *buf, unsigned int buflen) { if (!val || !buf || sizeof(float) != sizeof(u_int32_t)) @@ -385,7 +385,7 @@ unmarshall_float(float *val, const char *buf, unsigned int buflen) return 0; } -int +int unmarshall_double(double *val, const char *buf, unsigned int buflen) { if (!val || !buf || sizeof(double) != (2*sizeof(u_int32_t))) @@ -414,9 +414,9 @@ unmarshall_double(double *val, const char *buf, unsigned int buflen) } int -unmarshall_buffer(char *val, - unsigned int vallen, - const char *buf, +unmarshall_buffer(char *val, + unsigned int vallen, + const char *buf, unsigned int buflen) { if (!val || !buf) diff --git a/src/libs/common/marshall.h b/src/libs/common/marshall.h index c95117f0..582f12da 100644 --- a/src/libs/common/marshall.h +++ b/src/libs/common/marshall.h @@ -24,7 +24,7 @@ * You should have received a copy of the GNU General Public License along * with Cerebro. If not, see . \*****************************************************************************/ - + #ifndef _MARSHALL_H #define _MARSHALL_H @@ -118,9 +118,9 @@ int marshall_double(double val, char *buf, unsigned int buflen); * Returns length of data copied into buffer, 0 if not enough buffer * space available, -1 on error */ -int marshall_buffer(const char *val, - unsigned int vallen, - char *buf, +int marshall_buffer(const char *val, + unsigned int vallen, + char *buf, unsigned int buflen); /* @@ -211,9 +211,9 @@ int unmarshall_double(double *val, const char *buf, unsigned int buflen); * Returns length of data unmarshalled from buffer, 0 if buffer does * not contain enough data, -1 on error */ -int unmarshall_buffer(char *val, - unsigned int vallen, - const char *buf, +int unmarshall_buffer(char *val, + unsigned int vallen, + const char *buf, unsigned int buflen); #endif /* _MARSHALL_H */ diff --git a/src/libs/common/vector.c b/src/libs/common/vector.c index 98b8ff89..3bad017e 100644 --- a/src/libs/common/vector.c +++ b/src/libs/common/vector.c @@ -27,7 +27,7 @@ * Copyright (C) 2001-2002 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Chris Dunlap . - * + * * This file is from LSD-Tools, the LLNL Software Development Toolbox. * * LSD-Tools is free software; you can redistribute it and/or modify it under @@ -116,7 +116,7 @@ struct vector { unsigned int length; /* length of current data array */ void **data; /* data array */ #ifdef WITH_PTHREADS - pthread_mutex_t mutex; + pthread_mutex_t mutex; #endif /* WITH_PTHREADS */ #ifndef NDEBUG int32_t magic; /* magic number */ @@ -217,10 +217,10 @@ _alloc_data (Vector v, unsigned int length_increase) errno = ENOMEM; return lsd_nomem_error(__FILE__, __LINE__, "data create"); } - + for (i = v->length; i < (v->length + length_increase); i++) ptr[i] = NULL; - + v->data = ptr; v->length += length_increase; @@ -274,7 +274,7 @@ vector_create (VectorDelF f) v->data = NULL; vector_mutex_init(&(v->mutex)); assert(v->magic = VECTOR_MAGIC); /* set magic via assert abuse */ - + return v; } @@ -284,7 +284,7 @@ vector_destroy (Vector v) assert(v); vector_mutex_lock(&v->mutex); assert(v->magic == VECTOR_MAGIC); - + (void)_clear_data(v); assert(v->magic = ~VECTOR_MAGIC); /* clear magic via assert abuse */ @@ -364,7 +364,7 @@ vector_set (Vector v, void *x, unsigned int index) vector_mutex_lock(&v->mutex); assert(v->magic == VECTOR_MAGIC); - if (index < v->length) + if (index < v->length) { if (v->data[index]) { @@ -471,7 +471,7 @@ vector_for_each (Vector v, VectorForF f, void *arg) { if (v->data[i]) { - if (f(v->data[i], arg, i) < 0) + if (f(v->data[i], arg, i) < 0) { rv = -1; break; @@ -507,7 +507,7 @@ vector_to_array (Vector v, void *p[], unsigned int len) p[i] = v->data[i]; rv++; } - + cleanup: vector_mutex_unlock(&v->mutex); return(rv); @@ -571,7 +571,7 @@ vector_next (VectorIterator i) if (i->current < i->v->length) { /* Skip any elements that are NULL */ - while ((!(i->v->data[i->current])) + while ((!(i->v->data[i->current])) && i->current < i->v->length) i->current++; diff --git a/src/libs/common/vector.h b/src/libs/common/vector.h index 021bf57d..243b37a2 100644 --- a/src/libs/common/vector.h +++ b/src/libs/common/vector.h @@ -27,7 +27,7 @@ * Copyright (C) 2001-2002 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Chris Dunlap . - * + * * This file is from LSD-Tools, the LLNL Software Development Toolbox. * * LSD-Tools is free software; you can redistribute it and/or modify it under @@ -50,10 +50,10 @@ #define LSD_VECTOR_H /* Notes: - * + * * API emulates Chris Dunlap's (dunlap6 at llnl dot gov) List library. * Lots of code was copied. - * + * * If NDEBUG is not defined, internal debug code will be enabled. This is * intended for development use only and production code should define NDEBUG. * @@ -150,7 +150,7 @@ int vector_count (Vector v); * Vector Manipulation * ***************************/ -/* +/* * vector_append * * Append an item to the end of the vector, growing the vector @@ -160,7 +160,7 @@ int vector_count (Vector v); */ void *vector_append (Vector v, void *x); -/* +/* * vector_set * * Set an item to a specific index location. To clear one item out of @@ -170,7 +170,7 @@ void *vector_append (Vector v, void *x); */ void *vector_set(Vector v, void *x, unsigned int index); -/* +/* * vector_clear * * Remove all data in the vector. @@ -183,14 +183,14 @@ int vector_clear(Vector v); * Vector Access * ***************************/ -/* +/* * vector_get * * Return data stored at an index, NULL if item not set */ void *vector_get(Vector v, unsigned int index); -/* +/* * vector_find_first * * Returns the index to the first item that the specified @@ -198,7 +198,7 @@ void *vector_get(Vector v, unsigned int index); */ int vector_find_first (Vector v, VectorFindF f, void *key); -/* +/* * vector_for_each * * Operate on each data element of the vector that is set. @@ -207,7 +207,7 @@ int vector_find_first (Vector v, VectorFindF f, void *key); */ int vector_for_each (Vector v, VectorForF f, void *arg); -/* +/* * vector_to_array * * Copy vector pointers to the supplied array. @@ -220,7 +220,7 @@ int vector_to_array (Vector v, void *p[], unsigned int len); * Vector Iterator Functions * *****************************/ -/* +/* * vector_iterator_create * * Create a vector iterator @@ -229,21 +229,21 @@ int vector_to_array (Vector v, void *p[], unsigned int len); */ VectorIterator vector_iterator_create (Vector v); -/* +/* * vector_iterator_reset * * Resets the iterator */ void vector_iterator_reset (VectorIterator i); -/* +/* * vector_iterator_destroy * * Destroy the vector iteratory */ void vector_iterator_destroy (VectorIterator i); -/* +/* * vector_next * * Returns a pointer to the next item's data, NULL at the end of the diff --git a/src/libs/debug/debug.h b/src/libs/debug/debug.h index 283de9b3..20a6c09e 100644 --- a/src/libs/debug/debug.h +++ b/src/libs/debug/debug.h @@ -94,7 +94,7 @@ char *debug_msg_create(const char *fmt, ...); CEREBRO_MSG_CREATE(msg) \ cerebro_err_exit(errbuf); \ } while(0) - + #else /* !CEREBRO_DEBUG */ #define CEREBRO_DBG(msg) diff --git a/src/libs/include/cerebro.h b/src/libs/include/cerebro.h index b9a1b02d..89300768 100644 --- a/src/libs/include/cerebro.h +++ b/src/libs/include/cerebro.h @@ -28,7 +28,7 @@ #ifndef _CEREBRO_H #define _CEREBRO_H -/* +/* * Cerebro Error Codes */ #define CEREBRO_ERR_SUCCESS 0 @@ -41,9 +41,9 @@ #define CEREBRO_ERR_PARAMETERS 7 #define CEREBRO_ERR_HOSTNAME 8 #define CEREBRO_ERR_CONNECT 9 -#define CEREBRO_ERR_CONNECT_TIMEOUT 10 +#define CEREBRO_ERR_CONNECT_TIMEOUT 10 #define CEREBRO_ERR_PROTOCOL 11 -#define CEREBRO_ERR_PROTOCOL_TIMEOUT 12 +#define CEREBRO_ERR_PROTOCOL_TIMEOUT 12 #define CEREBRO_ERR_VERSION_INCOMPATIBLE 13 #define CEREBRO_ERR_OVERFLOW 14 #define CEREBRO_ERR_NODE_NOTFOUND 15 @@ -59,7 +59,7 @@ #define CEREBRO_ERR_INTERNAL 25 #define CEREBRO_ERR_ERRNUMRANGE 26 -/* +/* * Cerebro Flags */ @@ -69,7 +69,7 @@ #define CEREBRO_METRIC_CONTROL_FLAGS_SEND_NOW 0x00000008 #define CEREBRO_METRIC_FLAGS_MASK 0x0000000F -/* +/* * Cerebro Data Value Types */ #define CEREBRO_DATA_VALUE_TYPE_NONE 0 @@ -81,7 +81,7 @@ #define CEREBRO_DATA_VALUE_TYPE_INT64 6 #define CEREBRO_DATA_VALUE_TYPE_U_INT64 7 -/* +/* * Default metrics */ #define CEREBRO_METRIC_METRIC_NAMES "metric_names" @@ -91,12 +91,12 @@ #define CEREBRO_METRIC_UPDOWN_STATE_NODE_UP 1 #define CEREBRO_METRIC_UPDOWN_STATE_NODE_DOWN 0 -/* +/* * Default events */ #define CEREBRO_EVENT_NAMES "event_names" -/* +/* * Server defaults */ #define CEREBRO_METRIC_SERVER_PORT 8852 @@ -190,31 +190,31 @@ int cerebro_nodelist_iterator_errnum(cerebro_nodelist_iterator_t nodelistItr); */ char *cerebro_strerror(int errnum); -/* - * Parameter Get/Set Routines +/* + * Parameter Get/Set Routines */ -/* +/* * cerebro_get_hostname * * Get a string pointer to the currently set hostname of the cerebrod * server. The string returned may be the empty string, indicating no * hostname has been set. - * + * * Returns pointer on success, NULL on error */ char *cerebro_get_hostname(cerebro_t handle); -/* +/* * cerebro_set_hostname * * Set the hostname of the cerebrod server - * + * * Returns 0 on success, -1 on error */ int cerebro_set_hostname(cerebro_t handle, const char *hostname); -/* +/* * cerebro_get_port * * Get the currently set cerebrod server port. The port may be 0, @@ -224,7 +224,7 @@ int cerebro_set_hostname(cerebro_t handle, const char *hostname); */ int cerebro_get_port(cerebro_t handle); -/* +/* * cerebro_set_port * * Set the cerebrod server port to connect to @@ -233,7 +233,7 @@ int cerebro_get_port(cerebro_t handle); */ int cerebro_set_port(cerebro_t handle, unsigned int port); -/* +/* * cerebro_get_timeout_len * * Get the currently set timeout_len. The timeout_len may be 0, @@ -243,7 +243,7 @@ int cerebro_set_port(cerebro_t handle, unsigned int port); */ int cerebro_get_timeout_len(cerebro_t handle); -/* +/* * cerebro_set_timeout_len * * Set the cerebrod server timeout_len for up vs. down calculation @@ -252,7 +252,7 @@ int cerebro_get_timeout_len(cerebro_t handle); */ int cerebro_set_timeout_len(cerebro_t handle, unsigned int timeout_len); -/* +/* * cerebro_get_flags * * Get the currently set flags. The flags may be 0, indicating no @@ -262,7 +262,7 @@ int cerebro_set_timeout_len(cerebro_t handle, unsigned int timeout_len); */ int cerebro_get_flags(cerebro_t handle); -/* +/* * cerebro_set_flags * * Set the cerebrod server flags to use @@ -271,11 +271,11 @@ int cerebro_get_flags(cerebro_t handle); */ int cerebro_set_flags(cerebro_t handle, unsigned int flags); -/* +/* * Event Retrieval API */ -/* +/* * cerebro_get_event_names * * Get a namelist of currently available events @@ -284,7 +284,7 @@ int cerebro_set_flags(cerebro_t handle, unsigned int flags); */ cerebro_namelist_t cerebro_get_event_names(cerebro_t handle); -/* +/* * cerebro_event_register * * Setup a file descriptor for event polling. @@ -293,7 +293,7 @@ cerebro_namelist_t cerebro_get_event_names(cerebro_t handle); */ int cerebro_event_register(cerebro_t handle, const char *event_name); -/* +/* * cerebro_event_unregister * * Tear down event file descriptor @@ -302,7 +302,7 @@ int cerebro_event_register(cerebro_t handle, const char *event_name); */ int cerebro_event_unregister(cerebro_t handle, int fd); -/* +/* * cerebro_event_parse * * Parse event data when there is data to read on the file descriptor. @@ -317,11 +317,11 @@ int cerebro_event_parse(cerebro_t handle, unsigned int *event_value_len, void **event_value); -/* +/* * Metric Retrieval API */ -/* +/* * cerebro_get_metric_names * * Get a namelist of currently available metrics @@ -330,7 +330,7 @@ int cerebro_event_parse(cerebro_t handle, */ cerebro_namelist_t cerebro_get_metric_names(cerebro_t handle); -/* +/* * cerebro_get_metric_data * * Get nodelist of nodes and values for a certain metric @@ -340,11 +340,11 @@ cerebro_namelist_t cerebro_get_metric_names(cerebro_t handle); cerebro_nodelist_t cerebro_get_metric_data(cerebro_t handle, const char *metric_name); -/* +/* * Metric Monitoring API */ -/* +/* * cerebro_register_metric * * Register a new metric with the local cerebro daemon @@ -353,7 +353,7 @@ cerebro_nodelist_t cerebro_get_metric_data(cerebro_t handle, */ int cerebro_register_metric(cerebro_t handle, const char *metric_name); -/* +/* * cerebro_unregister_metric * * Unregister a metric with the local cerebro daemon @@ -362,7 +362,7 @@ int cerebro_register_metric(cerebro_t handle, const char *metric_name); */ int cerebro_unregister_metric(cerebro_t handle, const char *metric_name); -/* +/* * cerebro_update_metric_value * * Update the value of a metric on the local cerebro daemon @@ -375,7 +375,7 @@ int cerebro_update_metric_value(cerebro_t handle, unsigned int metric_value_len, void *metric_value); -/* +/* * cerebro_resend_metric * * Resend a metric @@ -384,7 +384,7 @@ int cerebro_update_metric_value(cerebro_t handle, */ int cerebro_resend_metric(cerebro_t handle, const char *metric_name); -/* +/* * cerebro_flush_metric * * Flush a metric @@ -393,12 +393,12 @@ int cerebro_resend_metric(cerebro_t handle, const char *metric_name); */ int cerebro_flush_metric(cerebro_t handle, const char *metric_name); -/* +/* * Namelist API * */ -/* +/* * cerebro_namelist_length * * Determine the length of the namelist. @@ -407,7 +407,7 @@ int cerebro_flush_metric(cerebro_t handle, const char *metric_name); */ int cerebro_namelist_length(cerebro_namelist_t namelist); -/* +/* * cerebro_namelist_destroy * * Destroy a namelist @@ -416,7 +416,7 @@ int cerebro_namelist_length(cerebro_namelist_t namelist); */ int cerebro_namelist_destroy(cerebro_namelist_t namelist); -/* +/* * cerebro_namelist_iterator_create * * Create a namelist iterator @@ -425,14 +425,14 @@ int cerebro_namelist_destroy(cerebro_namelist_t namelist); */ cerebro_namelist_iterator_t cerebro_namelist_iterator_create(cerebro_namelist_t namelist); -/* +/* * cerebro_namelist_iterator_name * * Retrieve a pointer to the current name * * Returns 0 on success, -1 on error */ -int cerebro_namelist_iterator_name(cerebro_namelist_iterator_t namelistItr, +int cerebro_namelist_iterator_name(cerebro_namelist_iterator_t namelistItr, char **name); /* @@ -445,16 +445,16 @@ int cerebro_namelist_iterator_name(cerebro_namelist_iterator_t namelistItr, */ int cerebro_namelist_iterator_next(cerebro_namelist_iterator_t namelistItr); -/* +/* * cerebro_namelist_iterator_reset * * Reset the namelist iterator to the beginning. - * + * * Returns 0 on success, -1 on error */ int cerebro_namelist_iterator_reset(cerebro_namelist_iterator_t namelistItr); -/* +/* * cerebro_namelist_iterator_at_end * * Returns 1 if the end of the list has been reached, 0 if not, -1 on @@ -462,19 +462,19 @@ int cerebro_namelist_iterator_reset(cerebro_namelist_iterator_t namelistItr); */ int cerebro_namelist_iterator_at_end(cerebro_namelist_iterator_t namelistItr); -/* +/* * cerebro_namelist_iterator_destroy * * Returns 0 on success, -1 on error */ int cerebro_namelist_iterator_destroy(cerebro_namelist_iterator_t namelistItr); -/* +/* * Nodelist API * */ -/* +/* * cerebro_nodelist_metric_name * * Determine the name of the data stored in the nodelist @@ -483,7 +483,7 @@ int cerebro_namelist_iterator_destroy(cerebro_namelist_iterator_t namelistItr); */ char *cerebro_nodelist_metric_name(cerebro_nodelist_t nodelist); -/* +/* * cerebro_nodelist_length * * Determine the length of the nodelist. @@ -492,7 +492,7 @@ char *cerebro_nodelist_metric_name(cerebro_nodelist_t nodelist); */ int cerebro_nodelist_length(cerebro_nodelist_t nodelist); -/* +/* * cerebro_nodelist_destroy * * Destroy a nodelist @@ -501,7 +501,7 @@ int cerebro_nodelist_length(cerebro_nodelist_t nodelist); */ int cerebro_nodelist_destroy(cerebro_nodelist_t nodelist); -/* +/* * cerebro_nodelist_iterator_create * * Create a nodelist iterator @@ -510,17 +510,17 @@ int cerebro_nodelist_destroy(cerebro_nodelist_t nodelist); */ cerebro_nodelist_iterator_t cerebro_nodelist_iterator_create(cerebro_nodelist_t nodelist); -/* +/* * cerebro_nodelist_iterator_nodename * * Retrieve a pointer to the current nodename * * Returns 0 on success, -1 on error */ -int cerebro_nodelist_iterator_nodename(cerebro_nodelist_iterator_t nodelistItr, +int cerebro_nodelist_iterator_nodename(cerebro_nodelist_iterator_t nodelistItr, char **nodename); -/* +/* * cerebro_nodelist_iterator_metric_value * * If a value exists for the current point in the list, the metric @@ -535,7 +535,7 @@ int cerebro_nodelist_iterator_metric_value(cerebro_nodelist_iterator_t nodelistI unsigned int *metric_value_len, void **metric_value); -/* +/* * cerebro_nodelist_iterator_next * * Move the iterator pointer forward @@ -545,16 +545,16 @@ int cerebro_nodelist_iterator_metric_value(cerebro_nodelist_iterator_t nodelistI */ int cerebro_nodelist_iterator_next(cerebro_nodelist_iterator_t nodelistItr); -/* +/* * cerebro_nodelist_iterator_reset * * Reset the nodelist iterator to the beginning. - * + * * Returns 0 on success, -1 on error */ int cerebro_nodelist_iterator_reset(cerebro_nodelist_iterator_t nodelistItr); -/* +/* * cerebro_nodelist_iterator_at_end * * Returns 1 if the end of the list has been reached, 0 if not, -1 on @@ -562,7 +562,7 @@ int cerebro_nodelist_iterator_reset(cerebro_nodelist_iterator_t nodelistItr); */ int cerebro_nodelist_iterator_at_end(cerebro_nodelist_iterator_t nodelistItr); -/* +/* * cerebro_nodelist_iterator_destroy * * Returns 0 on success, -1 on error diff --git a/src/libs/include/cerebro/cerebro_clusterlist_module.h b/src/libs/include/cerebro/cerebro_clusterlist_module.h index 1f03c6eb..6a037f29 100644 --- a/src/libs/include/cerebro/cerebro_clusterlist_module.h +++ b/src/libs/include/cerebro/cerebro_clusterlist_module.h @@ -30,7 +30,7 @@ #define CEREBRO_CLUSTERLIST_INTERFACE_VERSION 1 -/* +/* * Cerebro_clusterlist_interface_version * * function prototype for clusterlist module function to return the @@ -76,9 +76,9 @@ typedef int (*Cerebro_clusterlist_numnodes)(void); * Cerebro_clusterlist_get_all_nodes * * function prototype for clusterlist module function to get all - * cluster nodes. Caller is responsible for freeing the created + * cluster nodes. Caller is responsible for freeing the created * char ** array of nodes. The returned array of strings will - * be NULL terminated. Required to be defined by each clusterlist + * be NULL terminated. Required to be defined by each clusterlist * module. * * - nodes - pointer to return char ** array of nodes @@ -117,11 +117,11 @@ typedef int (*Cerebro_clusterlist_node_in_cluster)(const char *node); * * Returns nodename in buffer, 0 on success, -1 on error */ -typedef int (*Cerebro_clusterlist_get_nodename)(const char *node, - char *buf, +typedef int (*Cerebro_clusterlist_get_nodename)(const char *node, + char *buf, unsigned int buflen); - -/* + +/* * struct cerebro_clusterlist_module_info * * contains clusterlist module information and operations. Required diff --git a/src/libs/include/cerebro/cerebro_config.h b/src/libs/include/cerebro/cerebro_config.h index 0b7e1973..831b9290 100644 --- a/src/libs/include/cerebro/cerebro_config.h +++ b/src/libs/include/cerebro/cerebro_config.h @@ -83,14 +83,14 @@ struct cerebrod_config_forward_message_config { unsigned int host_len; }; -/* +/* * struct cerebro_config * * Stores configuration info from config file. */ struct cerebro_config { - /* + /* * Libcerebro configuration */ struct cerebro_config_server cerebro_metric_server[CEREBRO_CONFIG_CEREBRO_METRIC_SERVERS_MAX]; @@ -104,7 +104,7 @@ struct cerebro_config int cerebro_flags; int cerebro_flags_flag; - /* + /* * Cerebrod configuration */ unsigned int cerebrod_heartbeat_frequency_min; diff --git a/src/libs/include/cerebro/cerebro_config_module.h b/src/libs/include/cerebro/cerebro_config_module.h index 4a9ab3eb..86e335d7 100644 --- a/src/libs/include/cerebro/cerebro_config_module.h +++ b/src/libs/include/cerebro/cerebro_config_module.h @@ -32,7 +32,7 @@ #define CEREBRO_CONFIG_INTERFACE_VERSION 1 -/* +/* * Cerebro_config_interface_version * * function prototype for config module function to return the @@ -75,8 +75,8 @@ typedef int (*Cerebro_config_cleanup)(void); typedef int (*Cerebro_config_load_config)(struct cerebro_config *conf); /* - * struct cerebro_config_module_info - * + * struct cerebro_config_module_info + * * contains config module information and operations. Required to be * defined in each config module. */ diff --git a/src/libs/include/cerebro/cerebro_constants.h b/src/libs/include/cerebro/cerebro_constants.h index 2f770dc2..9fcb7ebb 100644 --- a/src/libs/include/cerebro/cerebro_constants.h +++ b/src/libs/include/cerebro/cerebro_constants.h @@ -24,7 +24,7 @@ * You should have received a copy of the GNU General Public License along * with Cerebro. If not, see . \*****************************************************************************/ - + #ifndef _CEREBRO_CONSTANTS_H #define _CEREBRO_CONSTANTS_H @@ -33,7 +33,7 @@ * definition for MAXHOSTNAMELEN. We define our own maximum nodename * length. */ -#define CEREBRO_MAX_NODENAME_LEN 64 +#define CEREBRO_MAX_NODENAME_LEN 64 #define CEREBRO_MAX_HOSTNAME_LEN CEREBRO_MAX_NODENAME_LEN #define CEREBRO_MAX_PATH_LEN 512 diff --git a/src/libs/include/cerebro/cerebro_error.h b/src/libs/include/cerebro/cerebro_error.h index 92dcfce1..c8dc23c5 100644 --- a/src/libs/include/cerebro/cerebro_error.h +++ b/src/libs/include/cerebro/cerebro_error.h @@ -32,7 +32,7 @@ #define CEREBRO_ERROR_STDERR 0x0002 #define CEREBRO_ERROR_SYSLOG 0x0004 -/* +/* * cerebro_err_init * * Initializes cerebro error lib @@ -46,28 +46,28 @@ void cerebro_err_init(char *prog); */ int cerebro_err_get_flags(void); -/* +/* * cerebro_err_set_flags * * Sets the error lib flags to 'flags'. */ void cerebro_err_set_flags(int flags); -/* +/* * cerebro_err_debug * - * Outputs error debugging. + * Outputs error debugging. */ void cerebro_err_debug(const char *fmt, ...); -/* +/* * cerebro_err_output * - * Calls error output. + * Calls error output. */ void cerebro_err_output(const char *fmt, ...); -/* +/* * cerebro_err_exit * * Outputs error and exits diff --git a/src/libs/include/cerebro/cerebro_event_module.h b/src/libs/include/cerebro/cerebro_event_module.h index f30acfb2..8ec7f1e4 100644 --- a/src/libs/include/cerebro/cerebro_event_module.h +++ b/src/libs/include/cerebro/cerebro_event_module.h @@ -32,7 +32,7 @@ #define CEREBRO_EVENT_INTERFACE_VERSION 1 -/* +/* * Cerebro_event_interface_version * * function prototype for event module function to return the @@ -123,7 +123,7 @@ typedef int (*Cerebro_event_metric_update)(const char *nodename, void *metric_value, struct cerebro_event **event); -/* +/* * Cerebro_event_destroy * * function prototype for event module to destroy an event generated @@ -133,8 +133,8 @@ typedef int (*Cerebro_event_metric_update)(const char *nodename, typedef void (*Cerebro_event_destroy)(struct cerebro_event *event); /* - * struct cerebro_event_module_info - * + * struct cerebro_event_module_info + * * contains event module information and operations. Required to be * defined in each event module. */ diff --git a/src/libs/include/cerebro/cerebro_event_protocol.h b/src/libs/include/cerebro/cerebro_event_protocol.h index 184ea4b0..089a4705 100644 --- a/src/libs/include/cerebro/cerebro_event_protocol.h +++ b/src/libs/include/cerebro/cerebro_event_protocol.h @@ -52,7 +52,7 @@ * response will be sent even if no event names exist. * * Client -> Server - * - Client can close the connection at any time by closing the + * - Client can close the connection at any time by closing the * TCP connection. * * Notes: @@ -110,12 +110,12 @@ struct cerebro_event_server_response + sizeof(u_int8_t) \ + CEREBRO_MAX_EVENT_NAME_LEN) -/* +/* * struct cerebro_event * * defines an event that can be returned to listeners */ -struct cerebro_event +struct cerebro_event { int32_t version; u_int32_t err_code; diff --git a/src/libs/include/cerebro/cerebro_metric_control_protocol.h.in b/src/libs/include/cerebro/cerebro_metric_control_protocol.h.in index 5fe501f2..232a7049 100644 --- a/src/libs/include/cerebro/cerebro_metric_control_protocol.h.in +++ b/src/libs/include/cerebro/cerebro_metric_control_protocol.h.in @@ -35,7 +35,7 @@ * * Client -> Server * - Metric request. - * + * * Server -> Client * - Metric response. * @@ -43,7 +43,7 @@ #define CEREBRO_METRIC_CONTROL_PROTOCOL_VERSION 2 -/* +/* * Even though the controller protocol is through a local unix domain * socket, we'll still need timeouts to ensure the user isn't being an * idiot and not sending data. @@ -83,7 +83,7 @@ struct cerebro_metric_control_request { int32_t version; int32_t command; - u_int32_t flags; + u_int32_t flags; char metric_name[CEREBRO_MAX_METRIC_NAME_LEN]; u_int32_t metric_value_type; u_int32_t metric_value_len; @@ -107,7 +107,7 @@ struct cerebro_metric_control_response int32_t version; u_int32_t err_code; }; - + #define CEREBRO_METRIC_CONTROL_RESPONSE_LEN (sizeof(int32_t) \ + sizeof(u_int32_t)) diff --git a/src/libs/include/cerebro/cerebro_metric_module.h b/src/libs/include/cerebro/cerebro_metric_module.h index a3c6e5c1..eabfa7a9 100644 --- a/src/libs/include/cerebro/cerebro_metric_module.h +++ b/src/libs/include/cerebro/cerebro_metric_module.h @@ -35,7 +35,7 @@ #define CEREBRO_METRIC_MODULE_FLAGS_SEND_ON_PERIOD 0x1 -/* +/* * Cerebro_metric_interface_version * * function prototype for metric module function to return the @@ -66,7 +66,7 @@ typedef int (*Cerebro_metric_setup)(void); */ typedef int (*Cerebro_metric_cleanup)(void); -/* +/* * Cerebro_metric_get_metric_name * * Returns the name of the metric metriced by this module Required to @@ -76,7 +76,7 @@ typedef int (*Cerebro_metric_cleanup)(void); */ typedef char *(*Cerebro_metric_get_metric_name)(void); -/* +/* * Cerebro_metric_get_metric_period * * Retrieve the period in seconds that the metric value should be read @@ -94,12 +94,12 @@ typedef char *(*Cerebro_metric_get_metric_name)(void); */ typedef int (*Cerebro_metric_get_metric_period)(int *period); -/* +/* * Cerebro_metric_get_metric_flags * * function prototype for metric module function to indicate the flags * it supports. Required to be defined by each metric module. - * + * * Returns 0 on success, -1 on error */ typedef int (*Cerebro_metric_get_metric_flags)(u_int32_t *flags); @@ -126,14 +126,14 @@ typedef int (*Cerebro_metric_get_metric_value)(unsigned int *metric_value_type, */ typedef int (*Cerebro_metric_destroy_metric_value)(void *metric_value); -/* +/* * Cerebro_metric_thread_pointer * * function prototype for a thread which will be passed to * pthread_create * * This thread can perform any metric monitoring duties it pleases and - * call the send message function (see Cerebro_metric_send_message below) + * call the send message function (see Cerebro_metric_send_message below) * to send data when its data has been updated. * * Typically the thread is used to watch or monitor for some event and @@ -154,7 +154,7 @@ typedef void *(*Cerebro_metric_thread_pointer)(void *arg); */ typedef Cerebro_metric_thread_pointer (*Cerebro_metric_get_metric_thread)(void); -/* Cerebro_metric_send_message +/* Cerebro_metric_send_message * * function prototype to inform the cerebrod daemon to send * a message. @@ -163,7 +163,7 @@ typedef Cerebro_metric_thread_pointer (*Cerebro_metric_get_metric_thread)(void); */ typedef int (*Cerebro_metric_send_message)(struct cerebrod_message *hb); -/* +/* * Cerebro_metric_send_message_function_pointer * * function prototype to give a Cerebro_metric_send_message function @@ -174,8 +174,8 @@ typedef int (*Cerebro_metric_send_message)(struct cerebrod_message *hb); typedef int (*Cerebro_metric_send_message_function_pointer)(Cerebro_metric_send_message function_pointer); /* - * struct cerebro_metric_module_info - * + * struct cerebro_metric_module_info + * * contains metric module information and operations. Required to be * defined in each metric module. */ @@ -191,7 +191,7 @@ struct cerebro_metric_module_info Cerebro_metric_get_metric_value get_metric_value; Cerebro_metric_destroy_metric_value destroy_metric_value; Cerebro_metric_get_metric_thread get_metric_thread; - Cerebro_metric_send_message_function_pointer send_message_function_pointer; + Cerebro_metric_send_message_function_pointer send_message_function_pointer; }; #endif /* _CEREBRO_METRIC_MODULE_H */ diff --git a/src/libs/include/cerebro/cerebro_metric_server_protocol.h b/src/libs/include/cerebro/cerebro_metric_server_protocol.h index c8d6afb3..15e23760 100644 --- a/src/libs/include/cerebro/cerebro_metric_server_protocol.h +++ b/src/libs/include/cerebro/cerebro_metric_server_protocol.h @@ -35,7 +35,7 @@ * * Client -> Server * - Metric request. - * + * * Server -> Client * - Stream of responses indicating metric_names or nodenames and * metric values. Responses may depend on the request flags. Metric @@ -50,7 +50,7 @@ * - On errors, an error packet will contain the error code. * * Notes: - * - Require a smaller timeout len for the server than the client, + * - Require a smaller timeout len for the server than the client, * so the server can respond to the client with a meaningful error * message. */ @@ -82,7 +82,7 @@ struct cerebro_metric_server_request u_int32_t timeout_len; u_int32_t flags; }; - + #define CEREBRO_METRIC_SERVER_REQUEST_PACKET_LEN (sizeof(int32_t) \ + CEREBRO_MAX_METRIC_NAME_LEN \ + sizeof(u_int32_t) \ @@ -105,7 +105,7 @@ struct cerebro_metric_server_response u_int32_t metric_value_len; void *metric_value; }; - + #define CEREBRO_METRIC_SERVER_RESPONSE_HEADER_LEN (sizeof(int32_t) \ + sizeof(u_int32_t) \ + sizeof(u_int8_t) \ @@ -124,7 +124,7 @@ struct cerebro_metric_server_err_response int32_t version; u_int32_t err_code; }; - + #define CEREBRO_METRIC_SERVER_ERR_RESPONSE_LEN (sizeof(int32_t) \ + sizeof(u_int32_t)) diff --git a/src/libs/include/cerebro/cerebro_monitor_module.h b/src/libs/include/cerebro/cerebro_monitor_module.h index 7bc7107c..03300db0 100644 --- a/src/libs/include/cerebro/cerebro_monitor_module.h +++ b/src/libs/include/cerebro/cerebro_monitor_module.h @@ -30,7 +30,7 @@ #define CEREBRO_MONITOR_INTERFACE_VERSION 1 -/* +/* * Cerebro_monitor_interface_version * * function prototype for monitor module function to return the @@ -87,8 +87,8 @@ typedef int (*Cerebro_monitor_metric_update)(const char *nodename, void *metric_value); /* - * struct cerebro_monitor_module_info - * + * struct cerebro_monitor_module_info + * * contains monitor module information and operations. Required to be * defined in each monitor module. */ diff --git a/src/libs/include/cerebro/cerebrod_message_protocol.h b/src/libs/include/cerebro/cerebrod_message_protocol.h index 00334f6d..4ee1fba7 100644 --- a/src/libs/include/cerebro/cerebrod_message_protocol.h +++ b/src/libs/include/cerebro/cerebrod_message_protocol.h @@ -51,12 +51,12 @@ struct cerebrod_message_metric + sizeof(u_int32_t) \ + sizeof(u_int32_t)) -/* +/* * struct cerebrod_message * * defines message data sent/received from each cerebrod daemon */ -struct cerebrod_message +struct cerebrod_message { int32_t version; char nodename[CEREBRO_MAX_NODENAME_LEN]; diff --git a/src/libs/modules/clusterlist_module.c b/src/libs/modules/clusterlist_module.c index f268a9e4..dae697b8 100644 --- a/src/libs/modules/clusterlist_module.c +++ b/src/libs/modules/clusterlist_module.c @@ -103,7 +103,7 @@ char *clusterlist_modules[] = { #define CLUSTERLIST_MODULE_MAX 1 #define CLUSTERLIST_MODULE_MAGIC_NUMBER 0x33882200 -/* +/* * struct clusterlist_module * * clusterlist module handle @@ -117,7 +117,7 @@ struct clusterlist_module struct cerebro_clusterlist_module_info *module_info; }; -/* +/* * _clusterlist_module_cb * * Check and store module @@ -152,7 +152,7 @@ _clusterlist_module_cb(void *handle, void *dl_handle, void *module_info) clusterlist_dl_handle = dl_handle; #endif /* !WITH_STATIC_MODULES */ clusterlist_module_info = module_info; - + if (clusterlist_handle->magic != CLUSTERLIST_MODULE_MAGIC_NUMBER) { CEREBRO_DBG(("invalid handle")); @@ -185,12 +185,12 @@ _clusterlist_module_cb(void *handle, void *dl_handle, void *module_info) return 1; } -clusterlist_module_t +clusterlist_module_t clusterlist_module_load(void) { struct clusterlist_module *handle = NULL; int rv; - + if (module_setup() < 0) return NULL; @@ -201,7 +201,7 @@ clusterlist_module_load(void) } memset(handle, '\0', sizeof(struct clusterlist_module)); handle->magic = CLUSTERLIST_MODULE_MAGIC_NUMBER; - + #if WITH_STATIC_MODULES if ((rv = find_and_load_modules(clusterlist_modules, _clusterlist_module_cb, @@ -218,7 +218,7 @@ clusterlist_module_load(void) CLUSTERLIST_MODULE_MAX)) < 0) goto cleanup; #endif /* !WITH_STATIC_MODULES */ - + if (rv) goto out; @@ -246,7 +246,7 @@ clusterlist_module_load(void) return NULL; } -/* +/* * _handle_check * * Check for proper clusterlist module handle @@ -331,7 +331,7 @@ clusterlist_module_interface_version(clusterlist_module_t handle) { if (_handle_info_check(handle) < 0) return -1; - + return ((*(handle->module_info)->interface_version)()); } @@ -340,7 +340,7 @@ clusterlist_module_setup(clusterlist_module_t handle) { if (_handle_info_check(handle) < 0) return -1; - + return ((*(handle->module_info)->setup)()); } @@ -349,7 +349,7 @@ clusterlist_module_cleanup(clusterlist_module_t handle) { if (_handle_info_check(handle) < 0) return -1; - + return ((*(handle->module_info)->cleanup)()); } @@ -358,7 +358,7 @@ clusterlist_module_numnodes(clusterlist_module_t handle) { if (_handle_info_check(handle) < 0) return -1; - + return ((*(handle->module_info)->numnodes)()); } @@ -367,7 +367,7 @@ clusterlist_module_get_all_nodes(clusterlist_module_t handle, char ***nodes) { if (_handle_info_check(handle) < 0) return -1; - + return ((*(handle->module_info)->get_all_nodes)(nodes)); } @@ -376,18 +376,18 @@ clusterlist_module_node_in_cluster(clusterlist_module_t handle, const char *node { if (_handle_info_check(handle) < 0) return -1; - + return ((*(handle->module_info)->node_in_cluster)(node)); } int clusterlist_module_get_nodename(clusterlist_module_t handle, - const char *node, - char *buf, + const char *node, + char *buf, unsigned int buflen) { if (_handle_info_check(handle) < 0) return -1; - + return ((*(handle->module_info)->get_nodename)(node, buf, buflen)); } diff --git a/src/libs/modules/clusterlist_module.h b/src/libs/modules/clusterlist_module.h index c0cf13b0..7ba56e76 100644 --- a/src/libs/modules/clusterlist_module.h +++ b/src/libs/modules/clusterlist_module.h @@ -35,7 +35,7 @@ typedef struct clusterlist_module *clusterlist_module_t; * * Find and load the clusterlist module. If none is found, will * assume a default clusterlist module. - * + * * Returns clusterlist module handle on success, NULL on error */ clusterlist_module_t clusterlist_module_load(void); @@ -103,7 +103,7 @@ int clusterlist_module_get_all_nodes(clusterlist_module_t handle, char ***nodes) * * call clusterlist module node in cluster function */ -int clusterlist_module_node_in_cluster(clusterlist_module_t handle, +int clusterlist_module_node_in_cluster(clusterlist_module_t handle, const char *node); /* @@ -112,8 +112,8 @@ int clusterlist_module_node_in_cluster(clusterlist_module_t handle, * call clusterlist module get nodename function */ int clusterlist_module_get_nodename(clusterlist_module_t handle, - const char *node, - char *buf, + const char *node, + char *buf, unsigned int buflen); #endif /* _CLUSTERLIST_MODULE_H */ diff --git a/src/libs/modules/config_module.c b/src/libs/modules/config_module.c index 22f59df7..472eac93 100644 --- a/src/libs/modules/config_module.c +++ b/src/libs/modules/config_module.c @@ -80,7 +80,7 @@ char *config_modules[] = { #define CONFIG_MODULE_MAX 1 #define CONFIG_MODULE_MAGIC_NUMBER 0x33882211 -/* +/* * struct config_module * * config module handle @@ -116,7 +116,7 @@ _config_module_cb(void *handle, void *dl_handle, void *module_info) #if WITH_STATIC_MODULES if (!handle || !module_info) -#else /* !WITH_STATIC_MODULES */ +#else /* !WITH_STATIC_MODULES */ if (!handle || !dl_handle || !module_info) #endif /* !WITH_STATIC_MODULES */ { @@ -251,13 +251,13 @@ _handle_info_check(config_module_t handle) { if (_handle_check(handle) < 0) return -1; - + if (!handle->module_info) { CEREBRO_DBG(("module not loaded")); return -1; } - + return 0; } @@ -266,7 +266,7 @@ config_module_unload(config_module_t handle) { if (_handle_check(handle) < 0) return -1; - + if (handle->module_info) config_module_cleanup(handle); @@ -282,7 +282,7 @@ config_module_unload(config_module_t handle) return 0; } -int +int config_module_found(config_module_t handle) { if (_handle_check(handle) < 0) @@ -305,7 +305,7 @@ config_module_interface_version(config_module_t handle) { if (_handle_info_check(handle) < 0) return -1; - + return ((*(handle->module_info)->interface_version)()); } @@ -314,7 +314,7 @@ config_module_setup(config_module_t handle) { if (_handle_info_check(handle) < 0) return -1; - + return ((*(handle->module_info)->setup)()); } @@ -323,7 +323,7 @@ config_module_cleanup(config_module_t handle) { if (_handle_info_check(handle) < 0) return -1; - + return ((*(handle->module_info)->cleanup)()); } @@ -332,6 +332,6 @@ config_module_load_config(config_module_t handle, struct cerebro_config *conf) { if (_handle_info_check(handle) < 0) return -1; - + return ((*(handle->module_info)->load_config)(conf)); } diff --git a/src/libs/modules/config_module.h b/src/libs/modules/config_module.h index f5893ee4..f72e2982 100644 --- a/src/libs/modules/config_module.h +++ b/src/libs/modules/config_module.h @@ -37,7 +37,7 @@ typedef struct config_module *config_module_t; * * Find and load the config module. If none is found, will assume a * default config module. - * + * * Returns config module handle on success, NULL on error */ config_module_t config_module_load(void); @@ -91,7 +91,7 @@ int config_module_cleanup(config_module_t handle); * * call config module get all nodes function */ -int config_module_load_config(config_module_t handle, +int config_module_load_config(config_module_t handle, struct cerebro_config *conf); diff --git a/src/libs/modules/event_module.c b/src/libs/modules/event_module.c index 213996da..74168869 100644 --- a/src/libs/modules/event_module.c +++ b/src/libs/modules/event_module.c @@ -76,7 +76,7 @@ void *event_modules[] = #define EVENT_MODULE_DIR EVENT_MODULE_BUILDDIR "/.libs" #define EVENT_MODULE_MAGIC_NUMBER 0x53812232 -/* +/* * struct event_module * * event module handle @@ -98,7 +98,7 @@ struct event_module * * Return 1 is module is stored, 0 if not, -1 on fatal error */ -static int +static int #if WITH_STATIC_MODULES _event_module_cb(void *handle, void *module_info) #else /* !WITH_STATIC_MODULES */ @@ -110,7 +110,7 @@ _event_module_cb(void *handle, void *dl_handle, void *module_info) #if !WITH_STATIC_MODULES lt_dlhandle event_dl_handle; #endif /* !WITH_STATIC_MODULES */ - + #if WITH_STATIC_MODULES if (!handle || !module_info) #else /* !WITH_STATIC_MODULES */ @@ -155,7 +155,7 @@ _event_module_cb(void *handle, void *dl_handle, void *module_info) } #if !WITH_STATIC_MODULES - if (!vector_set(event_handle->dl_handles, + if (!vector_set(event_handle->dl_handles, event_dl_handle, event_handle->modules_count)) { @@ -164,7 +164,7 @@ _event_module_cb(void *handle, void *dl_handle, void *module_info) } #endif /* !WITH_STATIC_MODULES */ if (!vector_set(event_handle->module_infos, - event_module_info, + event_module_info, event_handle->modules_count)) { CEREBRO_DBG(("vector_set: %s", strerror(errno))); @@ -179,7 +179,7 @@ _event_module_cb(void *handle, void *dl_handle, void *module_info) return 1; } -event_modules_t +event_modules_t event_modules_load(void) { struct event_module *handle = NULL; @@ -187,7 +187,7 @@ event_modules_load(void) if (module_setup() < 0) return NULL; - + if (!(handle = (struct event_module *)malloc(sizeof(struct event_module)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); @@ -204,7 +204,7 @@ event_modules_load(void) goto cleanup; } #endif /* !WITH_STATIC_MODULES */ - + if (!(handle->module_infos = vector_create(NULL))) { CEREBRO_ERR(("vector_create: %s", strerror(errno))); @@ -232,7 +232,7 @@ event_modules_load(void) goto out; /* Responsibility of caller to call count to see if no modules were - * loaded + * loaded */ out: @@ -294,7 +294,7 @@ _handle_index_check(event_modules_t handle, unsigned int index) return 0; } -int +int event_modules_unload(event_modules_t handle) { int i; @@ -326,10 +326,10 @@ event_modules_unload(event_modules_t handle) module_cleanup(); return 0; - + } -int +int event_modules_count(event_modules_t handle) { if (_handle_check(handle) < 0) @@ -372,7 +372,7 @@ event_module_interface_version(event_modules_t handle, unsigned int index) return ((*module_info->interface_version)()); } -int +int event_module_setup(event_modules_t handle, unsigned int index) { struct cerebro_event_module_info *module_info; @@ -389,7 +389,7 @@ event_module_setup(event_modules_t handle, unsigned int index) return ((*module_info->setup)()); } -int +int event_module_cleanup(event_modules_t handle, unsigned int index) { struct cerebro_event_module_info *module_info; @@ -440,24 +440,24 @@ event_module_metric_names(event_modules_t handle, unsigned int index) return ((*module_info->metric_names)()); } -int +int event_module_timeout_length(event_modules_t handle, unsigned int index) { struct cerebro_event_module_info *module_info; - + if (_handle_index_check(handle, index) < 0) return -1; - + if (!(module_info = vector_get(handle->module_infos, index))) { CEREBRO_DBG(("vector_get: %s", strerror(errno))); return -1; } - + return ((*module_info->timeout_length)()); } -int +int event_module_node_timeout(event_modules_t handle, unsigned int index, const char *nodename, @@ -477,7 +477,7 @@ event_module_node_timeout(event_modules_t handle, return ((*module_info->node_timeout)(nodename, event)); } -int +int event_module_metric_update(event_modules_t handle, unsigned int index, const char *nodename, @@ -506,7 +506,7 @@ event_module_metric_update(event_modules_t handle, event)); } -void +void event_module_destroy(event_modules_t handle, unsigned int index, struct cerebro_event *event) diff --git a/src/libs/modules/event_module.h b/src/libs/modules/event_module.h index 1dd62384..a0a26f07 100644 --- a/src/libs/modules/event_module.h +++ b/src/libs/modules/event_module.h @@ -30,13 +30,13 @@ #include "cerebro/cerebro_event_protocol.h" -typedef struct event_module *event_modules_t; +typedef struct event_module *event_modules_t; /* * event_modules_load * * Find and load the event modules. - * + * * Returns event module handle on success, NULL on error */ event_modules_t event_modules_load(void); @@ -121,7 +121,7 @@ int event_module_node_timeout(event_modules_t handle, * * call event module metric_update function */ -int event_module_metric_update(event_modules_t handle, +int event_module_metric_update(event_modules_t handle, unsigned int index, const char *nodename, const char *metric_name, diff --git a/src/libs/modules/metric_module.c b/src/libs/modules/metric_module.c index 10eaf594..f397e9fd 100644 --- a/src/libs/modules/metric_module.c +++ b/src/libs/modules/metric_module.c @@ -128,7 +128,7 @@ void *metric_modules[] = #define METRIC_MODULE_DIR METRIC_MODULE_BUILDDIR "/.libs" #define METRIC_MODULE_MAGIC_NUMBER 0x33882222 -/* +/* * struct metric_module * * metric module handle @@ -150,7 +150,7 @@ struct metric_module * * Return 1 is module is stored, 0 if not, -1 on fatal error */ -static int +static int #if WITH_STATIC_MODULES _metric_module_cb(void *handle, void *module_info) #else /* !WITH_STATIC_MODULES */ @@ -162,7 +162,7 @@ _metric_module_cb(void *handle, void *dl_handle, void *module_info) #if !WITH_STATIC_MODULES lt_dlhandle metric_dl_handle; #endif /* !WITH_STATIC_MODULES */ - + #if WITH_STATIC_MODULES if (!handle || !module_info) #else /* !WITH_STATIC_MODULES */ @@ -172,19 +172,19 @@ _metric_module_cb(void *handle, void *dl_handle, void *module_info) CEREBRO_DBG(("invalid parameters")); return -1; } - + metric_handle = handle; #if !WITH_STATIC_MODULES metric_dl_handle = dl_handle; #endif /* !WITH_STATIC_MODULES */ metric_module_info = module_info; - + if (metric_handle->magic != METRIC_MODULE_MAGIC_NUMBER) { CEREBRO_DBG(("invalid handle")); return -1; } - + if (!metric_module_info->metric_module_name || !metric_module_info->interface_version || !metric_module_info->setup @@ -207,7 +207,7 @@ _metric_module_cb(void *handle, void *dl_handle, void *module_info) } #if !WITH_STATIC_MODULES - if (!vector_set(metric_handle->dl_handles, + if (!vector_set(metric_handle->dl_handles, metric_dl_handle, metric_handle->modules_count)) { @@ -216,7 +216,7 @@ _metric_module_cb(void *handle, void *dl_handle, void *module_info) } #endif /* !WITH_STATIC_MODULES */ if (!vector_set(metric_handle->module_infos, - metric_module_info, + metric_module_info, metric_handle->modules_count)) { CEREBRO_DBG(("vector_set: %s", strerror(errno))); @@ -231,7 +231,7 @@ _metric_module_cb(void *handle, void *dl_handle, void *module_info) return 1; } -metric_modules_t +metric_modules_t metric_modules_load(void) { struct metric_module *handle = NULL; @@ -256,7 +256,7 @@ metric_modules_load(void) goto cleanup; } #endif /* !WITH_STATIC_MODULES */ - + if (!(handle->module_infos = vector_create(NULL))) { CEREBRO_ERR(("vector_create: %s", strerror(errno))); @@ -283,7 +283,7 @@ metric_modules_load(void) goto out; /* Responsibility of caller to call count to see if no modules were - * loaded + * loaded */ out: @@ -335,17 +335,17 @@ _handle_index_check(metric_modules_t handle, unsigned int index) { if (_handle_check(handle) < 0) return -1; - + if (!(index < handle->modules_count)) { CEREBRO_DBG(("invalid index")); return -1; } - + return 0; } -int +int metric_modules_unload(metric_modules_t handle) { int i; @@ -377,10 +377,10 @@ metric_modules_unload(metric_modules_t handle) module_cleanup(); return 0; - + } -int +int metric_modules_count(metric_modules_t handle) { if (_handle_check(handle) < 0) @@ -423,14 +423,14 @@ metric_module_interface_version(metric_modules_t handle, unsigned int index) return ((*module_info->interface_version)()); } -int +int metric_module_setup(metric_modules_t handle, unsigned int index) { struct cerebro_metric_module_info *module_info; if (_handle_index_check(handle, index) < 0) return -1; - + if (!(module_info = vector_get(handle->module_infos, index))) { CEREBRO_DBG(("vector_get: %s", strerror(errno))); @@ -440,14 +440,14 @@ metric_module_setup(metric_modules_t handle, unsigned int index) return ((*module_info->setup)()); } -int +int metric_module_cleanup(metric_modules_t handle, unsigned int index) { struct cerebro_metric_module_info *module_info; if (_handle_index_check(handle, index) < 0) return -1; - + if (!(module_info = vector_get(handle->module_infos, index))) { CEREBRO_DBG(("vector_get: %s", strerror(errno))); @@ -464,7 +464,7 @@ metric_module_get_metric_name(metric_modules_t handle, unsigned int index) if (_handle_index_check(handle, index) < 0) return NULL; - + if (!(module_info = vector_get(handle->module_infos, index))) { CEREBRO_DBG(("vector_get: %s", strerror(errno))); @@ -475,7 +475,7 @@ metric_module_get_metric_name(metric_modules_t handle, unsigned int index) } int -metric_module_get_metric_period(metric_modules_t handle, +metric_module_get_metric_period(metric_modules_t handle, unsigned int index, int *period) { @@ -483,7 +483,7 @@ metric_module_get_metric_period(metric_modules_t handle, if (_handle_index_check(handle, index) < 0) return -1; - + if (!(module_info = vector_get(handle->module_infos, index))) { CEREBRO_DBG(("vector_get: %s", strerror(errno))); @@ -494,7 +494,7 @@ metric_module_get_metric_period(metric_modules_t handle, } int -metric_module_get_metric_flags(metric_modules_t handle, +metric_module_get_metric_flags(metric_modules_t handle, unsigned int index, u_int32_t *flags) { @@ -502,7 +502,7 @@ metric_module_get_metric_flags(metric_modules_t handle, if (_handle_index_check(handle, index) < 0) return -1; - + if (!(module_info = vector_get(handle->module_infos, index))) { CEREBRO_DBG(("vector_get: %s", strerror(errno))); @@ -512,7 +512,7 @@ metric_module_get_metric_flags(metric_modules_t handle, return ((*module_info->get_metric_flags)(flags)); } -int +int metric_module_get_metric_value(metric_modules_t handle, unsigned int index, unsigned int *metric_value_type, @@ -523,7 +523,7 @@ metric_module_get_metric_value(metric_modules_t handle, if (_handle_index_check(handle, index) < 0) return -1; - + if (!(module_info = vector_get(handle->module_infos, index))) { CEREBRO_DBG(("vector_get: %s", strerror(errno))); @@ -535,7 +535,7 @@ metric_module_get_metric_value(metric_modules_t handle, metric_value)); } -int +int metric_module_destroy_metric_value(metric_modules_t handle, unsigned int index, void *metric_value) @@ -544,7 +544,7 @@ metric_module_destroy_metric_value(metric_modules_t handle, if (_handle_index_check(handle, index) < 0) return -1; - + if (!(module_info = vector_get(handle->module_infos, index))) { CEREBRO_DBG(("vector_get: %s", strerror(errno))); @@ -554,7 +554,7 @@ metric_module_destroy_metric_value(metric_modules_t handle, return ((*module_info->destroy_metric_value)(metric_value)); } -Cerebro_metric_thread_pointer +Cerebro_metric_thread_pointer metric_module_get_metric_thread(metric_modules_t handle, unsigned int index) { @@ -562,7 +562,7 @@ metric_module_get_metric_thread(metric_modules_t handle, if (_handle_index_check(handle, index) < 0) return NULL; - + if (!(module_info = vector_get(handle->module_infos, index))) { CEREBRO_DBG(("vector_get: %s", strerror(errno))); @@ -572,7 +572,7 @@ metric_module_get_metric_thread(metric_modules_t handle, return ((*module_info->get_metric_thread)()); } -int +int metric_module_send_message_function_pointer(metric_modules_t handle, unsigned int index, Cerebro_metric_send_message function_pointer) @@ -581,7 +581,7 @@ metric_module_send_message_function_pointer(metric_modules_t handle, if (_handle_index_check(handle, index) < 0) return -1; - + if (!(module_info = vector_get(handle->module_infos, index))) { CEREBRO_DBG(("vector_get: %s", strerror(errno))); diff --git a/src/libs/modules/metric_module.h b/src/libs/modules/metric_module.h index 0d570fba..e838154c 100644 --- a/src/libs/modules/metric_module.h +++ b/src/libs/modules/metric_module.h @@ -28,13 +28,13 @@ #ifndef _METRIC_MODULE_H #define _METRIC_MODULE_H -typedef struct metric_module *metric_modules_t; +typedef struct metric_module *metric_modules_t; /* * metric_modules_load * * Find and load the metric modules. - * + * * Returns metric module handle on success, NULL on error */ metric_modules_t metric_modules_load(void); @@ -95,7 +95,7 @@ char *metric_module_get_metric_name(metric_modules_t handle, unsigned int index) * * call metric module get_metric_period function */ -int metric_module_get_metric_period(metric_modules_t handle, +int metric_module_get_metric_period(metric_modules_t handle, unsigned int index, int *period); @@ -104,7 +104,7 @@ int metric_module_get_metric_period(metric_modules_t handle, * * call metric module get_metric_flags function */ -int metric_module_get_metric_flags(metric_modules_t handle, +int metric_module_get_metric_flags(metric_modules_t handle, unsigned int index, u_int32_t *flags); diff --git a/src/libs/modules/module_util.c b/src/libs/modules/module_util.c index c5cc6a57..3da1a0c3 100644 --- a/src/libs/modules/module_util.c +++ b/src/libs/modules/module_util.c @@ -53,7 +53,7 @@ #endif /* !WITH_STATIC_MODULES */ #include "module_util.h" -/* +/* * module_setup_count * * indicates the number of times module setup function has been called @@ -61,14 +61,14 @@ int module_setup_count = 0; #if WITH_STATIC_MODULES -int +int find_and_load_modules(void **modules_list, Module_callback module_cb, void *handle, unsigned int modules_max) { int found = 0; - + /* modules_list need not be passed in */ if (!module_cb || !handle @@ -86,13 +86,13 @@ find_and_load_modules(void **modules_list, while ((module_info = modules_list[i])) { int flag; - + if ((flag = module_cb(handle, module_info)) < 0) return -1; if (flag) found++; - + if (found >= modules_max) goto out; @@ -104,9 +104,9 @@ find_and_load_modules(void **modules_list, return (found) ? 1 : 0; } #else /* !WITH_STATIC_MODULES */ -/* +/* * _load_module - * + * * Load module indicated by parameters and call module callback * * Returns 1 if module loaded and stored, 0 if not, -1 on error @@ -141,16 +141,16 @@ _load_module(char *search_dir, CEREBRO_ERR(("lt_dlopen: %s, %s", filebuf, lt_dlerror())); goto cleanup; } - + /* clear lt_dlerror */ lt_dlerror(); - + if (!(module_info = lt_dlsym(dl_handle, module_info_sym))) { lt_dlclose(dl_handle); return 0; } - + if ((flag = module_cb(handle, dl_handle, module_info)) < 0) goto cleanup; @@ -259,7 +259,7 @@ _find_known_module(char *search_dir, * * Returns 1 when a module(s) are found, 0 if not, -1 on fatal error */ -static int +static int _find_unknown_modules(char *search_dir, char *signature, Module_callback module_cb, @@ -312,10 +312,10 @@ _find_unknown_modules(char *search_dir, module_info_sym, handle)) < 0) goto cleanup; - + if (flag) found++; - + if (found >= modules_max) goto out; } @@ -330,7 +330,7 @@ _find_unknown_modules(char *search_dir, return -1; } -int +int find_and_load_modules(char *module_dir, char **modules_list, char *signature, @@ -362,18 +362,18 @@ find_and_load_modules(char *module_dir, module_info_sym, handle)) < 0) return -1; - + if (rv) return 1; #endif /* CEREBRO_DEBUG */ - + if ((rv = _find_known_module(CEREBRO_MODULE_DIR, modules_list, module_cb, module_info_sym, handle)) < 0) return -1; - + if (rv) return 1; } @@ -386,7 +386,7 @@ find_and_load_modules(char *module_dir, handle, modules_max)) < 0) return -1; - + if (rv) return 1; #endif /* CEREBRO_DEBUG */ @@ -406,7 +406,7 @@ find_and_load_modules(char *module_dir, } #endif /* !WITH_STATIC_MODULES */ -int +int module_setup(void) { if (module_setup_count) @@ -425,7 +425,7 @@ module_setup(void) return 0; } -int +int module_cleanup(void) { if (module_setup_count) diff --git a/src/libs/modules/module_util.h b/src/libs/modules/module_util.h index ea3cadf9..ac1ff663 100644 --- a/src/libs/modules/module_util.h +++ b/src/libs/modules/module_util.h @@ -68,14 +68,14 @@ int find_and_load_modules(char *module_dir, unsigned int modules_max); #endif /* !WITH_STATIC_MODULES */ -/* +/* * module_setup * * Setup library for module loading */ int module_setup(void); -/* +/* * module_cleanup * * Cleanup library from module loading diff --git a/src/libs/modules/monitor_module.c b/src/libs/modules/monitor_module.c index 82eac53d..63584354 100644 --- a/src/libs/modules/monitor_module.c +++ b/src/libs/modules/monitor_module.c @@ -70,7 +70,7 @@ void *monitor_modules[] = #define MONITOR_MODULE_DIR MONITOR_MODULE_BUILDDIR "/.libs" #define MONITOR_MODULE_MAGIC_NUMBER 0x33882233 -/* +/* * struct monitor_module * * monitor module handle @@ -92,7 +92,7 @@ struct monitor_module * * Return 1 is module is stored, 0 if not, -1 on fatal error */ -static int +static int #if WITH_STATIC_MODULES _monitor_module_cb(void *handle, void *module_info) #else /* !WITH_STATIC_MODULES */ @@ -104,7 +104,7 @@ _monitor_module_cb(void *handle, void *dl_handle, void *module_info) #if !WITH_STATIC_MODULES lt_dlhandle monitor_dl_handle; #endif /* !WITH_STATIC_MODULES */ - + #if WITH_STATIC_MODULES if (!handle || !module_info) #else /* !WITH_STATIC_MODULES */ @@ -145,7 +145,7 @@ _monitor_module_cb(void *handle, void *dl_handle, void *module_info) } #if !WITH_STATIC_MODULES - if (!vector_set(monitor_handle->dl_handles, + if (!vector_set(monitor_handle->dl_handles, monitor_dl_handle, monitor_handle->modules_count)) { @@ -154,7 +154,7 @@ _monitor_module_cb(void *handle, void *dl_handle, void *module_info) } #endif /* !WITH_STATIC_MODULES */ if (!vector_set(monitor_handle->module_infos, - monitor_module_info, + monitor_module_info, monitor_handle->modules_count)) { CEREBRO_DBG(("vector_set: %s", strerror(errno))); @@ -169,7 +169,7 @@ _monitor_module_cb(void *handle, void *dl_handle, void *module_info) return 1; } -monitor_modules_t +monitor_modules_t monitor_modules_load(void) { struct monitor_module *handle = NULL; @@ -177,7 +177,7 @@ monitor_modules_load(void) if (module_setup() < 0) return NULL; - + if (!(handle = (struct monitor_module *)malloc(sizeof(struct monitor_module)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); @@ -194,7 +194,7 @@ monitor_modules_load(void) goto cleanup; } #endif /* !WITH_STATIC_MODULES */ - + if (!(handle->module_infos = vector_create(NULL))) { CEREBRO_ERR(("vector_create: %s", strerror(errno))); @@ -222,7 +222,7 @@ monitor_modules_load(void) goto out; /* Responsibility of caller to call count to see if no modules were - * loaded + * loaded */ out: @@ -284,7 +284,7 @@ _handle_index_check(monitor_modules_t handle, unsigned int index) return 0; } -int +int monitor_modules_unload(monitor_modules_t handle) { int i; @@ -316,10 +316,10 @@ monitor_modules_unload(monitor_modules_t handle) module_cleanup(); return 0; - + } -int +int monitor_modules_count(monitor_modules_t handle) { if (_handle_check(handle) < 0) @@ -362,7 +362,7 @@ monitor_module_interface_version(monitor_modules_t handle, unsigned int index) return ((*module_info->interface_version)()); } -int +int monitor_module_setup(monitor_modules_t handle, unsigned int index) { struct cerebro_monitor_module_info *module_info; @@ -379,7 +379,7 @@ monitor_module_setup(monitor_modules_t handle, unsigned int index) return ((*module_info->setup)()); } -int +int monitor_module_cleanup(monitor_modules_t handle, unsigned int index) { struct cerebro_monitor_module_info *module_info; @@ -413,7 +413,7 @@ monitor_module_metric_names(monitor_modules_t handle, unsigned int index) return ((*module_info->metric_names)()); } -int +int monitor_module_metric_update(monitor_modules_t handle, unsigned int index, const char *nodename, diff --git a/src/libs/modules/monitor_module.h b/src/libs/modules/monitor_module.h index 95b095a0..9f2e710a 100644 --- a/src/libs/modules/monitor_module.h +++ b/src/libs/modules/monitor_module.h @@ -28,13 +28,13 @@ #ifndef _MONITOR_MODULE_H #define _MONITOR_MODULE_H -typedef struct monitor_module *monitor_modules_t; +typedef struct monitor_module *monitor_modules_t; /* * monitor_modules_load * * Find and load the monitor modules. - * + * * Returns monitor module handle on success, NULL on error */ monitor_modules_t monitor_modules_load(void); @@ -95,7 +95,7 @@ char *monitor_module_metric_names(monitor_modules_t handle, unsigned int index); * * call monitor module metric_update function */ -int monitor_module_metric_update(monitor_modules_t handle, +int monitor_module_metric_update(monitor_modules_t handle, unsigned int index, const char *nodename, const char *metric_name, diff --git a/src/libs/util/config_util.c b/src/libs/util/config_util.c index 5d123e77..a9d7f738 100644 --- a/src/libs/util/config_util.c +++ b/src/libs/util/config_util.c @@ -47,7 +47,7 @@ char *config_debug_config_file = NULL; int config_debug_output = 0; -/* +/* * _load_config_module * * Find and load config module @@ -176,9 +176,9 @@ _cb_cerebro_metric_server(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARAMETERS); return -1; } - + conf = (struct cerebro_config *)option_ptr; - + /* arg1 - required - ip/hostname - 0.0.0.0 for default * arg2 - optional - port - 0 for default */ @@ -210,7 +210,7 @@ _cb_cerebro_metric_server(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_INVALID); return -1; } - + conf->cerebro_metric_server[index].port = port; } else @@ -242,9 +242,9 @@ _cb_cerebro_event_server(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARAMETERS); return -1; } - + conf = (struct cerebro_config *)option_ptr; - + /* arg1 - required - ip/hostname - 0.0.0.0 for default * arg2 - optional - port - 0 for default */ @@ -276,7 +276,7 @@ _cb_cerebro_event_server(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_INVALID); return -1; } - + conf->cerebro_event_server[index].port = port; } else @@ -308,7 +308,7 @@ _cb_cerebrod_speak_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARAMETERS); return -1; } - + conf = (struct cerebro_config *)option_ptr; /* arg1 - required - destination ip - 0.0.0.0 for default @@ -331,7 +331,7 @@ _cb_cerebrod_speak_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_OVERFLOW_ARGLEN); return -1; } - + strcpy(conf->cerebrod_speak_message_config[index].ip, data->stringlist[0]); if (data->stringlist_len > 1) @@ -345,7 +345,7 @@ _cb_cerebrod_speak_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_INVALID); return -1; } - + conf->cerebrod_speak_message_config[index].destination_port = port; } else @@ -362,12 +362,12 @@ _cb_cerebrod_speak_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_INVALID); return -1; } - + conf->cerebrod_speak_message_config[index].source_port = port; } else conf->cerebrod_speak_message_config[index].source_port = CEREBRO_CONFIG_PORT_DEFAULT; - + if (data->stringlist_len > 3) { if (strlen(data->stringlist[3]) > CEREBRO_MAX_HOSTNAME_LEN) @@ -405,7 +405,7 @@ _cb_cerebrod_listen_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARAMETERS); return -1; } - + conf = (struct cerebro_config *)option_ptr; /* arg1 - required - ip - 0.0.0.0 for default @@ -427,7 +427,7 @@ _cb_cerebrod_listen_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_OVERFLOW_ARGLEN); return -1; } - + strcpy(conf->cerebrod_listen_message_config[index].ip, data->stringlist[0]); if (data->stringlist_len > 1) @@ -441,7 +441,7 @@ _cb_cerebrod_listen_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_INVALID); return -1; } - + conf->cerebrod_listen_message_config[index].port = port; } else @@ -485,7 +485,7 @@ _cb_cerebrod_forward_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARAMETERS); return -1; } - + conf = (struct cerebro_config *)option_ptr; /* arg1 - required - destination ip - 0.0.0.0 for default @@ -504,13 +504,13 @@ _cb_cerebrod_forward_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_TOOMANY); return -1; } - + if (strlen(data->stringlist[0]) > CEREBRO_MAX_HOSTNAME_LEN) { conffile_seterrnum(cf, CONFFILE_ERR_PARSE_OVERFLOW_ARGLEN); return -1; } - + strcpy(conf->cerebrod_forward_message_config[index].ip, data->stringlist[0]); if (data->stringlist_len > 1) @@ -524,7 +524,7 @@ _cb_cerebrod_forward_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_INVALID); return -1; } - + conf->cerebrod_forward_message_config[index].destination_port = port; } else @@ -541,12 +541,12 @@ _cb_cerebrod_forward_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_INVALID); return -1; } - + conf->cerebrod_forward_message_config[index].source_port = port; } else conf->cerebrod_forward_message_config[index].source_port = CEREBRO_CONFIG_PORT_DEFAULT; - + if (data->stringlist_len > 3) { if (strlen(data->stringlist[3]) > CEREBRO_MAX_HOSTNAME_LEN) @@ -571,7 +571,7 @@ _cb_cerebrod_forward_message_config(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_OVERFLOW_ARGLEN); return -1; } - strcpy(conf->cerebrod_forward_message_config[index].host[host_index], + strcpy(conf->cerebrod_forward_message_config[index].host[host_index], data->stringlist[i]); conf->cerebrod_forward_message_config[index].host_len++; } @@ -603,7 +603,7 @@ _cb_cerebrod_forward_host_accept(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARAMETERS); return -1; } - + conf = (struct cerebro_config *)option_ptr; if (data->stringlist_len > 0) @@ -623,8 +623,8 @@ _cb_cerebrod_forward_host_accept(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_OVERFLOW_ARGLEN); return -1; } - - strcpy(conf->cerebrod_forward_host_accept[conf->cerebrod_forward_host_accept_len], + + strcpy(conf->cerebrod_forward_host_accept[conf->cerebrod_forward_host_accept_len], data->stringlist[i]); conf->cerebrod_forward_host_accept_len++; } @@ -652,7 +652,7 @@ _cb_cerebrod_module_exclude(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARAMETERS); return -1; } - + conf = (struct cerebro_config *)option_ptr; if (data->stringlist_len > 0) @@ -675,8 +675,8 @@ _cb_cerebrod_module_exclude(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_TOOMANY); return -1; } - - strcpy(conf->cerebrod_metric_module_exclude[conf->cerebrod_metric_module_exclude_len], + + strcpy(conf->cerebrod_metric_module_exclude[conf->cerebrod_metric_module_exclude_len], data->stringlist[i]); conf->cerebrod_metric_module_exclude_len++; } @@ -687,8 +687,8 @@ _cb_cerebrod_module_exclude(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_TOOMANY); return -1; } - - strcpy(conf->cerebrod_monitor_module_exclude[conf->cerebrod_monitor_module_exclude_len], + + strcpy(conf->cerebrod_monitor_module_exclude[conf->cerebrod_monitor_module_exclude_len], data->stringlist[i]); conf->cerebrod_monitor_module_exclude_len++; } @@ -699,8 +699,8 @@ _cb_cerebrod_module_exclude(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_TOOMANY); return -1; } - - strcpy(conf->cerebrod_event_module_exclude[conf->cerebrod_event_module_exclude_len], + + strcpy(conf->cerebrod_event_module_exclude[conf->cerebrod_event_module_exclude_len], data->stringlist[i]); conf->cerebrod_event_module_exclude_len++; } @@ -730,7 +730,7 @@ _cb_cerebrod_alternate_hostname(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARAMETERS); return -1; } - + conf = (struct cerebro_config *)option_ptr; if (strlen(data->string) > CEREBRO_MAX_HOSTNAME_LEN) @@ -738,7 +738,7 @@ _cb_cerebrod_alternate_hostname(conffile_t cf, struct conffile_data *data, conffile_seterrnum(cf, CONFFILE_ERR_PARSE_OVERFLOW_ARGLEN); return -1; } - + strcpy(conf->cerebrod_alternate_hostname, data->string); /* shorten hostname if necessary */ if ((p = strchr(conf->cerebrod_alternate_hostname, '.'))) @@ -748,7 +748,7 @@ _cb_cerebrod_alternate_hostname(conffile_t cf, struct conffile_data *data, } #endif /* CEREBRO_DEBUG */ -/* +/* * _load_config_file * * Read and load configuration file @@ -788,302 +788,302 @@ _load_config_file(struct cerebro_config *conf, unsigned int *errnum) 0 }, { - "cerebro_timeout_len", - CONFFILE_OPTION_INT, + "cerebro_timeout_len", + CONFFILE_OPTION_INT, -1, - conffile_int, - 1, - 0, + conffile_int, + 1, + 0, &(conf->cerebro_timeout_len_flag), - &(conf->cerebro_timeout_len), + &(conf->cerebro_timeout_len), 0 }, { - "cerebro_flags", - CONFFILE_OPTION_INT, + "cerebro_flags", + CONFFILE_OPTION_INT, -1, - conffile_int, - 1, - 0, + conffile_int, + 1, + 0, &(conf->cerebro_flags_flag), - &(conf->cerebro_flags), + &(conf->cerebro_flags), 0 }, /* * Cerebrod configuration */ { - "cerebrod_heartbeat_frequency", - CONFFILE_OPTION_LIST_INT, + "cerebrod_heartbeat_frequency", + CONFFILE_OPTION_LIST_INT, -1, - _cb_cerebrod_heartbeat_freq, - 1, - 0, + _cb_cerebrod_heartbeat_freq, + 1, + 0, &(conf->cerebrod_heartbeat_frequency_flag), - conf, + conf, 0 }, { - "cerebrod_speak", - CONFFILE_OPTION_BOOL, + "cerebrod_speak", + CONFFILE_OPTION_BOOL, -1, - conffile_bool, - 1, - 0, + conffile_bool, + 1, + 0, &(conf->cerebrod_speak_flag), - &conf->cerebrod_speak, + &conf->cerebrod_speak, 0 }, { "cerebrod_speak_message_config", - CONFFILE_OPTION_LIST_STRING, + CONFFILE_OPTION_LIST_STRING, -1, - _cb_cerebrod_speak_message_config, - CEREBRO_CONFIG_SPEAK_MESSAGE_CONFIG_MAX, - 0, + _cb_cerebrod_speak_message_config, + CEREBRO_CONFIG_SPEAK_MESSAGE_CONFIG_MAX, + 0, &(conf->cerebrod_speak_message_config_flag), - conf, + conf, 0 }, { - "cerebrod_speak_message_ttl", - CONFFILE_OPTION_INT, + "cerebrod_speak_message_ttl", + CONFFILE_OPTION_INT, -1, - conffile_int, - 1, - 0, + conffile_int, + 1, + 0, &(conf->cerebrod_speak_message_ttl_flag), - &(conf->cerebrod_speak_message_ttl), + &(conf->cerebrod_speak_message_ttl), 0 }, { - "cerebrod_listen", - CONFFILE_OPTION_BOOL, + "cerebrod_listen", + CONFFILE_OPTION_BOOL, -1, - conffile_bool, - 1, - 0, + conffile_bool, + 1, + 0, &(conf->cerebrod_listen_flag), - &conf->cerebrod_listen, + &conf->cerebrod_listen, 0 }, { - "cerebrod_listen_threads", - CONFFILE_OPTION_INT, + "cerebrod_listen_threads", + CONFFILE_OPTION_INT, -1, - conffile_int, - 1, - 0, + conffile_int, + 1, + 0, &(conf->cerebrod_listen_threads_flag), - &(conf->cerebrod_listen_threads), + &(conf->cerebrod_listen_threads), 0 }, { "cerebrod_listen_message_config", - CONFFILE_OPTION_LIST_STRING, + CONFFILE_OPTION_LIST_STRING, -1, - _cb_cerebrod_listen_message_config, - CEREBRO_CONFIG_LISTEN_MESSAGE_CONFIG_MAX, - 0, + _cb_cerebrod_listen_message_config, + CEREBRO_CONFIG_LISTEN_MESSAGE_CONFIG_MAX, + 0, &(conf->cerebrod_listen_message_config_flag), - conf, + conf, 0 }, { - "cerebrod_metric_controller", - CONFFILE_OPTION_BOOL, + "cerebrod_metric_controller", + CONFFILE_OPTION_BOOL, -1, - conffile_bool, - 1, - 0, + conffile_bool, + 1, + 0, &(conf->cerebrod_metric_controller_flag), - &conf->cerebrod_metric_controller, + &conf->cerebrod_metric_controller, 0 }, { - "cerebrod_metric_server", - CONFFILE_OPTION_BOOL, + "cerebrod_metric_server", + CONFFILE_OPTION_BOOL, -1, - conffile_bool, - 1, - 0, + conffile_bool, + 1, + 0, &(conf->cerebrod_metric_server_flag), - &conf->cerebrod_metric_server, + &conf->cerebrod_metric_server, 0 }, { - "cerebrod_metric_server_port", - CONFFILE_OPTION_INT, + "cerebrod_metric_server_port", + CONFFILE_OPTION_INT, -1, - conffile_int, - 1, - 0, + conffile_int, + 1, + 0, &(conf->cerebrod_metric_server_port_flag), - &(conf->cerebrod_metric_server_port), + &(conf->cerebrod_metric_server_port), 0 }, { - "cerebrod_event_server", - CONFFILE_OPTION_BOOL, + "cerebrod_event_server", + CONFFILE_OPTION_BOOL, -1, - conffile_bool, - 1, - 0, + conffile_bool, + 1, + 0, &(conf->cerebrod_event_server_flag), - &conf->cerebrod_event_server, + &conf->cerebrod_event_server, 0 }, { - "cerebrod_event_server_port", - CONFFILE_OPTION_INT, + "cerebrod_event_server_port", + CONFFILE_OPTION_INT, -1, - conffile_int, - 1, - 0, + conffile_int, + 1, + 0, &(conf->cerebrod_event_server_port_flag), - &(conf->cerebrod_event_server_port), + &(conf->cerebrod_event_server_port), 0 }, { "cerebrod_forward_message_config", - CONFFILE_OPTION_LIST_STRING, + CONFFILE_OPTION_LIST_STRING, -1, - _cb_cerebrod_forward_message_config, - CEREBRO_CONFIG_FORWARD_MESSAGE_CONFIG_MAX, - 0, + _cb_cerebrod_forward_message_config, + CEREBRO_CONFIG_FORWARD_MESSAGE_CONFIG_MAX, + 0, &(conf->cerebrod_forward_message_config_flag), - conf, + conf, 0 }, { - "cerebrod_forward_message_ttl", - CONFFILE_OPTION_INT, + "cerebrod_forward_message_ttl", + CONFFILE_OPTION_INT, -1, - conffile_int, - 1, - 0, + conffile_int, + 1, + 0, &(conf->cerebrod_forward_message_ttl_flag), - &(conf->cerebrod_forward_message_ttl), + &(conf->cerebrod_forward_message_ttl), 0 }, { - "cerebrod_forward_host_accept", - CONFFILE_OPTION_LIST_STRING, + "cerebrod_forward_host_accept", + CONFFILE_OPTION_LIST_STRING, -1, - _cb_cerebrod_forward_host_accept, - CEREBRO_CONFIG_FORWARD_HOST_ACCEPT_MAX, - 0, + _cb_cerebrod_forward_host_accept, + CEREBRO_CONFIG_FORWARD_HOST_ACCEPT_MAX, + 0, &(conf->cerebrod_forward_host_accept_flag), - conf, + conf, 0 }, { - "cerebrod_metric_module_exclude", - CONFFILE_OPTION_LIST_STRING, + "cerebrod_metric_module_exclude", + CONFFILE_OPTION_LIST_STRING, -1, - _cb_cerebrod_module_exclude, - CEREBRO_CONFIG_METRIC_MODULE_EXCLUDE_MAX, - 0, + _cb_cerebrod_module_exclude, + CEREBRO_CONFIG_METRIC_MODULE_EXCLUDE_MAX, + 0, &(conf->cerebrod_metric_module_exclude_flag), - conf, + conf, 0 }, { - "cerebrod_monitor_module_exclude", - CONFFILE_OPTION_LIST_STRING, + "cerebrod_monitor_module_exclude", + CONFFILE_OPTION_LIST_STRING, -1, - _cb_cerebrod_module_exclude, - CEREBRO_CONFIG_MONITOR_MODULE_EXCLUDE_MAX, - 0, + _cb_cerebrod_module_exclude, + CEREBRO_CONFIG_MONITOR_MODULE_EXCLUDE_MAX, + 0, &(conf->cerebrod_monitor_module_exclude_flag), - conf, + conf, 0 }, { - "cerebrod_event_module_exclude", - CONFFILE_OPTION_LIST_STRING, + "cerebrod_event_module_exclude", + CONFFILE_OPTION_LIST_STRING, -1, - _cb_cerebrod_module_exclude, - CEREBRO_CONFIG_EVENT_MODULE_EXCLUDE_MAX, - 0, + _cb_cerebrod_module_exclude, + CEREBRO_CONFIG_EVENT_MODULE_EXCLUDE_MAX, + 0, &(conf->cerebrod_event_module_exclude_flag), - conf, + conf, 0 }, { - "cerebrod_speak_debug", - CONFFILE_OPTION_BOOL, + "cerebrod_speak_debug", + CONFFILE_OPTION_BOOL, -1, - conffile_bool, - 1, - 0, + conffile_bool, + 1, + 0, &(conf->cerebrod_speak_debug_flag), - &conf->cerebrod_speak_debug, + &conf->cerebrod_speak_debug, 0 }, { - "cerebrod_listen_debug", - CONFFILE_OPTION_BOOL, + "cerebrod_listen_debug", + CONFFILE_OPTION_BOOL, -1, - conffile_bool, - 1, - 0, + conffile_bool, + 1, + 0, &(conf->cerebrod_listen_debug_flag), - &conf->cerebrod_listen_debug, + &conf->cerebrod_listen_debug, 0 }, { - "cerebrod_metric_controller_debug", - CONFFILE_OPTION_BOOL, + "cerebrod_metric_controller_debug", + CONFFILE_OPTION_BOOL, -1, - conffile_bool, - 1, - 0, + conffile_bool, + 1, + 0, &(conf->cerebrod_metric_controller_debug_flag), - &conf->cerebrod_metric_controller_debug, + &conf->cerebrod_metric_controller_debug, 0 }, { - "cerebrod_metric_server_debug", - CONFFILE_OPTION_BOOL, + "cerebrod_metric_server_debug", + CONFFILE_OPTION_BOOL, -1, - conffile_bool, - 1, - 0, + conffile_bool, + 1, + 0, &(conf->cerebrod_metric_server_debug_flag), - &conf->cerebrod_metric_server_debug, + &conf->cerebrod_metric_server_debug, 0 }, { - "cerebrod_event_server_debug", - CONFFILE_OPTION_BOOL, + "cerebrod_event_server_debug", + CONFFILE_OPTION_BOOL, -1, - conffile_bool, - 1, - 0, + conffile_bool, + 1, + 0, &(conf->cerebrod_event_server_debug_flag), - &conf->cerebrod_event_server_debug, + &conf->cerebrod_event_server_debug, 0 }, { - "cerebrod_gettimeofday_workaround", - CONFFILE_OPTION_BOOL, + "cerebrod_gettimeofday_workaround", + CONFFILE_OPTION_BOOL, -1, - conffile_bool, - 1, - 0, + conffile_bool, + 1, + 0, &(conf->cerebrod_gettimeofday_workaround_flag), - &conf->cerebrod_gettimeofday_workaround, + &conf->cerebrod_gettimeofday_workaround, 0 }, #if CEREBRO_DEBUG { - "cerebrod_alternate_hostname", - CONFFILE_OPTION_STRING, + "cerebrod_alternate_hostname", + CONFFILE_OPTION_STRING, -1, - _cb_cerebrod_alternate_hostname, - 1, - 0, + _cb_cerebrod_alternate_hostname, + 1, + 0, &(conf->cerebrod_alternate_hostname_flag), conf, 0 @@ -1092,7 +1092,7 @@ _load_config_file(struct cerebro_config *conf, unsigned int *errnum) }; conffile_t cf = NULL; int num; - + if (!(cf = conffile_handle_create())) { CEREBRO_ERR(("conffile_handle_create")); @@ -1100,7 +1100,7 @@ _load_config_file(struct cerebro_config *conf, unsigned int *errnum) *errnum = CEREBRO_ERR_OUTMEM; goto cleanup; } - + if (!config_debug_config_file) config_file = CEREBRO_CONFIG_FILE_DEFAULT; else @@ -1113,7 +1113,7 @@ _load_config_file(struct cerebro_config *conf, unsigned int *errnum) char buf[CONFFILE_MAX_ERRMSGLEN]; /* Its not an error if the default configuration file doesn't exist */ - if (!strcmp(config_file, CEREBRO_CONFIG_FILE_DEFAULT) + if (!strcmp(config_file, CEREBRO_CONFIG_FILE_DEFAULT) && conffile_errnum(cf) == CONFFILE_ERR_EXIST) goto out; @@ -1121,23 +1121,23 @@ _load_config_file(struct cerebro_config *conf, unsigned int *errnum) CEREBRO_DBG(("conffile_parse: %d", conffile_errnum(cf))); else CEREBRO_DBG(("conffile_parse: %s", buf)); - + if (errnum) *errnum = CEREBRO_ERR_CONFIG_FILE; goto cleanup; } - + out: conffile_handle_destroy(cf); return 0; - + cleanup: memset(conf, '\0', sizeof(struct cerebro_config)); conffile_handle_destroy(cf); return -1; } -/* +/* * _set_cerebro_config * * Set the dest cerebro_config based on its current settings and the @@ -1146,7 +1146,7 @@ _load_config_file(struct cerebro_config *conf, unsigned int *errnum) * Returns 0 on success, -1 on error */ static int -_set_cerebro_config(struct cerebro_config *dest, +_set_cerebro_config(struct cerebro_config *dest, struct cerebro_config *src, unsigned int *errnum) { @@ -1194,7 +1194,7 @@ _set_cerebro_config(struct cerebro_config *dest, dest->cerebro_flags_flag++; } - if (!dest->cerebrod_heartbeat_frequency_flag + if (!dest->cerebrod_heartbeat_frequency_flag && src->cerebrod_heartbeat_frequency_flag) { dest->cerebrod_heartbeat_frequency_min = src->cerebrod_heartbeat_frequency_min; @@ -1208,7 +1208,7 @@ _set_cerebro_config(struct cerebro_config *dest, dest->cerebrod_speak_flag++; } - if (!dest->cerebrod_speak_message_config_flag + if (!dest->cerebrod_speak_message_config_flag && src->cerebrod_speak_message_config_flag && src->cerebrod_speak_message_config_len) { @@ -1235,7 +1235,7 @@ _set_cerebro_config(struct cerebro_config *dest, dest->cerebrod_listen_flag++; } - if (!dest->cerebrod_listen_message_config_flag + if (!dest->cerebrod_listen_message_config_flag && src->cerebrod_listen_message_config_flag && src->cerebrod_listen_message_config_len) { @@ -1268,7 +1268,7 @@ _set_cerebro_config(struct cerebro_config *dest, } if (!dest->cerebrod_metric_server_port_flag - && src->cerebrod_metric_server_port_flag) + && src->cerebrod_metric_server_port_flag) { dest->cerebrod_metric_server_port = src->cerebrod_metric_server_port; dest->cerebrod_metric_server_port_flag++; @@ -1281,13 +1281,13 @@ _set_cerebro_config(struct cerebro_config *dest, } if (!dest->cerebrod_event_server_port_flag - && src->cerebrod_event_server_port_flag) + && src->cerebrod_event_server_port_flag) { dest->cerebrod_event_server_port = src->cerebrod_event_server_port; dest->cerebrod_event_server_port_flag++; } - if (!dest->cerebrod_forward_message_config_flag + if (!dest->cerebrod_forward_message_config_flag && src->cerebrod_forward_message_config_flag && src->cerebrod_forward_message_config_len) { @@ -1312,7 +1312,7 @@ _set_cerebro_config(struct cerebro_config *dest, dest->cerebrod_forward_message_ttl_flag++; } - if (!dest->cerebrod_forward_host_accept_flag + if (!dest->cerebrod_forward_host_accept_flag && src->cerebrod_forward_host_accept_flag && src->cerebrod_forward_host_accept_len) { @@ -1323,7 +1323,7 @@ _set_cerebro_config(struct cerebro_config *dest, dest->cerebrod_forward_host_accept_flag++; } - if (!dest->cerebrod_metric_module_exclude_flag + if (!dest->cerebrod_metric_module_exclude_flag && src->cerebrod_metric_module_exclude_flag && src->cerebrod_metric_module_exclude_len) { @@ -1334,7 +1334,7 @@ _set_cerebro_config(struct cerebro_config *dest, dest->cerebrod_metric_module_exclude_flag++; } - if (!dest->cerebrod_monitor_module_exclude_flag + if (!dest->cerebrod_monitor_module_exclude_flag && src->cerebrod_monitor_module_exclude_flag && src->cerebrod_monitor_module_exclude_len) { @@ -1345,7 +1345,7 @@ _set_cerebro_config(struct cerebro_config *dest, dest->cerebrod_monitor_module_exclude_flag++; } - if (!dest->cerebrod_event_module_exclude_flag + if (!dest->cerebrod_event_module_exclude_flag && src->cerebrod_event_module_exclude_flag && src->cerebrod_event_module_exclude_len) { @@ -1397,7 +1397,7 @@ _set_cerebro_config(struct cerebro_config *dest, } #if CEREBRO_DEBUG - if (!dest->cerebrod_alternate_hostname_flag + if (!dest->cerebrod_alternate_hostname_flag && src->cerebrod_alternate_hostname_flag) { strcpy(dest->cerebrod_alternate_hostname, src->cerebrod_alternate_hostname); @@ -1410,13 +1410,13 @@ _set_cerebro_config(struct cerebro_config *dest, } -/* +/* * _merge_cerebro_configs * * Merge contents of module_conf and config_file_conf into conf. The * config file conf takes precedence. */ -static int +static int _merge_cerebro_configs(struct cerebro_config *conf, struct cerebro_config *module_conf, struct cerebro_config *config_file_conf, @@ -1446,10 +1446,10 @@ _merge_cerebro_configs(struct cerebro_config *conf, return 0; } -int +int load_config(struct cerebro_config *conf, unsigned int *errnum) { - struct cerebro_config module_conf; + struct cerebro_config module_conf; struct cerebro_config config_file_conf; if (!conf) @@ -1472,6 +1472,6 @@ load_config(struct cerebro_config *conf, unsigned int *errnum) if (_merge_cerebro_configs(conf, &module_conf, &config_file_conf, errnum) < 0) return -1; - + return 0; } diff --git a/src/libs/util/config_util.h b/src/libs/util/config_util.h index ae9d0e65..6697d683 100644 --- a/src/libs/util/config_util.h +++ b/src/libs/util/config_util.h @@ -30,7 +30,7 @@ #include "cerebro/cerebro_config.h" -/* +/* * load_config * * Wrapper that calls config_load_config_module, diff --git a/src/libs/util/data_util.c b/src/libs/util/data_util.c index 6ea03c55..9e2f0b60 100644 --- a/src/libs/util/data_util.c +++ b/src/libs/util/data_util.c @@ -40,7 +40,7 @@ #include "debug.h" #include "marshall.h" -int +int _check_data_type_len(u_int32_t dtype, u_int32_t dlen, const char *caller) { if (!caller) @@ -72,7 +72,7 @@ _check_data_type_len(u_int32_t dtype, u_int32_t dlen, const char *caller) return -1; } - if (dtype == CEREBRO_DATA_VALUE_TYPE_STRING + if (dtype == CEREBRO_DATA_VALUE_TYPE_STRING && dlen > CEREBRO_MAX_DATA_STRING_LEN) { CEREBRO_DBG(("%s: string len too long", caller)); @@ -83,9 +83,9 @@ _check_data_type_len(u_int32_t dtype, u_int32_t dlen, const char *caller) } -int -_check_data_type_len_value(u_int32_t dtype, - u_int32_t dlen, +int +_check_data_type_len_value(u_int32_t dtype, + u_int32_t dlen, void *dvalue, const char *caller) { @@ -117,7 +117,7 @@ _marshall_data(u_int32_t dtype, const char *caller) { int n, c = 0; - + if (!buf || !caller) { CEREBRO_DBG(("%s: invalid parameters", caller)); @@ -141,7 +141,7 @@ _marshall_data(u_int32_t dtype, return -1; } c += n; - + if ((n = marshall_u_int32(dlen, buf + c, buflen - c)) <= 0) { CEREBRO_DBG(("%s: marshall_u_int32", caller)); @@ -237,7 +237,7 @@ _marshall_data(u_int32_t dtype, return c; } -int +int _unmarshall_data_type_len(u_int32_t *dtype, u_int32_t *dlen, const char *buf, @@ -271,7 +271,7 @@ _unmarshall_data_type_len(u_int32_t *dtype, return -1; } c += n; - + if ((n = unmarshall_u_int32(dlen, buf + c, buflen - c)) < 0) { CEREBRO_DBG(("unmarshall_u_int32")); @@ -293,7 +293,7 @@ _unmarshall_data_type_len(u_int32_t *dtype, return c; } -int +int _unmarshall_data_value(u_int32_t dtype, u_int32_t dlen, void *dvalue, @@ -319,7 +319,7 @@ _unmarshall_data_value(u_int32_t dtype, *errnum = CEREBRO_ERR_PROTOCOL; return -1; } - + if (!dlen) return 0; @@ -369,7 +369,7 @@ _unmarshall_data_value(u_int32_t dtype, else /* If an invalid param, should have been caught before here */ CEREBRO_DBG(("%s: invalid type %d", caller, dtype)); - + if (n < 0) { if (errnum) @@ -385,6 +385,6 @@ _unmarshall_data_value(u_int32_t dtype, *errnum = CEREBRO_ERR_INTERNAL; return -1; } - + return n; } diff --git a/src/libs/util/data_util.h b/src/libs/util/data_util.h index 31547ea8..5ea2724c 100644 --- a/src/libs/util/data_util.h +++ b/src/libs/util/data_util.h @@ -45,30 +45,30 @@ #define unmarshall_data_value(t,l,v,vl,b,bl,e) \ _unmarshall_data_value(t,l,v,vl,b,bl,e,__FUNCTION__) -/* +/* * _check_data_type_len * * Check if data type and len are reasonable * * Returns 0 if data is sane, -1 if not */ -int _check_data_type_len(u_int32_t dtype, - u_int32_t dlen, +int _check_data_type_len(u_int32_t dtype, + u_int32_t dlen, const char *caller); -/* +/* * _check_data_type_len_value * * Check if data type, len, and value are reasonable * * Returns 0 if data is sane, -1 if not */ -int _check_data_type_len_value(u_int32_t dtype, - u_int32_t dlen, +int _check_data_type_len_value(u_int32_t dtype, + u_int32_t dlen, void *dvalue, const char *caller); -/* +/* * _marshall_data * * Marshall data type, len, and if appropriate the value @@ -83,12 +83,12 @@ int _marshall_data(u_int32_t dtype, int *errnum, const char *caller); -/* +/* * _unmarshall_data_type_len * * Unmarshall a data type and len * - * Returns length of data unmarshalled from buffer, 0 if buffer + * Returns length of data unmarshalled from buffer, 0 if buffer * does not contain enough data, -1 on error */ int _unmarshall_data_type_len(u_int32_t *dtype, @@ -98,12 +98,12 @@ int _unmarshall_data_type_len(u_int32_t *dtype, int *errnum, const char *caller); -/* +/* * _unmarshall_data_value * * Unmarshall a data value * - * Returns length of data unmarshalled from buffer, 0 if buffer + * Returns length of data unmarshalled from buffer, 0 if buffer * does not contain enough data, -1 on error */ int _unmarshall_data_value(u_int32_t dtype, diff --git a/src/libs/util/network_util.c b/src/libs/util/network_util.c index 8bea25ee..beb83090 100644 --- a/src/libs/util/network_util.c +++ b/src/libs/util/network_util.c @@ -76,10 +76,10 @@ receive_data(int fd, unsigned int *errnum) { int bytes_read = 0; - - if (!buf - || !buflen - || !bytes_to_read + + if (!buf + || !buflen + || !bytes_to_read || buflen < bytes_to_read || !timeout_len) { @@ -88,21 +88,21 @@ receive_data(int fd, *errnum = CEREBRO_ERR_INTERNAL; goto cleanup; } - + memset(buf, '\0', buflen); - + while (bytes_read < bytes_to_read) { fd_set rfds; struct timeval tv; int num; - + tv.tv_sec = timeout_len; tv.tv_usec = 0; - + FD_ZERO(&rfds); FD_SET(fd, &rfds); - + if ((num = select(fd + 1, &rfds, NULL, NULL, &tv)) < 0) { CEREBRO_ERR(("select: %s", strerror(errno))); @@ -145,18 +145,18 @@ receive_data(int fd, *errnum = CEREBRO_ERR_INTERNAL; goto cleanup; } - + /* Pipe closed */ if (!n) { if (bytes_read) goto out; - + if (errnum) *errnum = CEREBRO_ERR_PROTOCOL; goto cleanup; } - + bytes_read += n; } else @@ -167,15 +167,15 @@ receive_data(int fd, goto cleanup; } } - + out: return bytes_read; - + cleanup: return -1; } -int +int low_timeout_connect(const char *hostname, unsigned int port, unsigned int connect_timeout, @@ -189,7 +189,7 @@ low_timeout_connect(const char *hostname, char buf[GETHOSTBYNAME_AUX_BUFLEN]; #endif /* HAVE_FUNC_GETHOSTBYNAME_R_6 */ struct hostent *hptr; - + if (!hostname || !port || !connect_timeout) { CEREBRO_DBG(("invalid parameters")); @@ -197,14 +197,14 @@ low_timeout_connect(const char *hostname, *errnum = CEREBRO_ERR_INTERNAL; return -1; } - + #ifdef HAVE_FUNC_GETHOSTBYNAME_R_6 memset(&hent, '\0', sizeof(struct hostent)); - if (gethostbyname_r(hostname, - &hent, - buf, - GETHOSTBYNAME_AUX_BUFLEN, - &hptr, + if (gethostbyname_r(hostname, + &hent, + buf, + GETHOSTBYNAME_AUX_BUFLEN, + &hptr, &h_errnop) != 0) { CEREBRO_ERR(("gethostbyname_r: %s", hstrerror(h_errnop))); @@ -229,9 +229,9 @@ low_timeout_connect(const char *hostname, return -1; } #endif /* !HAVE_FUNC_GETHOSTBYNAME_R */ - + /* Alot of this code is from Unix Network Programming, by Stevens */ - + if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { CEREBRO_ERR(("socket: %s", strerror(errno))); @@ -244,7 +244,7 @@ low_timeout_connect(const char *hostname, addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr = *((struct in_addr *)hptr->h_addr); - + if ((old_flags = fcntl(fd, F_GETFL, 0)) < 0) { CEREBRO_ERR(("fcntl: %s", strerror(errno))); @@ -252,7 +252,7 @@ low_timeout_connect(const char *hostname, *errnum = CEREBRO_ERR_INTERNAL; goto cleanup; } - + if (fcntl(fd, F_SETFL, old_flags | O_NONBLOCK) < 0) { CEREBRO_ERR(("fcntl: %s", strerror(errno))); @@ -272,14 +272,14 @@ low_timeout_connect(const char *hostname, { fd_set rset, wset; struct timeval tval; - + FD_ZERO(&rset); FD_SET(fd, &rset); FD_ZERO(&wset); FD_SET(fd, &wset); tval.tv_sec = connect_timeout; tval.tv_usec = 0; - + if ((rv = select(fd+1, &rset, &wset, NULL, &tval)) < 0) { CEREBRO_ERR(("select: %s", strerror(errno))); @@ -287,7 +287,7 @@ low_timeout_connect(const char *hostname, *errnum = CEREBRO_ERR_INTERNAL; goto cleanup; } - + if (!rv) { if (errnum) @@ -300,9 +300,9 @@ low_timeout_connect(const char *hostname, { unsigned int len; int error; - + len = sizeof(int); - + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { CEREBRO_ERR(("getsockopt: %s", strerror(errno))); @@ -310,7 +310,7 @@ low_timeout_connect(const char *hostname, *errnum = CEREBRO_ERR_INTERNAL; goto cleanup; } - + if (error != 0) { errno = error; @@ -333,7 +333,7 @@ low_timeout_connect(const char *hostname, } } } - + /* reset flags */ if (fcntl(fd, F_SETFL, old_flags) < 0) { diff --git a/src/libs/util/network_util.h b/src/libs/util/network_util.h index d80168ff..ba7c35f3 100644 --- a/src/libs/util/network_util.h +++ b/src/libs/util/network_util.h @@ -28,7 +28,7 @@ #ifndef _NETWORK_UTIL_H #define _NETWORK_UTIL_H -/* +/* * receive_data * * Receive a certain amount of data diff --git a/src/libs/wrappers/wrappers.c b/src/libs/wrappers/wrappers.c index a2534ad7..63c5c6d0 100644 --- a/src/libs/wrappers/wrappers.c +++ b/src/libs/wrappers/wrappers.c @@ -51,7 +51,7 @@ wrap_malloc(WRAPPERS_ARGS, size_t size) if (!(size > 0 || size <= INT_MAX)) WRAPPERS_ERR_INVALID_PARAMETERS("malloc"); - if (!(ptr = malloc(2*sizeof(int) + size + MALLOC_PAD_LEN))) + if (!(ptr = malloc(2*sizeof(int) + size + MALLOC_PAD_LEN))) WRAPPERS_ERR_ERRNO("malloc"); *((int *)(ptr)) = MALLOC_MAGIC; @@ -83,7 +83,7 @@ wrap_free(WRAPPERS_ARGS, void *ptr) free(p); } -void +void _Free(void *ptr) { wrap_free(__FILE__, __FUNCTION__, __LINE__, ptr); @@ -119,13 +119,13 @@ wrap_strncpy(WRAPPERS_ARGS, char *dest, const char *src, size_t n) return rv; } -int +int wrap_open(WRAPPERS_ARGS, const char *pathname, int flags, int mode) { int fd; assert(file && function); - + if (!pathname) WRAPPERS_ERR_INVALID_PARAMETERS("open"); @@ -135,13 +135,13 @@ wrap_open(WRAPPERS_ARGS, const char *pathname, int flags, int mode) return fd; } -int +int wrap_close(WRAPPERS_ARGS, int fd) { int rv; - + assert(file && function); - + if ((rv = close(fd)) < 0) WRAPPERS_ERR_ERRNO("close"); @@ -152,7 +152,7 @@ ssize_t wrap_read(WRAPPERS_ARGS, int fd, void *buf, size_t count) { ssize_t rv; - + assert(file && function); if (!buf || !(count > 0 || count <= INT_MAX)) @@ -164,7 +164,7 @@ wrap_read(WRAPPERS_ARGS, int fd, void *buf, size_t count) if (rv < 0) WRAPPERS_ERR_ERRNO("read"); - + return rv; } @@ -204,7 +204,7 @@ wrap_chdir(WRAPPERS_ARGS, const char *path) return rv; } -int +int wrap_stat(WRAPPERS_ARGS, const char *path, struct stat *buf) { int rv; @@ -233,7 +233,7 @@ DIR * wrap_opendir(WRAPPERS_ARGS, const char *name) { DIR *rv; - + assert(file && function); if (!name) @@ -274,11 +274,11 @@ wrap_socket(WRAPPERS_ARGS, int domain, int type, int protocol) return fd; } -int +int wrap_bind(WRAPPERS_ARGS, int sockfd, struct sockaddr *my_addr, socklen_t addrlen) { int rv; - + assert(file && function); if (!my_addr || !(addrlen > 0 || addrlen <= INT_MAX)) @@ -290,7 +290,7 @@ wrap_bind(WRAPPERS_ARGS, int sockfd, struct sockaddr *my_addr, socklen_t addrlen return rv; } -int +int wrap_connect(WRAPPERS_ARGS, int sockfd, struct sockaddr *serv_addr, socklen_t addrlen) { int rv; @@ -306,7 +306,7 @@ wrap_connect(WRAPPERS_ARGS, int sockfd, struct sockaddr *serv_addr, socklen_t ad return rv; } -int +int wrap_listen(WRAPPERS_ARGS, int s, int backlog) { int rv; @@ -322,7 +322,7 @@ wrap_listen(WRAPPERS_ARGS, int s, int backlog) return rv; } -int +int wrap_accept(WRAPPERS_ARGS, int s, struct sockaddr *addr, socklen_t *addrlen) { int rv; @@ -338,13 +338,13 @@ wrap_accept(WRAPPERS_ARGS, int s, struct sockaddr *addr, socklen_t *addrlen) return rv; } -int +int wrap_select(WRAPPERS_ARGS, int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { int rv; struct timeval timeout_orig; struct timeval start, end, delta; - + assert(file && function); /* readfds, writefds, exceptfds, and timeout could each be null, but @@ -353,7 +353,7 @@ wrap_select(WRAPPERS_ARGS, int n, fd_set *readfds, fd_set *writefds, fd_set *exc if (!readfds && !writefds && !exceptfds && !timeout) WRAPPERS_ERR_INVALID_PARAMETERS("select"); - if (timeout) + if (timeout) { timeout_orig = *timeout; Gettimeofday(&start, NULL); @@ -365,37 +365,37 @@ wrap_select(WRAPPERS_ARGS, int n, fd_set *readfds, fd_set *writefds, fd_set *exc timeout_orig.tv_usec = 0; } - do + do { rv = select(n, readfds, writefds, exceptfds, timeout); if (rv < 0 && errno != EINTR) WRAPPERS_ERR_ERRNO("select"); - if (rv < 0 && timeout) + if (rv < 0 && timeout) { Gettimeofday(&end, NULL); /* delta = end-start */ - timersub(&end, &start, &delta); + timersub(&end, &start, &delta); /* timeout = timeout_orig-delta */ - timersub(&timeout_orig, &delta, timeout); + timersub(&timeout_orig, &delta, timeout); } - } + } while (rv < 0); return rv; } -int +int wrap_poll(WRAPPERS_ARGS, struct pollfd *ufds, unsigned int nfds, int timeout) { int rv; struct timeval timeout_orig, timeout_current; struct timeval start, end, delta; - - if (!ufds) + + if (!ufds) WRAPPERS_ERR_INVALID_PARAMETERS("poll"); /* Poll uses timeout in milliseconds */ - if (timeout >= 0) + if (timeout >= 0) { timeout_orig.tv_sec = (long)timeout/1000; timeout_orig.tv_usec = (timeout % 1000) * 1000; @@ -415,13 +415,13 @@ wrap_poll(WRAPPERS_ARGS, struct pollfd *ufds, unsigned int nfds, int timeout) if (rv < 0 && timeout >= 0) { Gettimeofday(&end, NULL); /* delta = end-start */ - timersub(&end, &start, &delta); + timersub(&end, &start, &delta); /* timeout_current = timeout_orig-delta */ timersub(&timeout_orig, &delta, &timeout_current); timeout = (timeout_current.tv_sec * 1000) + (timeout_current.tv_usec/1000); } } while (rv < 0); - + return rv; } @@ -485,15 +485,15 @@ wrap_inet_ntop(WRAPPERS_ARGS, int af, const void *src, char *dst, socklen_t cnt) if ((rv = inet_ntop(af, src, dst, cnt)) < 0) WRAPPERS_ERR_ERRNO("inet_ntop"); - + return rv; } -int +int wrap_inet_pton(WRAPPERS_ARGS, int af, const char *src, void *dst) { int rv; - + assert(file && function); if (!src || !dst) @@ -509,15 +509,15 @@ struct tm * wrap_localtime(WRAPPERS_ARGS, const time_t *timep) { struct tm *tmptr; - + assert(file && function); - + if (!timep) WRAPPERS_ERR_INVALID_PARAMETERS("localtime"); - + if (!(tmptr = localtime(timep))) WRAPPERS_ERR_ERRNO("localtime"); - + return tmptr; } @@ -525,15 +525,15 @@ struct tm * wrap_localtime_r(WRAPPERS_ARGS, const time_t *timep, struct tm *result) { struct tm *tmptr; - + assert(file && function); - + if (!timep || !result) WRAPPERS_ERR_INVALID_PARAMETERS("localtime_r"); - + if (!(tmptr = localtime_r(timep, result))) WRAPPERS_ERR_ERRNO("localtime_r"); - + return tmptr; } @@ -588,7 +588,7 @@ wrap_gettimeofday_workaround(WRAPPERS_ARGS, struct timeval *tv, struct timezone WRAPPERS_ERR_ERRNO("gettimeofday"); if ((ret2 = gettimeofday(&tv2, tz))) WRAPPERS_ERR_ERRNO("gettimeofday"); - + if (abs(tv1.tv_sec - tv2.tv_sec) < GETTIMEOFDAY_RANGE) { tv->tv_sec = tv2.tv_sec; @@ -608,7 +608,7 @@ wrap_gettimeofday_workaround(WRAPPERS_ARGS, struct timeval *tv, struct timezone return rv; } -pid_t +pid_t wrap_fork(WRAPPERS_ARGS) { pid_t pid; @@ -637,7 +637,7 @@ wrap_signal(WRAPPERS_ARGS, int signum, Sighandler_t handler) return rv; } -int +int wrap_gethostname(WRAPPERS_ARGS, char *name, size_t len) { int rv; diff --git a/src/libs/wrappers/wrappers.h b/src/libs/wrappers/wrappers.h index acfdc9df..cf32df70 100644 --- a/src/libs/wrappers/wrappers.h +++ b/src/libs/wrappers/wrappers.h @@ -103,8 +103,8 @@ file, function, line, msg); \ } while(0); -/* - * Memory/String Wrappers +/* + * Memory/String Wrappers */ #define Malloc(size) \ wrap_malloc(WRAPPERS_DEBUG_ARGS, size) @@ -123,17 +123,17 @@ char * wrap_strncpy(WRAPPERS_ARGS, char *dest, const char *src, size_t n); /* Special wrapper for List/Hash libraries */ void _Free(void *ptr); -/* - * File System Wrappers +/* + * File System Wrappers */ #define Open(pathname, flags, mode) \ wrap_open(WRAPPERS_DEBUG_ARGS, pathname, flags, mode) #define Close(fd) \ wrap_close(WRAPPERS_DEBUG_ARGS, fd) #define Read(fd, buf, count) \ - wrap_read(WRAPPERS_DEBUG_ARGS, fd, buf, count) + wrap_read(WRAPPERS_DEBUG_ARGS, fd, buf, count) #define Write(fd, buf, count) \ - wrap_write(WRAPPERS_DEBUG_ARGS, fd, buf, count) + wrap_write(WRAPPERS_DEBUG_ARGS, fd, buf, count) #define Chdir(path) \ wrap_chdir(WRAPPERS_DEBUG_ARGS, path) #define Stat(path, buf) \ @@ -155,8 +155,8 @@ mode_t wrap_umask(WRAPPERS_ARGS, mode_t mask); DIR *wrap_opendir(WRAPPERS_ARGS, const char *name); int wrap_closedir(WRAPPERS_ARGS, DIR *dir); -/* - * Networking Wrappers +/* + * Networking Wrappers */ #define Socket(domain, type, protocol) \ wrap_socket(WRAPPERS_DEBUG_ARGS, domain, type, protocol) @@ -196,8 +196,8 @@ struct hostent *wrap_gethostbyname(WRAPPERS_ARGS, const char *name); const char *wrap_inet_ntop(WRAPPERS_ARGS, int af, const void *src, char *dst, socklen_t cnt); int wrap_inet_pton(WRAPPERS_ARGS, int af, const char *src, void *dst); -/* - * Time Wrappers +/* + * Time Wrappers */ #define Localtime(timep) \ wrap_localtime(__FILE__, __FUNCTION__, __LINE__, timep) @@ -213,8 +213,8 @@ struct tm *wrap_localtime_r(WRAPPERS_ARGS, const time_t *timep, struct tm *resul int wrap_gettimeofday(WRAPPERS_ARGS, struct timeval *tv, struct timezone *tz); int wrap_gettimeofday_workaround(WRAPPERS_ARGS, struct timeval *tv, struct timezone *tz); -/* - * Misc System Call Wrappers +/* + * Misc System Call Wrappers */ #define Fork() \ wrap_fork(WRAPPERS_DEBUG_ARGS); @@ -229,8 +229,8 @@ pid_t wrap_fork(WRAPPERS_ARGS); Sighandler_t wrap_signal(WRAPPERS_ARGS, int signum, Sighandler_t handler); int wrap_gethostname(WRAPPERS_ARGS, char *name, size_t len); -/* - * Pthread Wrappers +/* + * Pthread Wrappers */ #define Pthread_create(thread, attr, start_routine, arg) \ wrap_pthread_create(WRAPPERS_DEBUG_ARGS, thread, attr, start_routine, arg) @@ -267,8 +267,8 @@ int wrap_pthread_mutex_init(WRAPPERS_ARGS, pthread_mutex_t *mutex, const pthread int wrap_pthread_cond_signal(WRAPPERS_ARGS, pthread_cond_t *cond); int wrap_pthread_cond_wait(WRAPPERS_ARGS, pthread_cond_t *cond, pthread_mutex_t *mutex); -/* - * List lib wrappers +/* + * List lib wrappers */ #define List_create(f) \ wrap_list_create(WRAPPERS_DEBUG_ARGS, f) @@ -311,8 +311,8 @@ void wrap_list_iterator_destroy(WRAPPERS_ARGS, ListIterator i); void *wrap_list_remove(WRAPPERS_ARGS, ListIterator i); int wrap_list_delete(WRAPPERS_ARGS, ListIterator i); -/* - * Hash lib wrappers +/* + * Hash lib wrappers */ #define Hash_create(size, key_f, cmp_f, del_f) \ wrap_hash_create(WRAPPERS_DEBUG_ARGS, size, key_f, cmp_f, del_f) @@ -343,8 +343,8 @@ int wrap_hash_delete_if(WRAPPERS_ARGS, hash_t h, hash_arg_f argf, void *arg); int wrap_hash_for_each(WRAPPERS_ARGS, hash_t h, hash_arg_f argf, void *arg); void wrap_hash_destroy(WRAPPERS_ARGS, hash_t h); -/* - * Hostlist lib wrappers +/* + * Hostlist lib wrappers */ #define Hostlist_create(hostlist) \ wrap_hostlist_create(WRAPPERS_DEBUG_ARGS, hostlist) @@ -381,7 +381,7 @@ hostlist_iterator_t wrap_hostlist_iterator_create(WRAPPERS_ARGS, hostlist_t hl); void wrap_hostlist_iterator_destroy(WRAPPERS_ARGS, hostlist_iterator_t i); char *wrap_hostlist_next(WRAPPERS_ARGS, hostlist_iterator_t i); -/* +/* * Marshall wrappers */ @@ -429,5 +429,5 @@ int wrap_unmarshall_float(WRAPPERS_ARGS, float *val, const char *buf, unsigned i int wrap_unmarshall_double(WRAPPERS_ARGS, double *val, const char *buf, unsigned int buflen); int wrap_unmarshall_buffer(WRAPPERS_ARGS, char *val, unsigned int vallen, const char *buf, unsigned int buflen); - + #endif /* _WRAPPERS_H */ diff --git a/src/libs/wrappers/wrappers_hash.c b/src/libs/wrappers/wrappers_hash.c index 6d5ae1c9..59b73d83 100644 --- a/src/libs/wrappers/wrappers_hash.c +++ b/src/libs/wrappers/wrappers_hash.c @@ -35,7 +35,7 @@ #include "wrappers.h" -hash_t +hash_t wrap_hash_create(WRAPPERS_ARGS, int size, hash_key_f key_f, hash_cmp_f cmp_f, hash_del_f del_f) { hash_t rv; @@ -51,7 +51,7 @@ wrap_hash_create(WRAPPERS_ARGS, int size, hash_key_f key_f, hash_cmp_f cmp_f, ha return rv; } -int +int wrap_hash_count(WRAPPERS_ARGS, hash_t h) { int rv; @@ -122,13 +122,13 @@ wrap_hash_remove(WRAPPERS_ARGS, hash_t h, const void *key) return rv; } -int +int wrap_hash_remove_if(WRAPPERS_ARGS, hash_t h, hash_arg_f argf, void *arg) { int rv; assert(file && function); - + if (!h || !argf) WRAPPERS_ERR_INVALID_PARAMETERS("hash_remove_if"); @@ -138,13 +138,13 @@ wrap_hash_remove_if(WRAPPERS_ARGS, hash_t h, hash_arg_f argf, void *arg) return rv; } -int +int wrap_hash_delete_if(WRAPPERS_ARGS, hash_t h, hash_arg_f argf, void *arg) { int rv; assert(file && function); - + if (!h || !argf) WRAPPERS_ERR_INVALID_PARAMETERS("hash_delete_if"); @@ -154,7 +154,7 @@ wrap_hash_delete_if(WRAPPERS_ARGS, hash_t h, hash_arg_f argf, void *arg) return rv; } -int +int wrap_hash_for_each(WRAPPERS_ARGS, hash_t h, hash_arg_f argf, void *arg) { int rv; diff --git a/src/libs/wrappers/wrappers_hostlist.c b/src/libs/wrappers/wrappers_hostlist.c index 8a3f28b4..c4d83d89 100644 --- a/src/libs/wrappers/wrappers_hostlist.c +++ b/src/libs/wrappers/wrappers_hostlist.c @@ -35,7 +35,7 @@ #include "wrappers.h" -hostlist_t +hostlist_t wrap_hostlist_create(WRAPPERS_ARGS, const char *hostlist) { hostlist_t rv; @@ -60,7 +60,7 @@ wrap_hostlist_destroy(WRAPPERS_ARGS, hostlist_t hl) return; } -void +void wrap_hostlist_sort(WRAPPERS_ARGS, hostlist_t hl) { assert(file && function); @@ -72,7 +72,7 @@ wrap_hostlist_sort(WRAPPERS_ARGS, hostlist_t hl) return; } -void +void wrap_hostlist_uniq(WRAPPERS_ARGS, hostlist_t hl) { assert(file && function); @@ -84,7 +84,7 @@ wrap_hostlist_uniq(WRAPPERS_ARGS, hostlist_t hl) return; } -int +int wrap_hostlist_push(WRAPPERS_ARGS, hostlist_t hl, const char *host) { int rv; @@ -100,7 +100,7 @@ wrap_hostlist_push(WRAPPERS_ARGS, hostlist_t hl, const char *host) return rv; } -int +int wrap_hostlist_find(WRAPPERS_ARGS, hostlist_t hl, const char *hostname) { assert(file && function); @@ -112,7 +112,7 @@ wrap_hostlist_find(WRAPPERS_ARGS, hostlist_t hl, const char *hostname) return hostlist_find(hl, hostname); } -ssize_t +ssize_t wrap_hostlist_ranged_string(WRAPPERS_ARGS, hostlist_t hl, size_t n, char *buf) { ssize_t rv; @@ -128,7 +128,7 @@ wrap_hostlist_ranged_string(WRAPPERS_ARGS, hostlist_t hl, size_t n, char *buf) return rv; } -ssize_t +ssize_t wrap_hostlist_deranged_string(WRAPPERS_ARGS, hostlist_t hl, size_t n, char *buf) { ssize_t rv; @@ -144,7 +144,7 @@ wrap_hostlist_deranged_string(WRAPPERS_ARGS, hostlist_t hl, size_t n, char *buf) return rv; } -hostlist_iterator_t +hostlist_iterator_t wrap_hostlist_iterator_create(WRAPPERS_ARGS, hostlist_t hl) { hostlist_iterator_t rv; @@ -178,6 +178,6 @@ wrap_hostlist_next(WRAPPERS_ARGS, hostlist_iterator_t i) /* Can return NULL value to indicate end of list */ rv = hostlist_next(i); - + return rv; } diff --git a/src/libs/wrappers/wrappers_list.c b/src/libs/wrappers/wrappers_list.c index a2d117b1..f3edffd0 100644 --- a/src/libs/wrappers/wrappers_list.c +++ b/src/libs/wrappers/wrappers_list.c @@ -34,7 +34,7 @@ #include "wrappers.h" -List +List wrap_list_create(WRAPPERS_ARGS, ListDelF f) { List rv; @@ -83,11 +83,11 @@ wrap_list_append (WRAPPERS_ARGS, List l, void *x) if (!(rv = list_append(l, x))) WRAPPERS_ERR_ERRNO("list_append"); - + return rv; } -void * +void * wrap_list_find_first (WRAPPERS_ARGS, List l, ListFindF f, void *key) { assert(file && function); @@ -98,7 +98,7 @@ wrap_list_find_first (WRAPPERS_ARGS, List l, ListFindF f, void *key) return list_find_first(l, f, key); } -int +int wrap_list_delete_all(WRAPPERS_ARGS, List l, ListFindF f, void *key) { int rv; @@ -110,7 +110,7 @@ wrap_list_delete_all(WRAPPERS_ARGS, List l, ListFindF f, void *key) if ((rv = list_delete_all(l, f, key)) < 0) WRAPPERS_ERR_ERRNO("list_delete_all"); - + return rv; } @@ -126,7 +126,7 @@ wrap_list_for_each(WRAPPERS_ARGS, List l, ListForF f, void *arg) if ((rv = list_for_each(l, f, arg)) < 0) WRAPPERS_ERR_ERRNO("list_for_each"); - + return rv; } @@ -151,7 +151,7 @@ wrap_list_peek(WRAPPERS_ARGS, List l) if (!l) WRAPPERS_ERR_INVALID_PARAMETERS("list_peek"); - + rv = list_peek(l); return rv; @@ -201,7 +201,7 @@ wrap_list_remove(WRAPPERS_ARGS, ListIterator i) return rv; } -int +int wrap_list_delete(WRAPPERS_ARGS, ListIterator i) { int rv; diff --git a/src/libs/wrappers/wrappers_marshall.c b/src/libs/wrappers/wrappers_marshall.c index 6c0f56ab..134af5b7 100644 --- a/src/libs/wrappers/wrappers_marshall.c +++ b/src/libs/wrappers/wrappers_marshall.c @@ -34,7 +34,7 @@ #include "wrappers.h" -int +int wrap_marshall_int8(WRAPPERS_ARGS, int8_t val, char *buf, unsigned int buflen) { int rv; @@ -50,7 +50,7 @@ wrap_marshall_int8(WRAPPERS_ARGS, int8_t val, char *buf, unsigned int buflen) return rv; } -int +int wrap_marshall_int32(WRAPPERS_ARGS, int32_t val, char *buf, unsigned int buflen) { int rv; @@ -66,7 +66,7 @@ wrap_marshall_int32(WRAPPERS_ARGS, int32_t val, char *buf, unsigned int buflen) return rv; } -int +int wrap_marshall_u_int8(WRAPPERS_ARGS, u_int8_t val, char *buf, unsigned int buflen) { int rv; @@ -82,7 +82,7 @@ wrap_marshall_u_int8(WRAPPERS_ARGS, u_int8_t val, char *buf, unsigned int buflen return rv; } -int +int wrap_marshall_u_int32(WRAPPERS_ARGS, u_int32_t val, char *buf, unsigned int buflen) { int rv; @@ -98,7 +98,7 @@ wrap_marshall_u_int32(WRAPPERS_ARGS, u_int32_t val, char *buf, unsigned int bufl return rv; } -int +int wrap_marshall_float(WRAPPERS_ARGS, float val, char *buf, unsigned int buflen) { int rv; @@ -114,7 +114,7 @@ wrap_marshall_float(WRAPPERS_ARGS, float val, char *buf, unsigned int buflen) return rv; } -int +int wrap_marshall_double(WRAPPERS_ARGS, double val, char *buf, unsigned int buflen) { int rv; @@ -130,7 +130,7 @@ wrap_marshall_double(WRAPPERS_ARGS, double val, char *buf, unsigned int buflen) return rv; } -int +int wrap_marshall_buffer(WRAPPERS_ARGS, const char *val, unsigned int vallen, char *buf, unsigned int buflen) { int rv; @@ -146,7 +146,7 @@ wrap_marshall_buffer(WRAPPERS_ARGS, const char *val, unsigned int vallen, char * return rv; } -int +int wrap_unmarshall_int8(WRAPPERS_ARGS, int8_t *val, const char *buf, unsigned int buflen) { int rv; @@ -162,7 +162,7 @@ wrap_unmarshall_int8(WRAPPERS_ARGS, int8_t *val, const char *buf, unsigned int b return rv; } -int +int wrap_unmarshall_int32(WRAPPERS_ARGS, int32_t *val, const char *buf, unsigned int buflen) { int rv; @@ -178,7 +178,7 @@ wrap_unmarshall_int32(WRAPPERS_ARGS, int32_t *val, const char *buf, unsigned int return rv; } -int +int wrap_unmarshall_u_int8(WRAPPERS_ARGS, u_int8_t *val, const char *buf, unsigned int buflen) { int rv; @@ -194,7 +194,7 @@ wrap_unmarshall_u_int8(WRAPPERS_ARGS, u_int8_t *val, const char *buf, unsigned i return rv; } -int +int wrap_unmarshall_u_int32(WRAPPERS_ARGS, u_int32_t *val, const char *buf, unsigned int buflen) { int rv; @@ -226,7 +226,7 @@ wrap_unmarshall_float(WRAPPERS_ARGS, float *val, const char *buf, unsigned int b return rv; } -int +int wrap_unmarshall_double(WRAPPERS_ARGS, double *val, const char *buf, unsigned int buflen) { int rv; @@ -242,7 +242,7 @@ wrap_unmarshall_double(WRAPPERS_ARGS, double *val, const char *buf, unsigned int return rv; } -int +int wrap_unmarshall_buffer(WRAPPERS_ARGS, char *val, unsigned int vallen, const char *buf, unsigned int buflen) { int rv; diff --git a/src/libs/wrappers/wrappers_pthread.c b/src/libs/wrappers/wrappers_pthread.c index e06f21fb..a0873573 100644 --- a/src/libs/wrappers/wrappers_pthread.c +++ b/src/libs/wrappers/wrappers_pthread.c @@ -34,11 +34,11 @@ #include "wrappers.h" -int +int wrap_pthread_create(WRAPPERS_ARGS, pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) { int rv; - + assert(file && function); if (!thread || !start_routine) @@ -50,11 +50,11 @@ wrap_pthread_create(WRAPPERS_ARGS, pthread_t *thread, pthread_attr_t *attr, void return rv; } -int +int wrap_pthread_attr_init(WRAPPERS_ARGS, pthread_attr_t *attr) { int rv; - + assert(file && function); if (!attr) @@ -66,11 +66,11 @@ wrap_pthread_attr_init(WRAPPERS_ARGS, pthread_attr_t *attr) return rv; } -int +int wrap_pthread_attr_destroy(WRAPPERS_ARGS, pthread_attr_t *attr) { int rv; - + assert(file && function); if (!attr) @@ -82,11 +82,11 @@ wrap_pthread_attr_destroy(WRAPPERS_ARGS, pthread_attr_t *attr) return rv; } -int +int wrap_pthread_attr_setdetachstate(WRAPPERS_ARGS, pthread_attr_t *attr, int detachstate) { int rv; - + assert(file && function); if (!attr) @@ -98,11 +98,11 @@ wrap_pthread_attr_setdetachstate(WRAPPERS_ARGS, pthread_attr_t *attr, int detach return rv; } -int +int wrap_pthread_attr_setstacksize(WRAPPERS_ARGS, pthread_attr_t *attr, size_t stacksize) { int rv; - + assert(file && function); if (!attr || stacksize < PTHREAD_STACK_MIN) @@ -118,7 +118,7 @@ int wrap_pthread_mutex_lock(WRAPPERS_ARGS, pthread_mutex_t *mutex) { int rv; - + assert(file && function); if (!mutex) @@ -130,11 +130,11 @@ wrap_pthread_mutex_lock(WRAPPERS_ARGS, pthread_mutex_t *mutex) return rv; } -int +int wrap_pthread_mutex_trylock(WRAPPERS_ARGS, pthread_mutex_t *mutex) { int rv; - + assert(file && function); if (!mutex) @@ -147,11 +147,11 @@ wrap_pthread_mutex_trylock(WRAPPERS_ARGS, pthread_mutex_t *mutex) return rv; } -int +int wrap_pthread_mutex_unlock(WRAPPERS_ARGS, pthread_mutex_t *mutex) { int rv; - + assert(file && function); if (!mutex) @@ -167,7 +167,7 @@ int wrap_pthread_mutex_init(WRAPPERS_ARGS, pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr) { int rv; - + assert(file && function); if (!mutex) @@ -179,7 +179,7 @@ wrap_pthread_mutex_init(WRAPPERS_ARGS, pthread_mutex_t *mutex, const pthread_mut return rv; } -int +int wrap_pthread_cond_signal(WRAPPERS_ARGS, pthread_cond_t *cond) { int rv; @@ -195,7 +195,7 @@ wrap_pthread_cond_signal(WRAPPERS_ARGS, pthread_cond_t *cond) return rv; } -int +int wrap_pthread_cond_wait(WRAPPERS_ARGS, pthread_cond_t *cond, pthread_mutex_t *mutex) { int rv; diff --git a/src/modules/clusterlist/cerebro_clusterlist_genders.c b/src/modules/clusterlist/cerebro_clusterlist_genders.c index 02295ae3..22310b1e 100644 --- a/src/modules/clusterlist/cerebro_clusterlist_genders.c +++ b/src/modules/clusterlist/cerebro_clusterlist_genders.c @@ -60,7 +60,7 @@ static genders_t gh = NULL; * * genders clusterlist module interface_version function */ -static int +static int genders_clusterlist_interface_version(void) { return CEREBRO_CLUSTERLIST_INTERFACE_VERSION; @@ -71,7 +71,7 @@ genders_clusterlist_interface_version(void) * * genders clusterlist module setup function */ -static int +static int genders_clusterlist_setup(void) { if (gh) @@ -102,7 +102,7 @@ genders_clusterlist_cleanup(void) * * genders clusterlist module numnodes function */ -static int +static int genders_clusterlist_numnodes(void) { if (!gh) @@ -133,7 +133,7 @@ genders_clusterlist_get_all_nodes(char ***nodes) CEREBRO_DBG(("invalid parameters")); return -1; } - + return cerebro_clusterlist_genders_get_all_nodes(gh, nodes); } @@ -190,8 +190,8 @@ genders_clusterlist_node_in_cluster(const char *node) * genders clusterlist module get_nodename function */ static int -genders_clusterlist_get_nodename(const char *node, - char *buf, +genders_clusterlist_get_nodename(const char *node, + char *buf, unsigned int buflen) { char nodebuf[CEREBRO_MAX_NODENAME_LEN+1]; @@ -208,7 +208,7 @@ genders_clusterlist_get_nodename(const char *node, CEREBRO_DBG(("invalid parameters")); return -1; } - + /* Shorten hostname if necessary */ if (strchr(node, '.')) { diff --git a/src/modules/clusterlist/cerebro_clusterlist_genders_util.c b/src/modules/clusterlist/cerebro_clusterlist_genders_util.c index bcfabab0..7295bc2a 100644 --- a/src/modules/clusterlist/cerebro_clusterlist_genders_util.c +++ b/src/modules/clusterlist/cerebro_clusterlist_genders_util.c @@ -42,11 +42,11 @@ #include "debug.h" -int +int cerebro_clusterlist_genders_setup(genders_t *gh, char *filename) { if (!gh) - { + { CEREBRO_DBG(("invalid parameters")); return -1; } @@ -104,7 +104,7 @@ cerebro_clusterlist_genders_cleanup(genders_t *gh) return 0; } -int +int cerebro_clusterlist_genders_numnodes(genders_t gh) { int num; @@ -129,7 +129,7 @@ cerebro_clusterlist_genders_get_all_nodes(genders_t gh, char ***nodes) { char **nodelist = NULL; int nodelistlen, num; - + if (!gh || !nodes) { CEREBRO_DBG(("invalid parameters")); @@ -141,7 +141,7 @@ cerebro_clusterlist_genders_get_all_nodes(genders_t gh, char ***nodes) CEREBRO_ERR(("genders_nodelist_create: %s", genders_errormsg(gh))); goto cleanup; } - + if ((num = genders_getnodes(gh, nodelist, nodelistlen, NULL, NULL)) < 0) { CEREBRO_ERR(("genders_getnodes: %s", genders_errormsg(gh))); diff --git a/src/modules/clusterlist/cerebro_clusterlist_genders_util.h b/src/modules/clusterlist/cerebro_clusterlist_genders_util.h index fd4947f9..9f09d00c 100644 --- a/src/modules/clusterlist/cerebro_clusterlist_genders_util.h +++ b/src/modules/clusterlist/cerebro_clusterlist_genders_util.h @@ -28,28 +28,28 @@ #ifndef _CEREBRO_CLUSTERLIST_GENDERS_UTIL_H #define _CEREBRO_CLUSTERLIST_GENDERS_UTIL_H -/* +/* * cerebro_clusterlist_genders_setup * * common setup function for genders and gendersllnl setup */ int cerebro_clusterlist_genders_setup(genders_t *gh, char *filename); -/* +/* * cerebro_clusterlist_genders_cleanup * * common cleanup function for genders and gendersllnl cleanup */ int cerebro_clusterlist_genders_cleanup(genders_t *gh); -/* +/* * cerebro_clusterlist_genders_numnodes * * common numnodes function for genders and gendersllnl numnodes */ int cerebro_clusterlist_genders_numnodes(genders_t gh); -/* +/* * cerebro_clusterlist_genders_get_all_nodes * * common get_all_nodes function for genders and gendersllnl get_all_nodes diff --git a/src/modules/clusterlist/cerebro_clusterlist_hostsfile.c b/src/modules/clusterlist/cerebro_clusterlist_hostsfile.c index bd3d2f0d..cb6f3822 100644 --- a/src/modules/clusterlist/cerebro_clusterlist_hostsfile.c +++ b/src/modules/clusterlist/cerebro_clusterlist_hostsfile.c @@ -55,7 +55,7 @@ #define HOSTSFILE_CLUSTERLIST_MODULE_NAME "hostsfile" #define HOSTSFILE_PARSE_BUFLEN 4096 -/* +/* * hosts * * Store all of the hosts found in the hostsfile @@ -67,15 +67,15 @@ static List hosts = NULL; * * hostsfile clusterlist module interface_version function */ -static int +static int hostsfile_clusterlist_interface_version(void) { return CEREBRO_CLUSTERLIST_INTERFACE_VERSION; } -/* +/* * _readline - * + * * read a line from the hostsfile. Buffer guaranteed to be null * terminated. * @@ -101,7 +101,7 @@ _readline(int fd, char *buf, unsigned int buflen) CEREBRO_ERR(("fd_read_line: %s", strerror(errno))); return -1; } - + /* buflen - 1 b/c fd_read_line guarantees null termination */ if (len >= (buflen-1)) { @@ -112,7 +112,7 @@ _readline(int fd, char *buf, unsigned int buflen) return len; } -/* +/* * _remove_comments * * remove comments from the buffer @@ -160,7 +160,7 @@ _remove_comments(char *buf, int buflen) return lenleft; } -/* +/* * _remove_trailing_whitespace * * remove trailing whitespace from the buffer @@ -175,7 +175,7 @@ static int _remove_trailing_whitespace(char *buf, int buflen) { char *temp; - + if (!buf) { CEREBRO_DBG(("invalid parameters")); @@ -183,7 +183,7 @@ _remove_trailing_whitespace(char *buf, int buflen) } temp = buf + buflen; - for (--temp; temp >= buf; temp--) + for (--temp; temp >= buf; temp--) { if (isspace(*temp)) *temp = '\0'; @@ -195,7 +195,7 @@ _remove_trailing_whitespace(char *buf, int buflen) return buflen; } -/* +/* * _move_past_whitespace * * move past whitespace at the beginning of the buffer @@ -220,13 +220,13 @@ _move_past_whitespace(char *buf) return buf; } -/* +/* * hostsfile_clusterlist_setup * * hostsfile clusterlist module setup function. Open hostsfile, read * each line of the hostsfile, and save hosts into hosts list. */ -static int +static int hostsfile_clusterlist_setup(void) { int len, fd = -1; @@ -247,11 +247,11 @@ hostsfile_clusterlist_setup(void) if ((fd = open(CEREBRO_CLUSTERLIST_HOSTSFILE_DEFAULT, O_RDONLY)) < 0) { - CEREBRO_ERR(("hostsfile '%s' cannot be opened: %s", + CEREBRO_ERR(("hostsfile '%s' cannot be opened: %s", CEREBRO_CLUSTERLIST_HOSTSFILE_DEFAULT, strerror(errno))); goto cleanup; } - + while ((len = _readline(fd, buf, HOSTSFILE_PARSE_BUFLEN)) > 0) { char *hostPtr; @@ -286,7 +286,7 @@ hostsfile_clusterlist_setup(void) cerebro_err_output("hostsfile node '%s' exceeds max length", hostPtr); goto cleanup; } - + /* Shorten hostname if necessary */ if ((p = strchr(hostPtr, '.'))) *p = '\0'; @@ -303,7 +303,7 @@ hostsfile_clusterlist_setup(void) goto cleanup; } } - + if (len < 0) goto cleanup; @@ -342,7 +342,7 @@ hostsfile_clusterlist_cleanup(void) * * hostsfile clusterlist module numnodes function */ -static int +static int hostsfile_clusterlist_numnodes(void) { if (!hosts) @@ -374,7 +374,7 @@ hostsfile_clusterlist_get_all_nodes(char ***nodes) } if (!nodes) - { + { CEREBRO_DBG(("invalid parameters")); return -1; } @@ -432,7 +432,7 @@ hostsfile_clusterlist_get_all_nodes(char ***nodes) /* * list_strcmp * - * strcmp for list data structure + * strcmp for list data structure */ static int list_strcmp(void *x, void *key) @@ -467,7 +467,7 @@ hostsfile_clusterlist_node_in_cluster(const char *node) } if (!node) - { + { CEREBRO_DBG(("invalid parameters")); return -1; } @@ -497,8 +497,8 @@ hostsfile_clusterlist_node_in_cluster(const char *node) * hostsfile clusterlist module get_nodename function */ static int -hostsfile_clusterlist_get_nodename(const char *node, - char *buf, +hostsfile_clusterlist_get_nodename(const char *node, + char *buf, unsigned int buflen) { char nodebuf[CEREBRO_MAX_NODENAME_LEN+1]; diff --git a/src/modules/clusterlist/cerebro_clusterlist_util.c b/src/modules/clusterlist/cerebro_clusterlist_util.c index ec38e501..962b9c24 100644 --- a/src/modules/clusterlist/cerebro_clusterlist_util.c +++ b/src/modules/clusterlist/cerebro_clusterlist_util.c @@ -39,7 +39,7 @@ #include "debug.h" -int +int cerebro_copy_nodename(const char *node, char *buf, unsigned int buflen) { int len; diff --git a/src/modules/clusterlist/cerebro_clusterlist_util.h b/src/modules/clusterlist/cerebro_clusterlist_util.h index ac4a3a84..2e6a3030 100644 --- a/src/modules/clusterlist/cerebro_clusterlist_util.h +++ b/src/modules/clusterlist/cerebro_clusterlist_util.h @@ -28,7 +28,7 @@ #ifndef _CEREBRO_CLUSTERLIST_UTIL_H #define _CEREBRO_CLUSTERLIST_UTIL_H -/* +/* * cerebro_copy_nodename * * Copy a node string into a buffer, checking for length appropriately diff --git a/src/modules/event/cerebro_event_updown.c b/src/modules/event/cerebro_event_updown.c index 90fb80a6..1842c5a6 100644 --- a/src/modules/event/cerebro_event_updown.c +++ b/src/modules/event/cerebro_event_updown.c @@ -98,7 +98,7 @@ updown_event_setup(void) CEREBRO_ERR(("hash_create: %s", strerror(errno))); goto cleanup; } - + if (!(node_states_nodenames = list_create((ListDelF)free))) { CEREBRO_ERR(("list_create: %s", strerror(errno))); @@ -165,7 +165,7 @@ updown_event_timeout_length(void) return UPDOWN_EVENT_TIMEOUT_LENGTH; } -/* +/* * _create_entry * * Create an entry in the node_states hash @@ -181,7 +181,7 @@ _create_entry(const char *nodename) CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + if (!(nodePtr = (char *)malloc(CEREBRO_MAX_NODENAME_LEN + 1))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); @@ -189,7 +189,7 @@ _create_entry(const char *nodename) } strncpy(nodePtr, nodename, CEREBRO_MAX_NODENAME_LEN); - + if (!list_append(node_states_nodenames, nodePtr)) { CEREBRO_DBG(("list_append: %s", strerror(errno))); @@ -211,7 +211,7 @@ _create_entry(const char *nodename) return NULL; } -/* +/* * _create_event * * Create an event @@ -238,7 +238,7 @@ _create_event(const char *nodename, int state) CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *((int *)event->event_value) = state; return event; @@ -296,7 +296,7 @@ updown_event_node_timeout(const char *nodename, rv = 1; } } - + *state = UPDOWN_EVENT_STATE_DOWN; return rv; } @@ -307,7 +307,7 @@ updown_event_node_timeout(const char *nodename, * updown event module metric_update function. Store results the * updown cache appropriately. */ -static int +static int updown_event_metric_update(const char *nodename, const char *metric_name, unsigned int metric_value_type, @@ -336,7 +336,7 @@ updown_event_metric_update(const char *nodename, rv = 1; } } - + *state = UPDOWN_EVENT_STATE_UP; return rv; } diff --git a/src/modules/metric/cerebro_metric_bytesin.c b/src/modules/metric/cerebro_metric_bytesin.c index 699ddec2..5b380e5b 100644 --- a/src/modules/metric/cerebro_metric_bytesin.c +++ b/src/modules/metric/cerebro_metric_bytesin.c @@ -76,7 +76,7 @@ bytesin_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_network(&bytesinval, NULL, NULL, @@ -84,13 +84,13 @@ bytesin_metric_get_metric_value(unsigned int *metric_value_type, NULL, NULL) < 0) goto cleanup; - + if (!(bytesinptr = (u_int64_t *)malloc(sizeof(u_int64_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *bytesinptr = bytesinval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT64; diff --git a/src/modules/metric/cerebro_metric_bytesout.c b/src/modules/metric/cerebro_metric_bytesout.c index 994af876..26503a95 100644 --- a/src/modules/metric/cerebro_metric_bytesout.c +++ b/src/modules/metric/cerebro_metric_bytesout.c @@ -76,7 +76,7 @@ bytesout_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_network(NULL, &bytesoutval, NULL, @@ -84,13 +84,13 @@ bytesout_metric_get_metric_value(unsigned int *metric_value_type, NULL, NULL) < 0) goto cleanup; - + if (!(bytesoutptr = (u_int64_t *)malloc(sizeof(u_int64_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *bytesoutptr = bytesoutval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT64; diff --git a/src/modules/metric/cerebro_metric_common.c b/src/modules/metric/cerebro_metric_common.c index abc43b32..2f57341c 100644 --- a/src/modules/metric/cerebro_metric_common.c +++ b/src/modules/metric/cerebro_metric_common.c @@ -59,7 +59,7 @@ common_metric_cleanup_do_nothing(void) return 0; } -int +int common_metric_get_metric_period_0(int *period) { if (!period) @@ -72,7 +72,7 @@ common_metric_get_metric_period_0(int *period) return 0; } -int +int common_metric_get_metric_period_60(int *period) { if (!period) @@ -85,7 +85,7 @@ common_metric_get_metric_period_60(int *period) return 0; } -int +int common_metric_get_metric_period_300(int *period) { if (!period) diff --git a/src/modules/metric/cerebro_metric_common.h b/src/modules/metric/cerebro_metric_common.h index 3e7da620..152758e6 100644 --- a/src/modules/metric/cerebro_metric_common.h +++ b/src/modules/metric/cerebro_metric_common.h @@ -33,7 +33,7 @@ /* * common_metric_interface_version * - * common metric module interface version function + * common metric module interface version function */ int common_metric_interface_version(void); @@ -51,25 +51,25 @@ int common_metric_setup_do_nothing(void); */ int common_metric_cleanup_do_nothing(void); -/* +/* * common_metric_get_metric_period_0 - * + * * common metric module get_metric_period function returning a period * of 0 */ int common_metric_get_metric_period_0(int *period); -/* +/* * common_metric_get_metric_period_60 - * + * * common metric module get_metric_period function returning a period * of 60 */ int common_metric_get_metric_period_60(int *period); -/* +/* * common_metric_get_metric_period_300 - * + * * common metric module get_metric_period function returning a period * of 300 */ diff --git a/src/modules/metric/cerebro_metric_loadavg.c b/src/modules/metric/cerebro_metric_loadavg.c index f4fa56fd..7af5cade 100644 --- a/src/modules/metric/cerebro_metric_loadavg.c +++ b/src/modules/metric/cerebro_metric_loadavg.c @@ -91,25 +91,25 @@ cerebro_metric_get_loadavgs(float *loadavg1, goto cleanup; } - if ((now.tv_sec - last_read) > LOADVAG_CACHETIMEOUT) + if ((now.tv_sec - last_read) > LOADVAG_CACHETIMEOUT) { if ((fd = open(LOADAVG_FILE, O_RDONLY, 0)) < 0) { CEREBRO_ERR(("open: %s", strerror(errno))); goto cleanup; } - + memset(buf, '\0', LOADAVG_BUFLEN); if ((len = read(fd, buf, LOADAVG_BUFLEN)) < 0) { CEREBRO_ERR(("read: %s", strerror(errno))); goto cleanup; } - - if (sscanf(buf, - "%f %f %f", - &cache_loadavg1, - &cache_loadavg5, + + if (sscanf(buf, + "%f %f %f", + &cache_loadavg1, + &cache_loadavg5, &cache_loadavg15) != 3) { CEREBRO_DBG(("loadavg file parse error")); diff --git a/src/modules/metric/cerebro_metric_loadavg1.c b/src/modules/metric/cerebro_metric_loadavg1.c index 88f55581..04f28019 100644 --- a/src/modules/metric/cerebro_metric_loadavg1.c +++ b/src/modules/metric/cerebro_metric_loadavg1.c @@ -79,7 +79,7 @@ loadavg1_metric_get_metric_value(unsigned int *metric_value_type, if (cerebro_metric_get_loadavgs(&loadavg1, NULL, NULL) < 0) goto cleanup; - + if (!(loadavgptr = (float *)malloc(sizeof(float)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); diff --git a/src/modules/metric/cerebro_metric_loadavg15.c b/src/modules/metric/cerebro_metric_loadavg15.c index 3557a83d..46aef873 100644 --- a/src/modules/metric/cerebro_metric_loadavg15.c +++ b/src/modules/metric/cerebro_metric_loadavg15.c @@ -79,7 +79,7 @@ loadavg15_metric_get_metric_value(unsigned int *metric_value_type, if (cerebro_metric_get_loadavgs(NULL, NULL, &loadavg15) < 0) goto cleanup; - + if (!(loadavgptr = (float *)malloc(sizeof(float)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); diff --git a/src/modules/metric/cerebro_metric_loadavg5.c b/src/modules/metric/cerebro_metric_loadavg5.c index 8dbd1ed7..90e46c40 100644 --- a/src/modules/metric/cerebro_metric_loadavg5.c +++ b/src/modules/metric/cerebro_metric_loadavg5.c @@ -79,7 +79,7 @@ loadavg5_metric_get_metric_value(unsigned int *metric_value_type, if (cerebro_metric_get_loadavgs(NULL, &loadavg5, NULL) < 0) goto cleanup; - + if (!(loadavgptr = (float *)malloc(sizeof(float)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); diff --git a/src/modules/metric/cerebro_metric_memfree.c b/src/modules/metric/cerebro_metric_memfree.c index 831d1f39..7c9a1ca4 100644 --- a/src/modules/metric/cerebro_metric_memfree.c +++ b/src/modules/metric/cerebro_metric_memfree.c @@ -76,19 +76,19 @@ memfree_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_memory(NULL, &memfreeval, NULL, NULL) < 0) goto cleanup; - + if (!(memfreeptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *memfreeptr = memfreeval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32; diff --git a/src/modules/metric/cerebro_metric_memory.c b/src/modules/metric/cerebro_metric_memory.c index 613c2313..4825c055 100644 --- a/src/modules/metric/cerebro_metric_memory.c +++ b/src/modules/metric/cerebro_metric_memory.c @@ -75,7 +75,7 @@ static u_int32_t cache_swapfree; static unsigned long int last_read = 0; -/* +/* * _read_memory * * Returns 0 on success, -1 on error @@ -115,7 +115,7 @@ _read_memory(int fd, } parseptr += strlen(keyword); parseptr += 1; /* for the ':' character */ - + errno = 0; memval = (u_int32_t)strtoul(parseptr, NULL, 10); if ((memval == LONG_MIN || memval == LONG_MAX) && errno == ERANGE) @@ -123,7 +123,7 @@ _read_memory(int fd, CEREBRO_DBG(("memtotal out of range")); goto cleanup; } - + *memvalptr = memval; rv = 0; cleanup: @@ -159,7 +159,7 @@ cerebro_metric_get_memory(u_int32_t *memtotal, CEREBRO_ERR(("open: %s", strerror(errno))); goto cleanup; } - + memset(buf, '\0', MEMORY_BUFLEN); if ((len = read(fd, buf, MEMORY_BUFLEN)) < 0) { diff --git a/src/modules/metric/cerebro_metric_memtotal.c b/src/modules/metric/cerebro_metric_memtotal.c index b4e11712..1039520f 100644 --- a/src/modules/metric/cerebro_metric_memtotal.c +++ b/src/modules/metric/cerebro_metric_memtotal.c @@ -76,19 +76,19 @@ memtotal_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_memory(&memtotalval, NULL, NULL, NULL) < 0) goto cleanup; - + if (!(memtotalptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *memtotalptr = memtotalval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32; diff --git a/src/modules/metric/cerebro_metric_memused.c b/src/modules/metric/cerebro_metric_memused.c index df4e286a..3603021d 100644 --- a/src/modules/metric/cerebro_metric_memused.c +++ b/src/modules/metric/cerebro_metric_memused.c @@ -76,19 +76,19 @@ memused_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_memory(&memtotalval, &memfreeval, NULL, NULL) < 0) goto cleanup; - + if (!(memusedptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *memusedptr = memtotalval - memfreeval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32; diff --git a/src/modules/metric/cerebro_metric_network.c b/src/modules/metric/cerebro_metric_network.c index 9c8af6a2..37201923 100644 --- a/src/modules/metric/cerebro_metric_network.c +++ b/src/modules/metric/cerebro_metric_network.c @@ -111,7 +111,7 @@ cerebro_metric_get_network(u_int64_t *bytesin, CEREBRO_ERR(("open: %s", strerror(errno))); goto cleanup; } - + memset(buf, '\0', NETWORK_BUFLEN); if ((len = read(fd, buf, NETWORK_BUFLEN)) < 0) { @@ -120,7 +120,7 @@ cerebro_metric_get_network(u_int64_t *bytesin, } /* skip the first two lines of the file, which are headers, and - * skip the local loopback interface + * skip the local loopback interface */ parseptr = buf; if (!(parseptr = strstr(parseptr, "\n"))) @@ -150,7 +150,7 @@ cerebro_metric_get_network(u_int64_t *bytesin, u_int32_t tx_packets, tx_errs; u_int32_t temp; char *strptr; - + /* skip the device name */ if (!(strptr = strstr(parseptr, ":"))) { @@ -158,7 +158,7 @@ cerebro_metric_get_network(u_int64_t *bytesin, goto cleanup; } strptr++; - + rx_bytes = strtoull(strptr, &strptr, 10); if (!strptr) { @@ -225,7 +225,7 @@ cerebro_metric_get_network(u_int64_t *bytesin, CEREBRO_ERR(("%s parse error", NETWORK_FILE)); goto cleanup; } - + total_bytesin += rx_bytes; total_packetsin += rx_packets; total_rxerrs += rx_errs; diff --git a/src/modules/metric/cerebro_metric_packetsin.c b/src/modules/metric/cerebro_metric_packetsin.c index 55d2723a..4ac4f7f9 100644 --- a/src/modules/metric/cerebro_metric_packetsin.c +++ b/src/modules/metric/cerebro_metric_packetsin.c @@ -76,7 +76,7 @@ packetsin_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_network(NULL, NULL, &packetsinval, @@ -84,13 +84,13 @@ packetsin_metric_get_metric_value(unsigned int *metric_value_type, NULL, NULL) < 0) goto cleanup; - + if (!(packetsinptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *packetsinptr = packetsinval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32; diff --git a/src/modules/metric/cerebro_metric_packetsout.c b/src/modules/metric/cerebro_metric_packetsout.c index 5bf83cb6..55cbe0da 100644 --- a/src/modules/metric/cerebro_metric_packetsout.c +++ b/src/modules/metric/cerebro_metric_packetsout.c @@ -76,7 +76,7 @@ packetsout_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_network(NULL, NULL, NULL, @@ -84,13 +84,13 @@ packetsout_metric_get_metric_value(unsigned int *metric_value_type, NULL, NULL) < 0) goto cleanup; - + if (!(packetsoutptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *packetsoutptr = packetsoutval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32; diff --git a/src/modules/metric/cerebro_metric_rxerrs.c b/src/modules/metric/cerebro_metric_rxerrs.c index 717ea2b1..b748e95f 100644 --- a/src/modules/metric/cerebro_metric_rxerrs.c +++ b/src/modules/metric/cerebro_metric_rxerrs.c @@ -76,7 +76,7 @@ rxerrs_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_network(NULL, NULL, NULL, @@ -84,13 +84,13 @@ rxerrs_metric_get_metric_value(unsigned int *metric_value_type, &rxerrsval, NULL) < 0) goto cleanup; - + if (!(rxerrsptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *rxerrsptr = rxerrsval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32; diff --git a/src/modules/metric/cerebro_metric_shutdown.c b/src/modules/metric/cerebro_metric_shutdown.c index 5ce1b32b..6abc1b0b 100644 --- a/src/modules/metric/cerebro_metric_shutdown.c +++ b/src/modules/metric/cerebro_metric_shutdown.c @@ -63,14 +63,14 @@ */ static u_int32_t metric_shutdown = 0; -/* +/* * send_message_function * * Stores pointer to function to send a message */ Cerebro_metric_send_message send_message_function = NULL; -/* +/* * _metric_shutdown_handler * * Will handle the SIGTERM (and SIGINT if we're debugging) signals. @@ -104,19 +104,19 @@ _metric_shutdown_handler(int signum) hb->version = CEREBROD_MESSAGE_PROTOCOL_VERSION; memcpy(hb->nodename, nodename, CEREBRO_MAX_NODENAME_LEN); - + hb->metrics_len = 1; if (!(hb->metrics = (struct cerebrod_message_metric **)malloc(sizeof(struct cerebrod_message_metric *)*(hb->metrics_len + 1)))) goto cleanup; memset(hb->metrics, '\0', sizeof(struct cerebrod_message_metric *)*(hb->metrics_len + 1)); - + if (!(hd = (struct cerebrod_message_metric *)malloc(sizeof(struct cerebrod_message_metric)))) goto cleanup; memset(hd, '\0', sizeof(struct cerebrod_message_metric)); /* need not overflow */ strncpy(hd->metric_name, SHUTDOWN_METRIC_NAME, CEREBRO_MAX_METRIC_NAME_LEN); - + hd->metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32; hd->metric_value_len = sizeof(u_int32_t); metric_shutdown = 1; @@ -185,7 +185,7 @@ shutdown_metric_get_metric_period(int *period) CEREBRO_DBG(("invalid parameters")); return -1; } - + /* Rather than making the period -1 (so the metric is never sent * except on during shutdown when the signal is caught), we set the * period to INT_MAX, so that the value of '0' is sent once at the diff --git a/src/modules/metric/cerebro_metric_slurm_state.c b/src/modules/metric/cerebro_metric_slurm_state.c index 7b1e17ab..33f99b97 100644 --- a/src/modules/metric/cerebro_metric_slurm_state.c +++ b/src/modules/metric/cerebro_metric_slurm_state.c @@ -75,9 +75,9 @@ */ static u_int32_t metric_slurm_state = 0; -/* +/* * slurm_state_fd - * + * * Unix Domain socket in which slurm will connect to */ static int slurm_state_fd = -1; @@ -89,7 +89,7 @@ static int slurm_state_fd = -1; */ Cerebro_metric_send_message send_message_function = NULL; -/* +/* * _slurm_state_setup_socket * * Create and setup the server socket @@ -103,11 +103,11 @@ _slurm_state_setup_socket(void) int fd; if ((fd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) - { + { CEREBRO_ERR(("socket: %s", strerror(errno))); goto cleanup; } - + if (strlen(SLURM_STATE_CONTROL_PATH) >= sizeof(addr.sun_path)) { CEREBRO_ERR(("path '%s' too long", SLURM_STATE_CONTROL_PATH)); @@ -133,13 +133,13 @@ _slurm_state_setup_socket(void) CEREBRO_ERR(("bind: %s", strerror(errno))); goto cleanup; } - + if (listen(fd, SLURM_STATE_BACKLOG) < 0) { CEREBRO_ERR(("listen: %s", strerror(errno))); goto cleanup; } - + return fd; cleanup: @@ -231,7 +231,7 @@ _send_message(void) hb->version = CEREBROD_MESSAGE_PROTOCOL_VERSION; memcpy(hb->nodename, nodename, CEREBRO_MAX_NODENAME_LEN); - + hb->metrics_len = 1; if (!(hb->metrics = (struct cerebrod_message_metric **)malloc(sizeof(struct cerebrod_message_metric *)*(hb->metrics_len + 1)))) goto cleanup; @@ -256,7 +256,7 @@ _send_message(void) CEREBRO_DBG(("cerebrod_send_message")); goto cleanup; } - + rv = 0; cleanup: if (hb) @@ -270,7 +270,7 @@ _send_message(void) return rv; } -/* +/* * slurm_state_metric_thread * * Thread that will continually monitor the state of slurm @@ -283,7 +283,7 @@ slurm_state_metric_thread(void *arg) struct sockaddr_un addr; socklen_t addrlen; int fd, num; - + addrlen = sizeof(sizeof(struct sockaddr_un)); if ((fd = accept(slurm_state_fd, (struct sockaddr *)&addr, &addrlen)) < 0) { @@ -301,10 +301,10 @@ slurm_state_metric_thread(void *arg) metric_slurm_state = 1; /* No biggie if it fails, we can continue */ - + if (_send_message() < 0) CEREBRO_DBG(("_send_message failed")); - + while (1) { char buf[CEREBRO_MAX_PACKET_LEN]; @@ -312,7 +312,7 @@ slurm_state_metric_thread(void *arg) FD_ZERO(&rfds); FD_SET(fd, &rfds); - + if ((num = select(fd + 1, &rfds, NULL, NULL, NULL)) < 0) { CEREBRO_DBG(("select: %s", strerror(errno))); @@ -340,7 +340,7 @@ slurm_state_metric_thread(void *arg) if (FD_ISSET(fd, &rfds)) { int n; - + if ((n = read(fd, buf, CEREBRO_MAX_PACKET_LEN)) < 0) { CEREBRO_ERR(("read: %s", strerror(errno))); @@ -362,7 +362,7 @@ slurm_state_metric_thread(void *arg) if (!n) { metric_slurm_state = 0; - + /* No biggie if it fails, we can continue */ if (_send_message() < 0) CEREBRO_DBG(("_send_message failed")); @@ -380,7 +380,7 @@ slurm_state_metric_thread(void *arg) close(fd); break; } - + } } diff --git a/src/modules/metric/cerebro_metric_swapfree.c b/src/modules/metric/cerebro_metric_swapfree.c index b55eaf9b..d79edb5f 100644 --- a/src/modules/metric/cerebro_metric_swapfree.c +++ b/src/modules/metric/cerebro_metric_swapfree.c @@ -76,19 +76,19 @@ swapfree_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_memory(NULL, NULL, NULL, &swapfreeval) < 0) goto cleanup; - + if (!(swapfreeptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *swapfreeptr = swapfreeval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32; diff --git a/src/modules/metric/cerebro_metric_swaptotal.c b/src/modules/metric/cerebro_metric_swaptotal.c index 8e0d6081..559ee795 100644 --- a/src/modules/metric/cerebro_metric_swaptotal.c +++ b/src/modules/metric/cerebro_metric_swaptotal.c @@ -76,19 +76,19 @@ swaptotal_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_memory(NULL, NULL, &swaptotalval, NULL) < 0) goto cleanup; - + if (!(swaptotalptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *swaptotalptr = swaptotalval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32; diff --git a/src/modules/metric/cerebro_metric_swapused.c b/src/modules/metric/cerebro_metric_swapused.c index 2b90450c..36f3cc6c 100644 --- a/src/modules/metric/cerebro_metric_swapused.c +++ b/src/modules/metric/cerebro_metric_swapused.c @@ -76,19 +76,19 @@ swapused_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_memory(NULL, NULL, &swaptotalval, &swapfreeval) < 0) goto cleanup; - + if (!(swapusedptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *swapusedptr = swaptotalval - swapfreeval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32; diff --git a/src/modules/metric/cerebro_metric_txerrs.c b/src/modules/metric/cerebro_metric_txerrs.c index f0ba9ff4..a85a218b 100644 --- a/src/modules/metric/cerebro_metric_txerrs.c +++ b/src/modules/metric/cerebro_metric_txerrs.c @@ -76,7 +76,7 @@ txerrs_metric_get_metric_value(unsigned int *metric_value_type, CEREBRO_DBG(("invalid parameters")); return -1; } - + if (cerebro_metric_get_network(NULL, NULL, NULL, @@ -84,13 +84,13 @@ txerrs_metric_get_metric_value(unsigned int *metric_value_type, NULL, &txerrsval) < 0) goto cleanup; - + if (!(txerrsptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) { CEREBRO_ERR(("malloc: %s", strerror(errno))); goto cleanup; } - + *txerrsptr = txerrsval; *metric_value_type = CEREBRO_DATA_VALUE_TYPE_U_INT32;