Send Linux-ha-cvs mailing list submissions to linux-ha-cvs@lists.linux-ha.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of Linux-ha-cvs digest..." Today's Topics: 1. Linux-HA CVS: lib by davidlee from (linux-ha-cvs@lists.linux-ha.org) 2. Linux-HA CVS: crm by andrew from (linux-ha-cvs@lists.linux-ha.org) 3. Linux-HA CVS: lib by lars from (linux-ha-cvs@lists.linux-ha.org) ---------------------------------------------------------------------- Message: 1 Date: Fri, 7 Jul 2006 02:57:01 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: lib by davidlee from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : davidlee Host : Project : linux-ha Module : lib Dir : linux-ha/lib/plugins/HBcomm Modified Files: hbaping.c Log Message: 'include <portability.h>' must be the first. =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/lib/plugins/HBcomm/hbaping.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- hbaping.c 15 Aug 2005 21:12:16 -0000 1.4 +++ hbaping.c 7 Jul 2006 08:57:00 -0000 1.5 @@ -34,8 +34,8 @@ * */ -#include <time.h> #include <portability.h> +#include <time.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> ------------------------------ Message: 2 Date: Fri, 7 Jul 2006 03:04:40 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: crm by andrew from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : andrew Host : Project : linux-ha Module : crm Dir : linux-ha/crm/cib Modified Files: io.c Log Message: Tweaks so that we behave in read-and-free mode Make sure *all* counters are updated correctly when reading from disk =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/crm/cib/io.c,v retrieving revision 1.77 retrieving revision 1.78 diff -u -3 -r1.77 -r1.78 --- io.c 7 Jul 2006 08:29:34 -0000 1.77 +++ io.c 7 Jul 2006 09:04:40 -0000 1.78 @@ -1,4 +1,4 @@ -/* $Id: io.c,v 1.77 2006/07/07 08:29:34 andrew Exp $ */ +/* $Id: io.c,v 1.78 2006/07/07 09:04:40 andrew Exp $ */ /* * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]> * @@ -296,7 +296,7 @@ } /* unset these and require the DC/CCM to update as needed */ - crm_xml_add(root, XML_ATTR_HAVE_QUORUM, XML_BOOLEAN_FALSE); + update_counters(__FILE__, __PRETTY_FUNCTION__, root); xml_remove_prop(root, XML_ATTR_DC_UUID); } @@ -362,7 +362,7 @@ if(tmp_cib == NULL) { - crm_err("The CIB has already been deallocated."); + crm_debug("The CIB has already been deallocated."); return FALSE; } @@ -373,11 +373,11 @@ constraint_search = NULL; status_search = NULL; - crm_err("Deallocating the CIB."); + crm_debug("Deallocating the CIB."); free_xml(tmp_cib); - crm_err("The CIB has been deallocated."); + crm_info("The CIB has been deallocated."); return TRUE; } @@ -682,8 +682,12 @@ gboolean set_transition(crm_data_t *xml_obj) { - const char *current = crm_element_value( - xml_obj, XML_ATTR_CCM_TRANSITION); + const char *current = NULL; + if(xml_obj == NULL) { + return FALSE; + } + + current = crm_element_value(xml_obj, XML_ATTR_CCM_TRANSITION); if(safe_str_neq(current, ccm_transition_id)) { crm_debug("CCM transition: old=%s, new=%s", current, ccm_transition_id); @@ -699,8 +703,12 @@ int active = 0; int current = 0; char *peers_s = NULL; - const char *current_s = crm_element_value(xml_obj, XML_ATTR_NUMPEERS); - + const char *current_s = NULL; + if(xml_obj == NULL) { + return FALSE; + } + + current_s = crm_element_value(xml_obj, XML_ATTR_NUMPEERS); g_hash_table_foreach(peer_hash, GHFunc_count_peers, &active); current = crm_parse_int(current_s, "0"); if(current != active) { @@ -717,7 +725,12 @@ update_quorum(crm_data_t *xml_obj) { const char *quorum_value = XML_BOOLEAN_FALSE; - const char *current = crm_element_value(xml_obj, XML_ATTR_HAVE_QUORUM); + const char *current = NULL; + if(xml_obj == NULL) { + return FALSE; + } + + current = crm_element_value(xml_obj, XML_ATTR_HAVE_QUORUM); if(cib_have_quorum) { quorum_value = XML_BOOLEAN_TRUE; } ------------------------------ Message: 3 Date: Fri, 7 Jul 2006 04:27:15 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: lib by lars from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : lars Host : Project : linux-ha Module : lib Dir : linux-ha/lib/clplumbing Modified Files: cl_malloc.c Log Message: Adds compile-time support for HA_MALLOC_TRACK. Each and every active allocation is tagged with who allocated it and when, and put on a linked list for retrieval. This is a very memory expensive option and shouldn't be enabled in production ever. =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/lib/clplumbing/cl_malloc.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- cl_malloc.c 2 Feb 2006 21:01:37 -0000 1.24 +++ cl_malloc.c 7 Jul 2006 10:27:15 -0000 1.25 @@ -1,4 +1,4 @@ -/* $Id: cl_malloc.c,v 1.24 2006/02/02 21:01:37 alan Exp $ */ +/* $Id: cl_malloc.c,v 1.25 2006/07/07 10:27:15 lars Exp $ */ /* * Copyright (C) 2000 Alan Robertson <[EMAIL PROTECTED]> * @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#define HA_MALLOC_ORIGINAL #include <portability.h> #include <unistd.h> #include <stdlib.h> @@ -31,6 +32,7 @@ #endif #include <clplumbing/cl_malloc.h> #include <clplumbing/cl_log.h> +#include <clplumbing/longclock.h> #include <ltdl.h> @@ -118,10 +120,22 @@ */ +#ifdef HA_MALLOC_TRACK +# define HA_MALLOC_OWNER 64 +struct cl_bucket; +#endif + struct cl_mhdr { # ifdef HA_MALLOC_MAGIC unsigned long magic; /* Must match HA_*_MAGIC */ #endif +# ifdef HA_MALLOC_TRACK + char owner[HA_MALLOC_OWNER]; + struct cl_bucket * left; + struct cl_bucket * right; + int dumped; + longclock_t mtime; +#endif size_t reqsize; int bucket; }; @@ -131,7 +145,6 @@ struct cl_bucket * next; }; - #define NUMBUCKS 12 #define NOBUCKET (NUMBUCKS) @@ -141,10 +154,7 @@ static int cl_malloc_inityet = 0; static size_t cl_malloc_hdr_offset = sizeof(struct cl_mhdr); -void* cl_malloc(size_t size); static void* cl_new_mem(size_t size, int numbuck); -void* cl_calloc(size_t nmemb, size_t size); -void cl_free(void *ptr); static void cl_malloc_init(void); static void cl_dump_item(const struct cl_bucket*b); @@ -194,6 +204,100 @@ #define MALLOCROUND 4096 /* Round big mallocs up to a multiple of this size */ + +#ifdef HA_MALLOC_TRACK + +static struct cl_bucket * cl_malloc_track_root = NULL; + +static void +cl_ptr_tag(void *ptr, const char *file, const char *function, const int line) +{ + struct cl_bucket* bhdr = BHDR(ptr); + snprintf(bhdr->hdr.owner, HA_MALLOC_OWNER, "%s:%s:%d", + file, function, line); +} + +static void +cl_ptr_track(void *ptr) +{ + struct cl_bucket* bhdr = BHDR(ptr); + +#if defined(USE_ASSERTS) + g_assert(bhdr->hdr.left == NULL); + g_assert(bhdr->hdr.right == NULL); + g_assert((cl_malloc_track_root == NULL) || (cl_malloc_track_root->hdr.left == NULL)); +#endif + + bhdr->hdr.dumped = 0; + bhdr->hdr.mtime = time_longclock(); + + if (cl_malloc_track_root == NULL) { + cl_malloc_track_root = bhdr; + } else { + bhdr->hdr.right = cl_malloc_track_root; + cl_malloc_track_root->hdr.left = bhdr; + cl_malloc_track_root = bhdr; + } +} + +static void +cl_ptr_release(void *ptr) +{ + struct cl_bucket* bhdr = BHDR(ptr); + +/* cl_log(LOG_DEBUG, "cl_free: Freeing memory belonging to %s" + , bhdr->hdr.owner); */ + +#if defined(USE_ASSERTS) + g_assert(cl_malloc_track_root != NULL); + g_assert(cl_malloc_track_root->hdr.left == NULL); +#endif + + if (bhdr->hdr.left != NULL) { + bhdr->hdr.left->hdr.right=bhdr->hdr.right; + } + + if (bhdr->hdr.right != NULL) { + bhdr->hdr.right->hdr.left=bhdr->hdr.left; + } + + if (cl_malloc_track_root == bhdr) { + cl_malloc_track_root=bhdr->hdr.right; + } + + bhdr->hdr.left = NULL; + bhdr->hdr.right = NULL; +} + +static void +cl_ptr_init(void) +{ + cl_malloc_track_root = NULL; +} + +void +cl_malloc_dump_allocated(void) +{ + struct cl_bucket* cursor = cl_malloc_track_root; + longclock_t time_diff; + + cl_log(LOG_INFO, "Dumping allocated memory buffers:"); + + while (cursor != NULL) { + time_diff = sub_longclock(time_longclock(), cursor->hdr.mtime); + cl_log(LOG_INFO, "cl_malloc_dump: owner %s, size %d, dumped %d, age %lu ms" + , cursor->hdr.owner + , cursor->hdr.reqsize + , cursor->hdr.dumped + , longclockto_long(time_diff)); + cursor->hdr.dumped = 1; + cursor = cursor->hdr.right; + } + + cl_log(LOG_INFO, "End dump."); +} +#endif + /* * cl_malloc: malloc clone */ @@ -289,6 +393,13 @@ memstats->numalloc++; } if (ret) { +#ifdef HA_MALLOC_TRACK + /* If we were _always_ called via the wrapper functions, + * this wouldn't be necessary, but we aren't, some use + * function pointers directly to cl_malloc() */ + cl_ptr_track(ret); + cl_ptr_tag(ret, "cl_malloc.c", "cl_malloc", 0); +#endif ADD_GUARD(ret); } return(ret); @@ -297,7 +408,6 @@ int cl_is_allocated(const void *ptr) { - #ifdef HA_MALLOC_MAGIC if (NULL == ptr || CBHDR(ptr)->hdr.magic != HA_MALLOC_MAGIC) { return FALSE; @@ -371,6 +481,9 @@ DUMPIFASKED(); return; } +#ifdef HA_MALLOC_TRACK + cl_ptr_release(ptr); +#endif bucket = bhdr->hdr.bucket; #ifdef HA_MALLOC_MAGIC bhdr->hdr.magic = HA_FREE_MAGIC; @@ -434,6 +547,11 @@ /* NULL is a legal 'ptr' value for realloc... */ return cl_malloc(newsize); } + if (newsize == 0) { + /* realloc() is the most redundant interface ever */ + cl_free(ptr); + return NULL; + } /* Find the beginning of our "hidden" structure */ @@ -464,6 +582,7 @@ } #endif CHECK_GUARD_BYTES(ptr, "cl_realloc"); + bucket = bhdr->hdr.bucket; /* @@ -480,10 +599,17 @@ memstats->nbytes_alloc += MALLOCSIZE(newsize); memstats->mallocbytes += MALLOCSIZE(newsize); } +#ifdef HA_MALLOC_TRACK + cl_ptr_release(ptr); +#endif bhdr = realloc(bhdr, newsize + cl_malloc_hdr_offset + GUARDSIZE); if (!bhdr) { return NULL; } +#ifdef HA_MALLOC_TRACK + cl_ptr_track(ptr); + cl_ptr_tag(ptr, "cl_malloc.c", "realloc", 0); +#endif bhdr->hdr.reqsize = newsize; ptr = (((char*)bhdr)+cl_malloc_hdr_offset); ADD_GUARD(ptr); @@ -548,6 +674,12 @@ #ifdef HA_MALLOC_MAGIC hdrret->hdr.magic = HA_MALLOC_MAGIC; #endif +#ifdef HA_MALLOC_TRACK + hdrret->hdr.left = NULL; + hdrret->hdr.right = NULL; + hdrret->hdr.owner[0] = '\0'; + hdrret->hdr.dumped = 0; +#endif if (memstats) { memstats->nbytes_alloc += mallocsize; @@ -567,14 +699,62 @@ cl_calloc(size_t nmemb, size_t size) { void * ret = cl_malloc(nmemb*size); - + if (ret != NULL) { memset(ret, 0, nmemb*size); + cl_ptr_tag(ret, "cl_malloc.c", "cl_calloc", 0); } return(ret); } +#ifdef HA_MALLOC_TRACK +void * +cl_calloc_track(size_t nmemb, size_t size, + const char *file, const char *function, const int line) +{ + void* ret; + + ret = cl_calloc(nmemb, size); + + if (ret) { + cl_ptr_tag(ret, file, function, line); + } + + return ret; +} + +void* +cl_realloc_track(void *ptr, size_t newsize, + const char *file, const char *function, const int line) +{ + void* ret; + + ret = cl_realloc(ptr, newsize); + + if (ret) { + cl_ptr_tag(ret, file, function, line); + } + + return ret; +} + +void * +cl_malloc_track(size_t size, + const char *file, const char *function, const int line) +{ + void* ret; + + ret = cl_malloc(size); + if (ret) { + /* Retag with the proper owner. */ + cl_ptr_tag(ret, file, function, line); + } + + return ret; +} + +#endif /* * cl_strdup: strdup clone @@ -632,6 +812,9 @@ pristoff += sizeof(b.next); } #endif +#ifdef HA_MALLOC_TRACK + cl_ptr_init(); +#endif } void @@ -657,6 +840,10 @@ const unsigned char * cp; cl_log(LOG_INFO, "Dumping cl_malloc item @ 0x%lx, bucket address: 0x%lx" , ((unsigned long)b)+cl_malloc_hdr_offset, (unsigned long)b); +#ifdef HA_MALLOC_TRACK + cl_log(LOG_INFO, "Owner: %s" + , b->hdr.owner); +#endif #ifdef HA_MALLOC_MAGIC cl_log(LOG_INFO, "Magic number: 0x%lx reqsize=%ld" ", bucket=%d, bucksize=%ld" ------------------------------ _______________________________________________ Linux-ha-cvs mailing list Linux-ha-cvs@lists.linux-ha.org http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs End of Linux-ha-cvs Digest, Vol 32, Issue 30 ********************************************