From: <bni...@us...> - 2008-03-31 22:00:55
|
Revision: 1171 http://ganglia.svn.sourceforge.net/ganglia/?rev=1171&view=rev Author: bnicholes Date: 2008-03-31 15:00:49 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Remove apr from the public headers except for gm_metric.h since metric modules depend directly on apr. This should break all of the dependancies that gmetad, gstat and gmetric have on apr directly. Apr should now only be directly referenced by gmond and libganglia. Modified Paths: -------------- trunk/monitor-core/gmetad/Makefile.am trunk/monitor-core/gmetad/gmetad.h trunk/monitor-core/gmetric/Makefile.am trunk/monitor-core/gmond/gmond.c trunk/monitor-core/gmond/gstat/Makefile.am trunk/monitor-core/include/Makefile.am trunk/monitor-core/include/ganglia.h trunk/monitor-core/include/gm_metric.h trunk/monitor-core/lib/apr_net.c trunk/monitor-core/lib/become_a_nobody.c trunk/monitor-core/lib/daemon_init.c trunk/monitor-core/lib/file.c trunk/monitor-core/lib/ganglia.c trunk/monitor-core/lib/ganglia_priv.h trunk/monitor-core/lib/libgmond.c trunk/monitor-core/lib/scoreboard.c trunk/monitor-core/lib/tcp.c trunk/monitor-core/libmetrics/get_ifi_info.c Added Paths: ----------- trunk/monitor-core/include/gm_msg.h Removed Paths: ------------- trunk/monitor-core/lib/error_msg.h Modified: trunk/monitor-core/gmetad/Makefile.am =================================================================== --- trunk/monitor-core/gmetad/Makefile.am 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/gmetad/Makefile.am 2008-03-31 22:00:49 UTC (rev 1171) @@ -8,8 +8,7 @@ GLDFLAGS = endif -INCLUDES = @APR_INCLUDES@ -AM_CFLAGS = -O0 -D_LARGEFILE64_SOURCE -I$(top_builddir)/lib -I$(top_builddir)/gmond -I$(top_builddir)/include $(GCFLAGS) +AM_CFLAGS = -O0 -I$(top_builddir)/lib -I$(top_builddir)/gmond -I$(top_builddir)/include $(GCFLAGS) sbin_PROGRAMS = gmetad gmetad_SOURCES = gmetad.c cmdline.c cmdline.h gmetad.h data_thread.c \ Modified: trunk/monitor-core/gmetad/gmetad.h =================================================================== --- trunk/monitor-core/gmetad/gmetad.h 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/gmetad/gmetad.h 2008-03-31 22:00:49 UTC (rev 1171) @@ -8,7 +8,6 @@ #include "ganglia_priv.h" #include "net.h" #include "hash.h" -#include "error_msg.h" #include "llist.h" #include "conf.h" #include "become_a_nobody.h" Modified: trunk/monitor-core/gmetric/Makefile.am =================================================================== --- trunk/monitor-core/gmetric/Makefile.am 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/gmetric/Makefile.am 2008-03-31 22:00:49 UTC (rev 1171) @@ -1,14 +1,13 @@ if STATIC_BUILD -GCFLAGS = -D_LARGEFILE64_SOURCE +GCFLAGS = GLDADD = GLDFLAGS = -static else -GCFLAGS = -D_LARGEFILE64_SOURCE +GCFLAGS = GLDADD = GLDFLAGS = endif -INCLUDES = @APR_INCLUDES@ AM_CFLAGS = -I../lib -I../include $(GCFLAGS) bin_PROGRAMS = gmetric Modified: trunk/monitor-core/gmond/gmond.c =================================================================== --- trunk/monitor-core/gmond/gmond.c 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/gmond/gmond.c 2008-03-31 22:00:49 UTC (rev 1171) @@ -45,7 +45,7 @@ /* The debug level (in debug_msg.c) */ static int debug_level; /* The global context */ -Ganglia_pool global_context = NULL; +apr_pool_t *global_context = NULL; /* Deaf mode boolean */ int deaf; /* Mute mode boolean */ @@ -196,7 +196,7 @@ cfg_t *tmp; /* this is a global for now */ - config_file = Ganglia_gmond_config_create( args_info.conf_arg, !args_info.conf_given ); + config_file = (cfg_t*)Ganglia_gmond_config_create( args_info.conf_arg, !args_info.conf_given ); /* Initialize a few variables */ tmp = cfg_getsec( config_file, "globals"); @@ -2044,8 +2044,9 @@ if (!cb->metadata_last_sent || (send_metadata_interval && (cb->metadata_last_sent < (now - apr_time_make(send_metadata_interval,0))))) { - Ganglia_metric gmetric = Ganglia_metric_create(global_context); + Ganglia_metric gmetric = Ganglia_metric_create((Ganglia_pool)global_context); char *val, *type; + apr_pool_t *gm_pool = (apr_pool_t*)gmetric->pool; if(!gmetric) { @@ -2053,8 +2054,8 @@ return; } - val = apr_pstrdup(gmetric->pool, host_metric_value(cb->info, &(cb->msg))); - type = apr_pstrdup(gmetric->pool, host_metric_type(cb->info->type)); + val = apr_pstrdup(gm_pool, host_metric_value(cb->info, &(cb->msg))); + type = apr_pstrdup(gm_pool, host_metric_type(cb->info->type)); errors = Ganglia_metric_set(gmetric, cb->info->name, val, type, cb->info->units, cstr_to_slope( cb->info->slope), @@ -2102,7 +2103,7 @@ } } - apr_pool_destroy(gmetric->pool); + Ganglia_metric_destroy(gmetric); } /* Send the updated value packet ever time it is collected */ @@ -2220,7 +2221,7 @@ } static void -cleanup_data( Ganglia_pool pool, apr_time_t now) +cleanup_data( apr_pool_t *pool, apr_time_t now) { apr_hash_index_t *hi, *metric_hi; @@ -2303,7 +2304,7 @@ main ( int argc, char *argv[] ) { apr_time_t now, next_collection, last_cleanup; - Ganglia_pool cleanup_context; + apr_pool_t *cleanup_context; if (cmdline_parser (argc, argv, &args_info) != 0) exit(1) ; @@ -2314,16 +2315,16 @@ } /* Create the global context */ - global_context = Ganglia_pool_create(NULL); + global_context = (apr_pool_t*)Ganglia_pool_create(NULL); /* Create the cleanup context from the global context */ - cleanup_context = Ganglia_pool_create(global_context); + cleanup_context = (apr_pool_t*)Ganglia_pool_create((Ganglia_pool)global_context); /* Mark the time this gmond started */ started = apr_time_now(); /* Builds a default configuration based on platform */ - build_default_gmond_configuration(global_context); + build_default_gmond_configuration((Ganglia_pool)global_context); if(args_info.default_config_flag) { @@ -2388,7 +2389,8 @@ } /* even if mute, a send channel may be needed to send a request for metadata */ - udp_send_channels = Ganglia_udp_send_channels_create( global_context, config_file ); + udp_send_channels = Ganglia_udp_send_channels_create((Ganglia_pool)global_context, + (Ganglia_gmond_config)config_file); if(!udp_send_channels) { /* if there are no send channels defined, we are equivalent to mute */ Modified: trunk/monitor-core/gmond/gstat/Makefile.am =================================================================== --- trunk/monitor-core/gmond/gstat/Makefile.am 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/gmond/gstat/Makefile.am 2008-03-31 22:00:49 UTC (rev 1171) @@ -6,8 +6,7 @@ GLDFLAGS = endif -INCLUDES = @APR_INCLUDES@ -AM_CFLAGS = -D_LARGEFILE64_SOURCE -I$(top_builddir)/lib -I$(top_builddir)/include $(GCFLAGS) +AM_CFLAGS = -I$(top_builddir)/lib -I$(top_builddir)/include $(GCFLAGS) bin_PROGRAMS = gstat gstat_SOURCES = gstat.c cmdline.c cmdline.h Modified: trunk/monitor-core/include/Makefile.am =================================================================== --- trunk/monitor-core/include/Makefile.am 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/include/Makefile.am 2008-03-31 22:00:49 UTC (rev 1171) @@ -1,3 +1,3 @@ -include_HEADERS = ganglia.h gm_mmn.h gm_metric.h gm_value.h +include_HEADERS = ganglia.h gm_mmn.h gm_metric.h gm_value.h gm_msg.h Modified: trunk/monitor-core/include/ganglia.h =================================================================== --- trunk/monitor-core/include/ganglia.h 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/include/ganglia.h 2008-03-31 22:00:49 UTC (rev 1171) @@ -2,11 +2,9 @@ #define GANGLIA_H 1 #include <rpc/rpc.h> +#include "gm_msg.h" #include "gm_protocol.h" -#include <confuse.h> -#include <apr_pools.h> - /* For C++ */ #ifdef __cplusplus #define BEGIN_C_DECLS extern "C" { @@ -29,12 +27,12 @@ }; typedef enum ganglia_slope ganglia_slope_t; -typedef struct apr_pool_t * Ganglia_pool; -typedef struct cfg_t * Ganglia_gmond_config; -typedef struct apr_array_header_t * Ganglia_udp_send_channels; +typedef struct Ganglia_pool* Ganglia_pool; +typedef struct Ganglia_gmond_config* Ganglia_gmond_config; +typedef struct Ganglia_udp_send_channels* Ganglia_udp_send_channels; struct Ganglia_metric { - apr_pool_t *pool; + Ganglia_pool pool; struct Ganglia_metadata_message *msg; /* defined in ./lib/gm_protocol.x */ char *value; void *extra; @@ -47,7 +45,7 @@ void Ganglia_gmond_config_destroy(Ganglia_gmond_config config); Ganglia_udp_send_channels -Ganglia_udp_send_channels_create(Ganglia_pool context,Ganglia_gmond_config config); +Ganglia_udp_send_channels_create(Ganglia_pool p, Ganglia_gmond_config config); void Ganglia_udp_send_channels_destroy(Ganglia_udp_send_channels channels); int Ganglia_udp_send_message(Ganglia_udp_send_channels channels, char *buf, int len ); @@ -67,10 +65,8 @@ ganglia_slope_t cstr_to_slope(const char* str); const char* slope_to_cstr(unsigned int slope); -void debug_msg(const char *format, ...); -void set_debug_msg_level(int level); -int get_debug_msg_level(); -void err_msg (const char *fmt, ...); +void build_default_gmond_configuration(Ganglia_pool p); +char *Ganglia_default_collection_groups(void); #define END_C_DECLS Modified: trunk/monitor-core/include/gm_metric.h =================================================================== --- trunk/monitor-core/include/gm_metric.h 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/include/gm_metric.h 2008-03-31 22:00:49 UTC (rev 1171) @@ -5,6 +5,7 @@ #include "gm_mmn.h" #include "gm_protocol.h" #include "gm_value.h" +#include "gm_msg.h" #include "confuse.h" /* header for libconfuse */ #include <apr.h> Added: trunk/monitor-core/include/gm_msg.h =================================================================== --- trunk/monitor-core/include/gm_msg.h (rev 0) +++ trunk/monitor-core/include/gm_msg.h 2008-03-31 22:00:49 UTC (rev 1171) @@ -0,0 +1,20 @@ +#ifndef GM_MSG_H +#define GM_MSG_H 1 + +extern int ganglia_quiet_errors; + +void debug_msg(const char *format, ...); +void set_debug_msg_level(int level); +int get_debug_msg_level(); + +void err_quiet( void ); +void err_ret (const char *fmt, ...); +void err_sys (const char *fmt, ...); +void err_dump (const char *fmt, ...); +void err_msg (const char *fmt, ...); +void err_quit (const char *fmt, ...); + +#define END_C_DECLS + + +#endif Modified: trunk/monitor-core/lib/apr_net.c =================================================================== --- trunk/monitor-core/lib/apr_net.c 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/lib/apr_net.c 2008-03-31 22:00:49 UTC (rev 1171) @@ -26,7 +26,7 @@ #include <stropts.h> #endif -#include "error_msg.h" +#include <gm_msg.h> const char *apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size); Modified: trunk/monitor-core/lib/become_a_nobody.c =================================================================== --- trunk/monitor-core/lib/become_a_nobody.c 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/lib/become_a_nobody.c 2008-03-31 22:00:49 UTC (rev 1171) @@ -5,7 +5,7 @@ #include <stdio.h> #include "become_a_nobody.h" -#include "error_msg.h" +#include <gm_msg.h> void become_a_nobody( const char *username ) Modified: trunk/monitor-core/lib/daemon_init.c =================================================================== --- trunk/monitor-core/lib/daemon_init.c 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/lib/daemon_init.c 2008-03-31 22:00:49 UTC (rev 1171) @@ -15,7 +15,7 @@ #include <errno.h> #include "daemon_init.h" -#include "error_msg.h" +#include <gm_msg.h> #define MAXFD 64 Deleted: trunk/monitor-core/lib/error_msg.h =================================================================== --- trunk/monitor-core/lib/error_msg.h 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/lib/error_msg.h 2008-03-31 22:00:49 UTC (rev 1171) @@ -1,13 +0,0 @@ -#ifndef ERROR_H -#define ERROR_H 1 - -extern int ganglia_quiet_errors; - -void err_quiet( void ); -void err_ret (const char *fmt, ...); -void err_sys (const char *fmt, ...); -void err_dump (const char *fmt, ...); -void err_msg (const char *fmt, ...); -void err_quit (const char *fmt, ...); - -#endif Modified: trunk/monitor-core/lib/file.c =================================================================== --- trunk/monitor-core/lib/file.c 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/lib/file.c 2008-03-31 22:00:49 UTC (rev 1171) @@ -12,7 +12,6 @@ #include <fcntl.h> #include <ctype.h> -#include "error_msg.h" #include "ganglia_priv.h" Modified: trunk/monitor-core/lib/ganglia.c =================================================================== --- trunk/monitor-core/lib/ganglia.c 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/lib/ganglia.c 2008-03-31 22:00:49 UTC (rev 1171) @@ -12,7 +12,6 @@ #include "net.h" #include "llist.h" #include "hash.h" -#include "error_msg.h" #include "expat.h" int gexec_errno = 0; Modified: trunk/monitor-core/lib/ganglia_priv.h =================================================================== --- trunk/monitor-core/lib/ganglia_priv.h 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/lib/ganglia_priv.h 2008-03-31 22:00:49 UTC (rev 1171) @@ -12,7 +12,7 @@ #endif #endif -#include "ganglia.h" +#include <gm_msg.h> #include <errno.h> #ifndef SYS_CALL @@ -78,12 +78,7 @@ } gexec_cluster_t; -BEGIN_C_DECLS -void build_default_gmond_configuration(Ganglia_pool context); -char *Ganglia_default_collection_groups(void); - int gexec_cluster_free ( gexec_cluster_t *cluster ); int gexec_cluster (gexec_cluster_t *cluster, char *ip, unsigned short port); -END_C_DECLS #endif Modified: trunk/monitor-core/lib/libgmond.c =================================================================== --- trunk/monitor-core/lib/libgmond.c 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/lib/libgmond.c 2008-03-31 22:00:49 UTC (rev 1171) @@ -8,8 +8,8 @@ #include <string.h> #include "ganglia_priv.h" +#include "ganglia.h" #include "confuse.h" -#include "error_msg.h" #include "default_conf.h" #include <apr_pools.h> @@ -30,7 +30,7 @@ in order for the documentation to be in order with the code ****************************/ -void build_default_gmond_configuration(apr_pool_t *context); +void build_default_gmond_configuration(Ganglia_pool p); static int Ganglia_cfg_include(cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv); @@ -159,8 +159,10 @@ } void -build_default_gmond_configuration(apr_pool_t *context) +build_default_gmond_configuration(Ganglia_pool p) { + apr_pool_t *context=(apr_pool_t*)p; + default_gmond_configuration = apr_pstrdup(context, BASE_GMOND_CONFIGURATION); default_gmond_configuration = apr_pstrcat(context, default_gmond_configuration, COLLECTION_GROUP_LIST, NULL); #if SOLARIS @@ -183,10 +185,10 @@ int libgmond_apr_lib_initialized = 0; Ganglia_pool -Ganglia_pool_create( Ganglia_pool parent ) +Ganglia_pool_create( Ganglia_pool p ) { apr_status_t status; - Ganglia_pool pool = NULL; + apr_pool_t *pool=NULL, *parent=(apr_pool_t*)p; if(!libgmond_apr_lib_initialized) { @@ -204,19 +206,19 @@ { return NULL; } - return pool; + return (Ganglia_pool)pool; } void Ganglia_pool_destroy( Ganglia_pool pool ) { - apr_pool_destroy(pool); + apr_pool_destroy((apr_pool_t*)pool); } Ganglia_gmond_config Ganglia_gmond_config_create(char *path, int fallback_to_default) { - Ganglia_gmond_config config = NULL; + cfg_t *config = NULL; /* Make sure we process ~ in the filename if the shell doesn't */ char *tilde_expanded = cfg_tilde_expand( path ); config = cfg_init( gmond_opts, CFGF_NOCASE ); @@ -254,18 +256,20 @@ #if 0 atexit(cleanup_configuration_file); #endif - return config; + return (Ganglia_gmond_config)config; } Ganglia_udp_send_channels -Ganglia_udp_send_channels_create( Ganglia_pool context, Ganglia_gmond_config config ) +Ganglia_udp_send_channels_create( Ganglia_pool p, Ganglia_gmond_config config ) { - Ganglia_udp_send_channels send_channels = NULL; - int i, num_udp_send_channels = cfg_size( config, "udp_send_channel"); + apr_array_header_t *send_channels = NULL; + cfg_t *cfg=(cfg_t *)config; + int i, num_udp_send_channels = cfg_size( cfg, "udp_send_channel"); + apr_pool_t *context = (apr_pool_t*)p; /* Return null if there are no send channels specified */ if(num_udp_send_channels <= 0) - return send_channels; + return (Ganglia_udp_send_channels)send_channels; /* Create my UDP send array */ send_channels = apr_array_make( context, num_udp_send_channels, @@ -279,7 +283,7 @@ apr_socket_t *socket = NULL; apr_pool_t *pool = NULL; - udp_send_channel = cfg_getnsec( config, "udp_send_channel", i); + udp_send_channel = cfg_getnsec( cfg, "udp_send_channel", i); host = cfg_getstr( udp_send_channel, "host" ); mcast_join = cfg_getstr( udp_send_channel, "mcast_join" ); mcast_if = cfg_getstr( udp_send_channel, "mcast_if" ); @@ -323,7 +327,7 @@ *(apr_socket_t **)apr_array_push(send_channels) = socket; } - return send_channels; + return (Ganglia_udp_send_channels)send_channels; } @@ -335,13 +339,14 @@ int i; int num_errors = 0; apr_size_t size; + apr_array_header_t *chnls=(apr_array_header_t*)channels; - if(!channels || !buf || len<=0) + if(!chnls || !buf || len<=0) return 1; - for(i=0; i< channels->nelts; i++) + for(i=0; i< chnls->nelts; i++) { - apr_socket_t *socket = ((apr_socket_t **)(channels->elts))[i]; + apr_socket_t *socket = ((apr_socket_t **)(chnls->elts))[i]; size = len; status = apr_socket_send( socket, buf, &size ); if(status != APR_SUCCESS) @@ -355,7 +360,7 @@ Ganglia_metric Ganglia_metric_create( Ganglia_pool parent_pool ) { - Ganglia_pool pool = Ganglia_pool_create(parent_pool); + apr_pool_t *pool = (apr_pool_t*)Ganglia_pool_create(parent_pool); Ganglia_metric gmetric; if(!pool) { @@ -364,15 +369,15 @@ gmetric = apr_pcalloc( pool, sizeof(struct Ganglia_metric)); if(!gmetric) { - Ganglia_pool_destroy(pool); + Ganglia_pool_destroy((Ganglia_pool)pool); return NULL; } - gmetric->pool = pool; + gmetric->pool = (Ganglia_pool)pool; gmetric->msg = apr_pcalloc( pool, sizeof(struct Ganglia_metadata_message)); if(!gmetric->msg) { - Ganglia_pool_destroy(pool); + Ganglia_pool_destroy((Ganglia_pool)pool); return NULL; } gmetric->extra = (void*)apr_table_make(pool, 2); @@ -390,21 +395,22 @@ const apr_array_header_t *arr; const apr_table_entry_t *elts; const char *spoof = SPOOF; + apr_pool_t *gm_pool=(apr_pool_t*)gmetric->pool; if (myhost[0] == '\0') - apr_gethostname( (char*)myhost, APRMAXHOSTLEN+1, gmetric->pool); + apr_gethostname( (char*)myhost, APRMAXHOSTLEN+1, gm_pool); msg.id = gmetadata_full; memcpy( &(msg.Ganglia_metadata_msg_u.gfull.metric), gmetric->msg, sizeof(Ganglia_metadata_message)); - msg.Ganglia_metadata_msg_u.gfull.metric_id.host = apr_pstrdup (gmetric->pool, (char*)myhost); - msg.Ganglia_metadata_msg_u.gfull.metric_id.name = apr_pstrdup (gmetric->pool, gmetric->msg->name); + msg.Ganglia_metadata_msg_u.gfull.metric_id.host = apr_pstrdup (gm_pool, (char*)myhost); + msg.Ganglia_metadata_msg_u.gfull.metric_id.name = apr_pstrdup (gm_pool, gmetric->msg->name); msg.Ganglia_metadata_msg_u.gfull.metric_id.spoof = FALSE; arr = apr_table_elts(gmetric->extra); elts = (const apr_table_entry_t *)arr->elts; msg.Ganglia_metadata_msg_u.gfull.metric.metadata.metadata_len = arr->nelts; msg.Ganglia_metadata_msg_u.gfull.metric.metadata.metadata_val = - (Ganglia_extra_data*)apr_pcalloc(gmetric->pool, sizeof(Ganglia_extra_data)*arr->nelts); + (Ganglia_extra_data*)apr_pcalloc(gm_pool, sizeof(Ganglia_extra_data)*arr->nelts); /* add all of the metadata to the packet */ for (i = 0; i < arr->nelts; ++i) { @@ -414,20 +420,20 @@ /* Replace the host name with the spoof host if it exists in the metadata */ if ((elts[i].key[0] == spoof[0]) && strcasecmp(SPOOF_HOST, elts[i].key) == 0) { - msg.Ganglia_metadata_msg_u.gfull.metric_id.host = apr_pstrdup (gmetric->pool, elts[i].val); + msg.Ganglia_metadata_msg_u.gfull.metric_id.host = apr_pstrdup (gm_pool, elts[i].val); msg.Ganglia_metadata_msg_u.gfull.metric_id.spoof = TRUE; } if ((elts[i].key[0] == spoof[0]) && strcasecmp(SPOOF_HEARTBEAT, elts[i].key) == 0) { - msg.Ganglia_metadata_msg_u.gfull.metric_id.name = apr_pstrdup (gmetric->pool, "heartbeat"); + msg.Ganglia_metadata_msg_u.gfull.metric_id.name = apr_pstrdup (gm_pool, "heartbeat"); msg.Ganglia_metadata_msg_u.gfull.metric.name = msg.Ganglia_metadata_msg_u.gfull.metric_id.name; msg.Ganglia_metadata_msg_u.gfull.metric_id.spoof = TRUE; } msg.Ganglia_metadata_msg_u.gfull.metric.metadata.metadata_val[i].name = - apr_pstrdup(gmetric->pool, elts[i].key); + apr_pstrdup(gm_pool, elts[i].key); msg.Ganglia_metadata_msg_u.gfull.metric.metadata.metadata_val[i].data = - apr_pstrdup(gmetric->pool, elts[i].val); + apr_pstrdup(gm_pool, elts[i].val); } /* Send the message */ @@ -451,16 +457,17 @@ const apr_array_header_t *arr; const apr_table_entry_t *elts; const char *spoof = SPOOF; + apr_pool_t *gm_pool=(apr_pool_t*)gmetric->pool; if (myhost[0] == '\0') - apr_gethostname( (char*)myhost, APRMAXHOSTLEN+1, gmetric->pool); + apr_gethostname( (char*)myhost, APRMAXHOSTLEN+1, gm_pool); msg.id = gmetric_string; - msg.Ganglia_value_msg_u.gstr.metric_id.host = apr_pstrdup (gmetric->pool, (char*)myhost); - msg.Ganglia_value_msg_u.gstr.metric_id.name = apr_pstrdup (gmetric->pool, gmetric->msg->name); + msg.Ganglia_value_msg_u.gstr.metric_id.host = apr_pstrdup (gm_pool, (char*)myhost); + msg.Ganglia_value_msg_u.gstr.metric_id.name = apr_pstrdup (gm_pool, gmetric->msg->name); msg.Ganglia_value_msg_u.gstr.metric_id.spoof = FALSE; - msg.Ganglia_value_msg_u.gstr.fmt = apr_pstrdup (gmetric->pool, "%s"); - msg.Ganglia_value_msg_u.gstr.str = apr_pstrdup (gmetric->pool, gmetric->value); + msg.Ganglia_value_msg_u.gstr.fmt = apr_pstrdup (gm_pool, "%s"); + msg.Ganglia_value_msg_u.gstr.str = apr_pstrdup (gm_pool, gmetric->value); arr = apr_table_elts(gmetric->extra); elts = (const apr_table_entry_t *)arr->elts; @@ -473,12 +480,12 @@ /* Replace the host name with the spoof host if it exists in the metadata */ if ((elts[i].key[0] == spoof[0]) && strcasecmp(SPOOF_HOST, elts[i].key) == 0) { - msg.Ganglia_value_msg_u.gstr.metric_id.host = apr_pstrdup (gmetric->pool, elts[i].val); + msg.Ganglia_value_msg_u.gstr.metric_id.host = apr_pstrdup (gm_pool, elts[i].val); msg.Ganglia_value_msg_u.gstr.metric_id.spoof = TRUE; } if ((elts[i].key[0] == spoof[0]) && strcasecmp(SPOOF_HEARTBEAT, elts[i].key) == 0) { - msg.Ganglia_value_msg_u.gstr.metric_id.name = apr_pstrdup (gmetric->pool, "heartbeat"); + msg.Ganglia_value_msg_u.gstr.metric_id.name = apr_pstrdup (gm_pool, "heartbeat"); msg.Ganglia_value_msg_u.gstr.metric_id.spoof = TRUE; } } @@ -543,10 +550,14 @@ int Ganglia_metric_set( Ganglia_metric gmetric, char *name, char *value, char *type, char *units, unsigned int slope, unsigned int tmax, unsigned int dmax) { + apr_pool_t *gm_pool; + /* Make sure all the params look ok */ if(!gmetric||!name||!value||!type||!units||slope<0||slope>4) return 1; + gm_pool = (apr_pool_t*)gmetric->pool; + /* Make sure none of the string params have a '"' in them (breaks the xml) */ if(strchr(name, '"')||strchr(value,'"')||strchr(type,'"')||strchr(units,'"')) { @@ -568,10 +579,10 @@ } /* All the data is there and validated... copy it into the structure */ - gmetric->msg->name = apr_pstrdup( gmetric->pool, name); - gmetric->value = apr_pstrdup( gmetric->pool, value); - gmetric->msg->type = apr_pstrdup( gmetric->pool, type); - gmetric->msg->units = apr_pstrdup( gmetric->pool, units); + gmetric->msg->name = apr_pstrdup( gm_pool, name); + gmetric->value = apr_pstrdup( gm_pool, value); + gmetric->msg->type = apr_pstrdup( gm_pool, type); + gmetric->msg->units = apr_pstrdup( gm_pool, units); gmetric->msg->slope = slope; gmetric->msg->tmax = tmax; gmetric->msg->dmax = dmax; @@ -699,7 +710,7 @@ char *path = calloc(sizeof(char), strlen(fname)+1); char *pattern = NULL; char *idx = strrchr(fname, '/'); - Ganglia_pool p; + apr_pool_t *p; apr_file_t *ftemp; char *dirname = NULL; char tn[] = "gmond.tmp.XXXXXX"; @@ -717,9 +728,10 @@ pattern = idx + 1; } - p = Ganglia_pool_create(NULL); + apr_pool_create(&p, NULL); if (apr_temp_dir_get((const char**)&dirname, p) != APR_SUCCESS) { cfg_error(cfg, "failed to determine the temp dir"); + apr_pool_destroy(p); return 1; } dirname = apr_psprintf(p, "%s/%s", dirname, tn); @@ -728,6 +740,7 @@ APR_CREATE | APR_READ | APR_WRITE | APR_DELONCLOSE, p) != APR_SUCCESS) { cfg_error(cfg, "unable to create a temporary file %s", dirname); + apr_pool_destroy(p); return 1; } @@ -761,7 +774,7 @@ } apr_file_close(ftemp); - Ganglia_pool_destroy(p); + apr_pool_destroy(p); argv[0] = fname; } Modified: trunk/monitor-core/lib/scoreboard.c =================================================================== --- trunk/monitor-core/lib/scoreboard.c 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/lib/scoreboard.c 2008-03-31 22:00:49 UTC (rev 1171) @@ -3,7 +3,7 @@ #endif #include "ganglia_priv.h" -#include "error_msg.h" +#include "gm_msg.h" #include "scoreboard.h" #include <apr_hash.h> #include <apr_strings.h> Modified: trunk/monitor-core/lib/tcp.c =================================================================== --- trunk/monitor-core/lib/tcp.c 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/lib/tcp.c 2008-03-31 22:00:49 UTC (rev 1171) @@ -24,7 +24,7 @@ */ #include <unistd.h> -#include "error_msg.h" +#include <gm_msg.h> #include "net.h" g_tcp_socket* Modified: trunk/monitor-core/libmetrics/get_ifi_info.c =================================================================== --- trunk/monitor-core/libmetrics/get_ifi_info.c 2008-03-31 09:22:03 UTC (rev 1170) +++ trunk/monitor-core/libmetrics/get_ifi_info.c 2008-03-31 22:00:49 UTC (rev 1171) @@ -15,7 +15,7 @@ #include <signal.h> #include "unpifi.h" -#include "error_msg.h" +#include <gm_msg.h> /* HP-UX, Solaris */ #if !defined(ifr_mtu) && defined(ifr_metric) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |