valgrind cleanups
This commit is contained in:
parent
b3cb1e12e4
commit
3621075da1
17 changed files with 166 additions and 11 deletions
1
.gitattributes
vendored
1
.gitattributes
vendored
|
@ -566,6 +566,7 @@ src/win32/neostats.rc -text
|
|||
src/win32/resource.h -text
|
||||
src/win32/winmain.c -text
|
||||
tools/generate_header -text
|
||||
tools/neostats.suppression -text
|
||||
tools/sqlphp/README -text
|
||||
tools/sqlphp/rta_tables.php -text
|
||||
tools/sqlphp/rta_view.php -text
|
||||
|
|
|
@ -4,6 +4,9 @@ Anything we add/remove/fix/change is in here (even our rants)
|
|||
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)
|
||||
|
|
|
@ -178,6 +178,12 @@ event_init(void)
|
|||
return (current_base);
|
||||
}
|
||||
|
||||
int
|
||||
event_fini(void)
|
||||
{
|
||||
return event_priority_fini(current_base->nactivequeues);
|
||||
}
|
||||
|
||||
int
|
||||
event_priority_init(int npriorities)
|
||||
{
|
||||
|
@ -191,7 +197,6 @@ event_base_priority_init(struct event_base *base, int npriorities)
|
|||
|
||||
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 @@ event_base_priority_init(struct event_base *base, int npriorities)
|
|||
free(base->activequeues);
|
||||
}
|
||||
|
||||
|
||||
/* Allocate our priority queues */
|
||||
base->nactivequeues = npriorities;
|
||||
base->activequeues = (struct event_list **)calloc(base->nactivequeues,
|
||||
|
@ -216,6 +222,29 @@ event_base_priority_init(struct event_base *base, int npriorities)
|
|||
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
|
||||
event_haveevents(struct event_base *base)
|
||||
{
|
||||
|
|
|
@ -129,6 +129,8 @@ struct eventop {
|
|||
#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 @@ const char *event_get_method(void);
|
|||
/* 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 */
|
||||
|
|
|
@ -234,6 +234,7 @@ int ModFini( void )
|
|||
database *db;
|
||||
hnode_t *hn;
|
||||
hscan_t hs;
|
||||
int i;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
hash_scan_begin( &hs, qshash );
|
||||
|
@ -241,6 +242,12 @@ int ModFini( void )
|
|||
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 );
|
||||
|
|
|
@ -327,4 +327,5 @@ void FiniDCC( void )
|
|||
dccnode = list_next( dcclist, dccnode );
|
||||
}
|
||||
list_destroy_nodes( dcclist );
|
||||
list_destroy(dcclist);
|
||||
}
|
||||
|
|
4
src/dl.c
4
src/dl.c
|
@ -104,12 +104,16 @@ void *ns_dlopen (const char *file, int mode)
|
|||
|
||||
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)
|
||||
|
|
|
@ -252,8 +252,7 @@ void FiniDns (void)
|
|||
list_destroy (dnsqueue);
|
||||
event_del(dnstimeout);
|
||||
free(dnstimeout);
|
||||
|
||||
free(ads);
|
||||
adns_finish(ads);
|
||||
}
|
||||
/** @brief Canx any DNS queries for modules we might be unloading
|
||||
*
|
||||
|
|
|
@ -105,6 +105,7 @@ int InitModExcludes(Module *mod_ptr)
|
|||
|
||||
void FiniExcludes(void)
|
||||
{
|
||||
DBACloseTable("exclusions");
|
||||
list_destroy_auto (exclude_list);
|
||||
}
|
||||
|
||||
|
|
|
@ -332,6 +332,11 @@ int InitIrcd( void )
|
|||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
int FiniIrcd ( void ) {
|
||||
ns_dlclose(protocol_module_handle);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
/** @brief HaveFeature
|
||||
*
|
||||
* @return 1 if have else 0
|
||||
|
|
|
@ -269,9 +269,11 @@ void FiniCore( void )
|
|||
FiniBans();
|
||||
FiniDns();
|
||||
FiniModules();
|
||||
FiniSocks();
|
||||
FiniServices();
|
||||
FiniBots();
|
||||
FiniTimers();
|
||||
FiniSocks();
|
||||
FiniIrcd();
|
||||
}
|
||||
|
||||
/** @brief InitCore
|
||||
|
|
|
@ -65,6 +65,7 @@ static dbm_sym dbm_sym_table[] =
|
|||
|
||||
static hash_t *dbhash;
|
||||
static char dbname[MAXPATH];
|
||||
void *dbm_module_handle;
|
||||
|
||||
/** @brief InitDBAMSymbols
|
||||
*
|
||||
|
@ -78,7 +79,6 @@ static char dbname[MAXPATH];
|
|||
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 @@ void FiniDBA( void )
|
|||
ns_free( dbe );
|
||||
}
|
||||
hash_destroy( dbhash );
|
||||
ns_dlclose(dbm_module_handle);
|
||||
|
||||
}
|
||||
|
||||
/** @brief DBAOpenDatabase
|
||||
|
@ -204,7 +206,7 @@ int DBACloseDatabase( void )
|
|||
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 );
|
||||
|
|
|
@ -200,7 +200,7 @@ void InitServices( void )
|
|||
*/
|
||||
void FiniServices( void )
|
||||
{
|
||||
del_services_set_list (ns_debugsettings);
|
||||
free(GET_CUR_MODULE()->event_list);
|
||||
}
|
||||
|
||||
/** @brief init_services_bot
|
||||
|
|
|
@ -49,14 +49,10 @@ static char msg_sigterm[] = "SIGTERM received, shutting down server.";
|
|||
|
||||
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
|
||||
|
|
|
@ -514,6 +514,7 @@ void FiniSocks (void)
|
|||
me.servsock = NULL;
|
||||
}
|
||||
hash_destroy(sockethash);
|
||||
event_fini();
|
||||
}
|
||||
|
||||
/** @brief create a new socket
|
||||
|
|
|
@ -59,6 +59,7 @@ int InitCurl(void)
|
|||
|
||||
void FiniCurl(void)
|
||||
{
|
||||
curl_multi_cleanup(curlmultihandle);
|
||||
list_destroy_auto (activetransfers);
|
||||
}
|
||||
|
||||
|
|
99
tools/neostats.suppression
Normal file
99
tools/neostats.suppression
Normal 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
|
||||
}
|
Reference in a new issue