valgrind cleanups

This commit is contained in:
Fish 2005-08-13 09:29:26 +00:00
parent b3cb1e12e4
commit 3621075da1
17 changed files with 166 additions and 11 deletions

1
.gitattributes vendored
View file

@ -566,6 +566,7 @@ src/win32/neostats.rc -text
src/win32/resource.h -text src/win32/resource.h -text
src/win32/winmain.c -text src/win32/winmain.c -text
tools/generate_header -text tools/generate_header -text
tools/neostats.suppression -text
tools/sqlphp/README -text tools/sqlphp/README -text
tools/sqlphp/rta_tables.php -text tools/sqlphp/rta_tables.php -text
tools/sqlphp/rta_view.php -text tools/sqlphp/rta_view.php -text

View file

@ -4,6 +4,9 @@ Anything we add/remove/fix/change is in here (even our rants)
Fish (F), Mark (M), DeadNotBuried (D) Fish (F), Mark (M), DeadNotBuried (D)
=============================================================================== ===============================================================================
* NeoStats * Version 3.0.a3-dev * 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) - Sync up libevent to distribution of 1.1a (F)
- Make QuoteServ take a optional database for Quote Command (F) - Make QuoteServ take a optional database for Quote Command (F)
- Fix up triggering WANT_NICKIP code (F) - Fix up triggering WANT_NICKIP code (F)

View file

@ -178,6 +178,12 @@ event_init(void)
return (current_base); return (current_base);
} }
int
event_fini(void)
{
return event_priority_fini(current_base->nactivequeues);
}
int int
event_priority_init(int npriorities) event_priority_init(int npriorities)
{ {
@ -191,7 +197,6 @@ event_base_priority_init(struct event_base *base, int npriorities)
if (base->event_count_active) if (base->event_count_active)
return (-1); return (-1);
if (base->nactivequeues && npriorities != base->nactivequeues) { if (base->nactivequeues && npriorities != base->nactivequeues) {
for (i = 0; i < base->nactivequeues; ++i) { for (i = 0; i < base->nactivequeues; ++i) {
free(base->activequeues[i]); free(base->activequeues[i]);
@ -199,6 +204,7 @@ event_base_priority_init(struct event_base *base, int npriorities)
free(base->activequeues); free(base->activequeues);
} }
/* Allocate our priority queues */ /* Allocate our priority queues */
base->nactivequeues = npriorities; base->nactivequeues = npriorities;
base->activequeues = (struct event_list **)calloc(base->nactivequeues, base->activequeues = (struct event_list **)calloc(base->nactivequeues,
@ -216,6 +222,29 @@ event_base_priority_init(struct event_base *base, int npriorities)
return (0); return (0);
} }
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 int
event_haveevents(struct event_base *base) event_haveevents(struct event_base *base)
{ {

View file

@ -129,6 +129,8 @@ struct eventop {
#define TIMEOUT_DEFAULT {5, 0} #define TIMEOUT_DEFAULT {5, 0}
void *event_init(void); void *event_init(void);
int event_fini(void);
int event_dispatch(void); int event_dispatch(void);
int event_base_dispatch(struct event_base *); int event_base_dispatch(struct event_base *);
@ -190,7 +192,9 @@ const char *event_get_method(void);
/* These functions deal with event priorities */ /* These functions deal with event priorities */
int event_priority_init(int); int event_priority_init(int);
int event_priority_fini(int);
int event_base_priority_init(struct event_base *, 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); int event_priority_set(struct event *, int);
/* These functions deal with buffering input and output */ /* These functions deal with buffering input and output */

View file

@ -234,6 +234,7 @@ int ModFini( void )
database *db; database *db;
hnode_t *hn; hnode_t *hn;
hscan_t hs; hscan_t hs;
int i;
SET_SEGV_LOCATION(); SET_SEGV_LOCATION();
hash_scan_begin( &hs, qshash ); hash_scan_begin( &hs, qshash );
@ -241,6 +242,12 @@ int ModFini( void )
db =( ( database * )hnode_get( hn ) ); db =( ( database * )hnode_get( hn ) );
hash_delete( qshash, hn ); hash_delete( qshash, hn );
hnode_destroy( 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 ); ns_free( db );
} }
hash_destroy( qshash ); hash_destroy( qshash );

View file

@ -327,4 +327,5 @@ void FiniDCC( void )
dccnode = list_next( dcclist, dccnode ); dccnode = list_next( dcclist, dccnode );
} }
list_destroy_nodes( dcclist ); list_destroy_nodes( dcclist );
list_destroy(dcclist);
} }

View file

@ -104,12 +104,16 @@ void *ns_dlopen (const char *file, int mode)
int ns_dlclose (void *handle) int ns_dlclose (void *handle)
{ {
#ifndef VALGRIND
#ifdef WIN32 #ifdef WIN32
FreeLibrary((HMODULE)handle); FreeLibrary((HMODULE)handle);
return 0; return 0;
#else #else
return (dlclose (handle)); return (dlclose (handle));
#endif #endif
#else
return NS_SUCCESS;
#endif
} }
char *ns_dlerror (void) char *ns_dlerror (void)

View file

@ -252,8 +252,7 @@ void FiniDns (void)
list_destroy (dnsqueue); list_destroy (dnsqueue);
event_del(dnstimeout); event_del(dnstimeout);
free(dnstimeout); free(dnstimeout);
adns_finish(ads);
free(ads);
} }
/** @brief Canx any DNS queries for modules we might be unloading /** @brief Canx any DNS queries for modules we might be unloading
* *

View file

@ -105,6 +105,7 @@ int InitModExcludes(Module *mod_ptr)
void FiniExcludes(void) void FiniExcludes(void)
{ {
DBACloseTable("exclusions");
list_destroy_auto (exclude_list); list_destroy_auto (exclude_list);
} }

View file

@ -332,6 +332,11 @@ int InitIrcd( void )
return NS_SUCCESS; return NS_SUCCESS;
} }
int FiniIrcd ( void ) {
ns_dlclose(protocol_module_handle);
return NS_SUCCESS;
}
/** @brief HaveFeature /** @brief HaveFeature
* *
* @return 1 if have else 0 * @return 1 if have else 0

View file

@ -269,9 +269,11 @@ void FiniCore( void )
FiniBans(); FiniBans();
FiniDns(); FiniDns();
FiniModules(); FiniModules();
FiniSocks(); FiniServices();
FiniBots(); FiniBots();
FiniTimers(); FiniTimers();
FiniSocks();
FiniIrcd();
} }
/** @brief InitCore /** @brief InitCore

View file

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

View file

@ -200,7 +200,7 @@ void InitServices( void )
*/ */
void FiniServices( void ) void FiniServices( void )
{ {
del_services_set_list (ns_debugsettings); free(GET_CUR_MODULE()->event_list);
} }
/** @brief init_services_bot /** @brief init_services_bot

View file

@ -49,14 +49,10 @@ static char msg_sigterm[] = "SIGTERM received, shutting down server.";
RETSIGTYPE sigterm_handler( int signum ) RETSIGTYPE sigterm_handler( int signum )
{ {
#ifdef VALGRIND
exit( NS_SUCCESS );
#else /* VALGRIND */
nlog( LOG_CRITICAL, msg_sigterm ); nlog( LOG_CRITICAL, msg_sigterm );
/* XXX-Mark something is wrong with irc_globops */ /* XXX-Mark something is wrong with irc_globops */
irc_globops( NULL, msg_sigterm ); irc_globops( NULL, msg_sigterm );
do_exit( NS_EXIT_NORMAL, msg_sigterm ); do_exit( NS_EXIT_NORMAL, msg_sigterm );
#endif /* VALGRIND */
} }
/** @brief SIGHUP handler /** @brief SIGHUP handler

View file

@ -514,6 +514,7 @@ void FiniSocks (void)
me.servsock = NULL; me.servsock = NULL;
} }
hash_destroy(sockethash); hash_destroy(sockethash);
event_fini();
} }
/** @brief create a new socket /** @brief create a new socket

View file

@ -59,6 +59,7 @@ int InitCurl(void)
void FiniCurl(void) void FiniCurl(void)
{ {
curl_multi_cleanup(curlmultihandle);
list_destroy_auto (activetransfers); list_destroy_auto (activetransfers);
} }

View file

@ -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
}