mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-26 09:39:45 -05:00
Add hacks to allow debugging with CSRI malloc.
(test001-populate runs without leak) Free global entry string buffer on shutdown.
This commit is contained in:
parent
533c4177c8
commit
c51f35fe0f
7 changed files with 54 additions and 2 deletions
|
|
@ -12,6 +12,12 @@
|
|||
#ifndef _AC_STDLIB_H
|
||||
#define _AC_STDLIB_H
|
||||
|
||||
#if defined( HAVE_CSRIMALLOC )
|
||||
#include <stdio.h>
|
||||
#define MALLOC_TRACE
|
||||
#include <libmalloc.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Ignore malloc.h if we have STDC_HEADERS */
|
||||
|
|
|
|||
|
|
@ -83,8 +83,6 @@ do_add( Connection *conn, Operation *op )
|
|||
e->e_ndn = ndn;
|
||||
e->e_private = NULL;
|
||||
|
||||
dn = NULL;
|
||||
|
||||
Debug( LDAP_DEBUG_ARGS, " do_add: ndn (%s)\n", e->e_ndn, 0, 0 );
|
||||
|
||||
/* get the attrs */
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
||||
*/
|
||||
|
||||
#define CH_FREE 1
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
@ -15,6 +17,8 @@
|
|||
|
||||
#include "slap.h"
|
||||
|
||||
#ifndef CSRIMALLOC
|
||||
|
||||
void *
|
||||
ch_malloc(
|
||||
ber_len_t size
|
||||
|
|
@ -97,3 +101,5 @@ ch_free( void *ptr )
|
|||
{
|
||||
ber_memfree( ptr );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,6 +19,15 @@ static unsigned char *ebuf; /* buf returned by entry2str */
|
|||
static unsigned char *ecur; /* pointer to end of currently used ebuf */
|
||||
static int emaxsize;/* max size of ebuf */
|
||||
|
||||
int entry_destroy(void)
|
||||
{
|
||||
free( *ebuf );
|
||||
ebuf = NULL;
|
||||
ecur = NULL;
|
||||
emaxsize = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Entry *
|
||||
str2entry( char *s )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -162,6 +162,8 @@ int slap_destroy(void)
|
|||
|
||||
rc = backend_destroy();
|
||||
|
||||
entry_destroy();
|
||||
|
||||
ldap_pvt_thread_destroy();
|
||||
|
||||
/* should destory the above mutex */
|
||||
|
|
|
|||
|
|
@ -159,6 +159,13 @@ int main( int argc, char **argv )
|
|||
int tls_port = 0;
|
||||
#endif
|
||||
|
||||
#ifdef CSRIMALLOC
|
||||
FILE *leakfile;
|
||||
if( ( leakfile = fopen( "slapd.leak", "w" )) == NULL ) {
|
||||
leakfile = stderr;
|
||||
}
|
||||
#endif
|
||||
|
||||
g_argc = argc;
|
||||
g_argv = argv;
|
||||
|
||||
|
|
@ -384,6 +391,10 @@ int main( int argc, char **argv )
|
|||
#endif
|
||||
#endif /* HAVE_WINSOCK */
|
||||
|
||||
#ifdef CSRIMALLOC
|
||||
mal_leaktrace(1);
|
||||
#endif
|
||||
|
||||
if ( slap_startup( NULL ) != 0 ) {
|
||||
rc = 1;
|
||||
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
|
||||
|
|
@ -428,6 +439,7 @@ int main( int argc, char **argv )
|
|||
shutdown:
|
||||
/* remember an error during shutdown */
|
||||
rc |= slap_shutdown( NULL );
|
||||
|
||||
destroy:
|
||||
/* remember an error during destroy */
|
||||
rc |= slap_destroy();
|
||||
|
|
@ -446,6 +458,10 @@ stop:
|
|||
closelog();
|
||||
slapd_daemon_destroy();
|
||||
|
||||
#ifdef CSRIMALLOC
|
||||
mal_dumpleaktrace( leakfile );
|
||||
#endif
|
||||
|
||||
MAIN_RETURN(rc);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,12 +118,25 @@ extern Attribute *backend_subschemasubentry( Backend * );
|
|||
* ch_malloc.c
|
||||
*/
|
||||
|
||||
#ifdef CSRIMALLOC
|
||||
#define ch_malloc malloc
|
||||
#define ch_realloc realloc
|
||||
#define ch_calloc calloc
|
||||
#define ch_strdup strdup
|
||||
#define ch_free free
|
||||
|
||||
#else
|
||||
void * ch_malloc LDAP_P(( ber_len_t size ));
|
||||
void * ch_realloc LDAP_P(( void *block, ber_len_t size ));
|
||||
void * ch_calloc LDAP_P(( ber_len_t nelem, ber_len_t size ));
|
||||
char * ch_strdup LDAP_P(( const char *string ));
|
||||
void ch_free LDAP_P(( void * ));
|
||||
|
||||
#ifndef CH_FREE
|
||||
#undef free
|
||||
#define free ch_free
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* charray.c
|
||||
|
|
@ -206,6 +219,8 @@ void build_new_dn LDAP_P(( char ** new_dn, char *e_dn, char * p_dn,
|
|||
* entry.c
|
||||
*/
|
||||
|
||||
int entry_destroy LDAP_P((void));
|
||||
|
||||
Entry * str2entry LDAP_P(( char *s ));
|
||||
char * entry2str LDAP_P(( Entry *e, int *len ));
|
||||
void entry_free LDAP_P(( Entry *e ));
|
||||
|
|
|
|||
Loading…
Reference in a new issue