]> git.sur5r.net Git - openldap/commitdiff
Don't leak slap_op when op not in list.
authorKurt Zeilenga <kurt@openldap.org>
Fri, 29 Jan 1999 05:46:12 +0000 (05:46 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 29 Jan 1999 05:46:12 +0000 (05:46 +0000)
Don't leak abandon mutex.
Use ch_malloc and friends.

servers/slapd/config.c
servers/slapd/connection.c
servers/slapd/daemon.c
servers/slapd/operation.c

index 6dcaae3d42f3bf08a048b9d1804bb433176f99b3..b810460680585fa12a89373d58802fb0e162d673 100644 (file)
@@ -282,7 +282,7 @@ read_config( char *fname, Backend **bep, FILE *pfp )
                                    fname, lineno, 0 );
                                exit( 1 );
                        }
-                       default_referral = (char *) malloc( strlen( cargv[1] )
+                       default_referral = (char *) ch_malloc( strlen( cargv[1] )
                            + sizeof("Referral:\n") + 1 );
                        strcpy( default_referral, "Referral:\n" );
                        strcat( default_referral, cargv[1] );
index 563d33bd50576ea695e7337252f6cc9f212c548f..e8f09b46c07aa2f4221c7f2ec2df204658fcfc01 100644 (file)
@@ -89,9 +89,13 @@ connection_operation( void *arg_v )
 
        ldap_pvt_thread_mutex_lock( &arg->co_conn->c_opsmutex );
        arg->co_conn->c_opscompleted++;
+
        slap_op_delete( &arg->co_conn->c_ops, arg->co_op );
+       arg->co_op = NULL;
+
        ldap_pvt_thread_mutex_unlock( &arg->co_conn->c_opsmutex );
 
+       arg->co_conn = NULL;
        free( (char *) arg );
 
        ldap_pvt_thread_mutex_lock( &ops_mutex );
@@ -195,12 +199,12 @@ connection_activity(
                free( tmpdn );
        }
 
+       ldap_pvt_thread_mutex_lock( &active_threads_mutex );
+       active_threads++;
+       ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
+
        if ( status = ldap_pvt_thread_create( &arg->co_op->o_tid, 1,
            connection_operation, (void *) arg ) != 0 ) {
                Debug( LDAP_DEBUG_ANY, "ldap_pvt_thread_create failed (%d)\n", status, 0, 0 );
-       } else {
-               ldap_pvt_thread_mutex_lock( &active_threads_mutex );
-               active_threads++;
-               ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
        }
 }
index 4e2ac8756c6cbb91c251c4bd0840687f28e1dcff..8b40c58fafd9d5827615f5a5d93023fe94c7f82b 100644 (file)
@@ -358,9 +358,9 @@ slapd_daemon(
                                    "signaling write waiter on %d\n", i, 0, 0 );
 
                                ldap_pvt_thread_mutex_lock( &active_threads_mutex );
-                               ldap_pvt_thread_cond_signal( &c[i].c_wcv );
-                               c[i].c_writewaiter = 0;
                                active_threads++;
+                               c[i].c_writewaiter = 0;
+                               ldap_pvt_thread_cond_signal( &c[i].c_wcv );
                                ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
                        }
 
index bf9590de98cdc8cc558600900cf53595fa17bf33..2fff851887656720e1705ec74cb54f7982fbf770 100644 (file)
 void
 slap_op_free( Operation *op )
 {
-       if ( op->o_ber != NULL )
+       ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
+
+       if ( op->o_ber != NULL ) {
                ber_free( op->o_ber, 1 );
+       }
        if ( op->o_dn != NULL ) {
                free( op->o_dn );
        }
        if ( op->o_ndn != NULL ) {
                free( op->o_ndn );
        }
-       /* ldap_pvt_thread_mutex_destroy( &op->o_abandonmutex ); */
+
+       ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+       ldap_pvt_thread_mutex_destroy( &op->o_abandonmutex );
        free( (char *) op );
 }
 
@@ -41,7 +46,8 @@ slap_op_add(
        for ( tmp = olist; *tmp != NULL; tmp = &(*tmp)->o_next )
                ;       /* NULL */
 
-       *tmp = (Operation *) calloc( 1, sizeof(Operation) );
+       *tmp = (Operation *) ch_calloc( 1, sizeof(Operation) );
+
        ldap_pvt_thread_mutex_init( &(*tmp)->o_abandonmutex );
        (*tmp)->o_ber = ber;
        (*tmp)->o_msgid = msgid;
@@ -72,6 +78,7 @@ slap_op_delete( Operation **olist, Operation *op )
        if ( *tmp == NULL ) {
                Debug( LDAP_DEBUG_ANY, "op_delete: can't find op %ld\n",
                    op->o_msgid, 0, 0 );
+               slap_op_free( op );
                return; 
        }