[NeoStats-Devel] [Commits] r2711 - in trunk: . lib/event modules/quoteserv src tools

[email protected] Sat, 13 Aug 2005 19:29:33 +1000
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Fish
Date: Sat Aug 13 17:29:26 2005
New Revision: 2711

Added:
   trunk/tools/neostats.suppression
Modified:
   trunk/ChangeLog
   trunk/lib/event/event.c
   trunk/lib/event/event.h
   trunk/modules/quoteserv/main.c
   trunk/src/dcc.c
   trunk/src/dl.c
   trunk/src/dns.c
   trunk/src/exclude.c
   trunk/src/ircprotocol.c
   trunk/src/main.c
   trunk/src/nsdba.c
   trunk/src/services.c
   trunk/src/signals.c
   trunk/src/sock.c
   trunk/src/transfer.c
Log:
valgrind cleanups

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	(original)
+++ trunk/ChangeLog	Sat Aug 13 17:29:26 2005
@@ -4,6 +4,9 @@
 Fish (F), Mark (M), DeadNotBuried (D)
 ===============================================================================
 * NeoStats * Version 3.0.a3-dev
+ - First round of memory cleanups with Valgrind (F)
+ - Create a runvalgrind.sh file with NeoStats suppressions for memory
+   checking (F)
  - Sync up libevent to distribution of 1.1a (F)
  - Make QuoteServ take a optional database for Quote Command (F)
  - Fix up triggering WANT_NICKIP code (F)

Modified: trunk/lib/event/event.c
==============================================================================
--- trunk/lib/event/event.c	(original)
+++ trunk/lib/event/event.c	Sat Aug 13 17:29:26 2005
@@ -179,6 +179,12 @@
 }
 
 int
+event_fini(void)
+{
+	return event_priority_fini(current_base->nactivequeues);
+}
+
+int
 event_priority_init(int npriorities)
 {
   return event_base_priority_init(current_base, npriorities);
@@ -191,7 +197,6 @@
 
 	if (base->event_count_active)
 		return (-1);
-
 	if (base->nactivequeues && npriorities != base->nactivequeues) {
 		for (i = 0; i < base->nactivequeues; ++i) {
 			free(base->activequeues[i]);
@@ -199,6 +204,7 @@
 		free(base->activequeues);
 	}
 
+
 	/* Allocate our priority queues */
 	base->nactivequeues = npriorities;
 	base->activequeues = (struct event_list **)calloc(base->nactivequeues,
@@ -217,6 +223,29 @@
 }
 
 int
+event_priority_fini(int npriorities)
+{
+	return event_base_priority_fini(current_base, npriorities);
+}
+
+int
+event_base_priority_fini(struct event_base *base, int npriorities)
+{
+	int i;
+	
+	if (base->event_count_active)
+		return (-1);
+	for (i = 0; i < base->nactivequeues; ++i) {
+		free(base->activequeues[i]);
+	}
+	free(base->activequeues);
+	free(base);
+	return (0);
+}
+
+
+
+int
 event_haveevents(struct event_base *base)
 {
 	return (base->event_count > 0);

Modified: trunk/lib/event/event.h
==============================================================================
--- trunk/lib/event/event.h	(original)
+++ trunk/lib/event/event.h	Sat Aug 13 17:29:26 2005
@@ -129,6 +129,8 @@
 #define TIMEOUT_DEFAULT	{5, 0}
 
 void *event_init(void);
+int event_fini(void);
+
 int event_dispatch(void);
 int event_base_dispatch(struct event_base *);
 
@@ -190,7 +192,9 @@
 /* These functions deal with event priorities */
 
 int	event_priority_init(int);
+int	event_priority_fini(int);
 int	event_base_priority_init(struct event_base *, int);
+int	event_base_priority_fini(struct event_base *, int);
 int	event_priority_set(struct event *, int);
 
 /* These functions deal with buffering input and output */

Modified: trunk/modules/quoteserv/main.c
==============================================================================
--- trunk/modules/quoteserv/main.c	(original)
+++ trunk/modules/quoteserv/main.c	Sat Aug 13 17:29:26 2005
@@ -234,6 +234,7 @@
 	database *db;
 	hnode_t *hn;
 	hscan_t hs;
+	int i;
 
 	SET_SEGV_LOCATION();
 	hash_scan_begin( &hs, qshash );
@@ -241,6 +242,12 @@
 		db =( ( database * )hnode_get( hn ) );
 		hash_delete( qshash, hn );
 		hnode_destroy( hn );
+		ns_free(db->prefixstring);
+		ns_free(db->suffixstring);
+		for (i = 0; i < db->stringcount; i++) {
+			ns_free(db->stringlist[i]);
+		}
+		ns_free(db->stringlist);
 		ns_free( db );
 	}
 	hash_destroy( qshash );

Modified: trunk/src/dcc.c
==============================================================================
--- trunk/src/dcc.c	(original)
+++ trunk/src/dcc.c	Sat Aug 13 17:29:26 2005
@@ -327,4 +327,5 @@
 		dccnode = list_next( dcclist, dccnode );
 	}
 	list_destroy_nodes( dcclist );
+	list_destroy(dcclist);
 }

Modified: trunk/src/dl.c
==============================================================================
--- trunk/src/dl.c	(original)
+++ trunk/src/dl.c	Sat Aug 13 17:29:26 2005
@@ -104,12 +104,16 @@
 
 int ns_dlclose (void *handle)
 {
+#ifndef VALGRIND
 #ifdef WIN32
 	FreeLibrary((HMODULE)handle);
 	return 0;
 #else
 	return (dlclose (handle));
 #endif
+#else
+	return NS_SUCCESS;
+#endif
 }
 
 char *ns_dlerror (void)

Modified: trunk/src/dns.c
==============================================================================
--- trunk/src/dns.c	(original)
+++ trunk/src/dns.c	Sat Aug 13 17:29:26 2005
@@ -252,8 +252,7 @@
 	list_destroy (dnsqueue);
 	event_del(dnstimeout);
 	free(dnstimeout);
-
-	free(ads);
+	adns_finish(ads);
 }
 /** @brief Canx any DNS queries for modules we might be unloading
  * 

Modified: trunk/src/exclude.c
==============================================================================
--- trunk/src/exclude.c	(original)
+++ trunk/src/exclude.c	Sat Aug 13 17:29:26 2005
@@ -105,6 +105,7 @@
 
 void FiniExcludes(void) 
 {
+	DBACloseTable("exclusions");
 	list_destroy_auto (exclude_list);
 }
 

Modified: trunk/src/ircprotocol.c
==============================================================================
--- trunk/src/ircprotocol.c	(original)
+++ trunk/src/ircprotocol.c	Sat Aug 13 17:29:26 2005
@@ -332,6 +332,11 @@
 	return NS_SUCCESS;
 }
 
+int FiniIrcd ( void ) {
+	ns_dlclose(protocol_module_handle);
+	return NS_SUCCESS;
+}
+
 /** @brief HaveFeature
  *
  *  @return 1 if have else 0

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Sat Aug 13 17:29:26 2005
@@ -269,9 +269,11 @@
 	FiniBans();
 	FiniDns();
 	FiniModules();
-	FiniSocks();
+	FiniServices();
 	FiniBots();
 	FiniTimers();
+	FiniSocks();
+	FiniIrcd();
 }
 
 /** @brief InitCore

Modified: trunk/src/nsdba.c
==============================================================================
--- trunk/src/nsdba.c	(original)
+++ trunk/src/nsdba.c	Sat Aug 13 17:29:26 2005
@@ -65,6 +65,7 @@
 
 static hash_t *dbhash;
 static char dbname[MAXPATH];
+void *dbm_module_handle;
 
 /** @brief InitDBAMSymbols
  *
@@ -78,7 +79,6 @@
 static int InitDBAMSymbols( void )
 {
 	static char dbm_path[MAXPATH];
-	void *dbm_module_handle;
 	dbm_sym *pdbm_sym;
 
 	ircsnprintf( dbm_path, 255, "%s/%s%s", MOD_PATH, me.dbm, MOD_STDEXT );
@@ -157,6 +157,8 @@
 		ns_free( dbe );
 	}
 	hash_destroy( dbhash );
+	ns_dlclose(dbm_module_handle);
+
 }
 
 /** @brief DBAOpenDatabase
@@ -204,7 +206,7 @@
 		hash_scan_begin( &ts, dbe->tablehash );
 		while(( tnode = hash_scan_next( &ts ) ) != NULL  ) {
 			tbe = (tableentry *) hnode_get( tnode );
-			DBACloseTable( tbe->table );
+			DBMCloseTable( tbe->handle );
 			hash_delete( dbe->tablehash, tnode );
 			hnode_destroy( tnode );
 			ns_free( tbe );

Modified: trunk/src/services.c
==============================================================================
--- trunk/src/services.c	(original)
+++ trunk/src/services.c	Sat Aug 13 17:29:26 2005
@@ -200,7 +200,7 @@
  */
 void FiniServices( void )
 {
-	del_services_set_list (ns_debugsettings);
+	free(GET_CUR_MODULE()->event_list);
 }
 
 /** @brief init_services_bot

Modified: trunk/src/signals.c
==============================================================================
--- trunk/src/signals.c	(original)
+++ trunk/src/signals.c	Sat Aug 13 17:29:26 2005
@@ -49,14 +49,10 @@
 
 RETSIGTYPE sigterm_handler( int signum )
 {
-#ifdef VALGRIND
-	exit( NS_SUCCESS );
-#else /* VALGRIND */
 	nlog( LOG_CRITICAL, msg_sigterm );
 	/* XXX-Mark something is wrong with irc_globops */
 	irc_globops( NULL, msg_sigterm );
 	do_exit( NS_EXIT_NORMAL, msg_sigterm );
-#endif /* VALGRIND */
 }
 
 /** @brief SIGHUP handler

Modified: trunk/src/sock.c
==============================================================================
--- trunk/src/sock.c	(original)
+++ trunk/src/sock.c	Sat Aug 13 17:29:26 2005
@@ -514,6 +514,7 @@
 		me.servsock = NULL;
 	}
 	hash_destroy(sockethash);
+	event_fini();
 }
 
 /** @brief create a new socket

Modified: trunk/src/transfer.c
==============================================================================
--- trunk/src/transfer.c	(original)
+++ trunk/src/transfer.c	Sat Aug 13 17:29:26 2005
@@ -59,6 +59,7 @@
 
 void FiniCurl(void) 
 {
+	curl_multi_cleanup(curlmultihandle);
 	list_destroy_auto (activetransfers);
 }
 

Added: trunk/tools/neostats.suppression
==============================================================================
--- (empty file)
+++ trunk/tools/neostats.suppression	Sat Aug 13 17:29:26 2005
@@ -0,0 +1,99 @@
+{
+   inet_ntoa
+   Memcheck:Leak
+   fun:malloc
+   fun:inet_ntoa
+}
+
+{
+   ns_dlopen
+   Memcheck:Leak
+   fun:calloc
+   fun:_dlerror_run
+   fun:dlopen@@GLIBC_2.1
+   fun:ns_dlopen
+}
+
+{
+   ns_dlopen2
+   Memcheck:Leak
+   fun:calloc
+   fun:_dl_new_object
+   fun:_dl_map_object_from_fd
+   fun:_dl_map_object
+   fun:dl_open_worker
+   fun:_dl_catch_error
+   fun:_dl_open
+   fun:dlopen_doit
+   fun:_dl_catch_error
+   fun:_dlerror_run
+   fun:dlopen@@GLIBC_2.1
+   fun:ns_dlopen
+}
+
+{
+   ns_dlopen3
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:_dl_new_object
+   fun:_dl_map_object_from_fd
+   fun:_dl_map_object
+   fun:dl_open_worker
+   fun:_dl_catch_error
+   fun:_dl_open
+   fun:dlopen_doit
+   fun:_dl_catch_error
+   fun:_dlerror_run
+   fun:dlopen@@GLIBC_2.1
+}
+{
+   ns_dlopen4
+   Memcheck:Leak
+   fun:calloc
+   fun:_dl_check_map_versions
+   fun:dl_open_worker
+   fun:_dl_catch_error
+   fun:_dl_open
+   fun:dlopen_doit
+   fun:_dl_catch_error
+   fun:_dlerror_run
+   fun:dlopen@@GLIBC_2.1
+   fun:ns_dlopen
+   fun:InitDBAMSymbols
+   fun:InitDBA
+}
+
+{
+   ns_dlopen5
+   Memcheck:Leak
+   fun:malloc
+   fun:_dl_map_object_deps
+   fun:dl_open_worker
+   fun:_dl_catch_error
+   fun:_dl_open
+   fun:dlopen_doit
+   fun:_dl_catch_error
+   fun:_dlerror_run
+   fun:dlopen@@GLIBC_2.1
+   fun:ns_dlopen
+   fun:InitDBAMSymbols
+   fun:InitDBA
+}
+
+{
+   ns_dlopen6
+   Memcheck:Leak
+   fun:malloc
+   fun:_dl_map_object
+   fun:dl_open_worker
+   fun:_dl_catch_error
+   fun:_dl_open
+   fun:dlopen_doit
+   fun:_dl_catch_error
+   fun:_dlerror_run
+   fun:dlopen@@GLIBC_2.1
+   fun:ns_dlopen
+   fun:InitDBAMSymbols
+   fun:InitDBA
+}