]> git.sur5r.net Git - openldap/commitdiff
Implemented all of the (db_)destroy and (db_)close functions
authorBen Collins <bcollins@openldap.org>
Wed, 17 Feb 1999 01:55:03 +0000 (01:55 +0000)
committerBen Collins <bcollins@openldap.org>
Wed, 17 Feb 1999 01:55:03 +0000 (01:55 +0000)
servers/slapd/back-tcl/external.h
servers/slapd/back-tcl/tcl_close.c

index c3487d8177659083a8c34497fc2629706f145a0e..e65fb2edc73feb2d947f1286825823faffedcc8f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id$
+ * $Id: external.h,v 1.3 1999/02/16 23:26:05 bcollins Exp $
  */
 
 #ifndef _TCL_EXTERNAL_H
@@ -14,6 +14,7 @@ extern int    tcl_back_destroy LDAP_P(( BackendInfo *bi ));
 
 extern int     tcl_back_db_init LDAP_P(( BackendDB *bd ));
 extern int     tcl_back_db_open LDAP_P(( BackendDB *bd ));
+extern int     tcl_back_db_close LDAP_P(( BackendDB *bd ));
 extern int     tcl_back_db_destroy LDAP_P(( BackendDB *bd ));
 
 extern int     tcl_back_db_config LDAP_P(( BackendDB *bd,
index 007bb6c2b61a2f0c66f58ce9350874407c5d992b..085a4e41c1939f596903e79eaa117cdedc101d2e 100644 (file)
@@ -7,6 +7,10 @@
  * as authorized by the OpenLDAP Public License.  A copy of this
  * license is available at http://www.OpenLDAP.org/license.html or
  * in file LICENSE in the top-level directory of the distribution.
+ *
+ * $Id$
+ *
+ * $Log$
  */
 
 #include "portable.h"
@@ -21,7 +25,11 @@ tcl_back_close (
        BackendInfo * bi
 )
 {
-       return 0;
+       Tcl_DeleteInterp(global_i->interp);
+       Tcl_Free(global_i->interp);
+       free(global_i);
+
+       return( 0 );
 }
 
 int
@@ -29,28 +37,50 @@ tcl_back_destroy(
                BackendInfo *bi
 )
 {
-               ldap_pvt_thread_mutex_destroy( &tcl_interpreter_mutex );
+       ldap_pvt_thread_mutex_destroy( &tcl_interpreter_mutex );
 
-               return 0;
+       return( 0 );
 }
 
 int
-tcl_back_db_destroy(
+tcl_back_db_close(
                BackendDB *bd
 )
 {
        struct tclinfo *ti = (struct tclinfo *) bd->be_private;
        struct i_info *ti_tmp;
 
+       /* Disable the interp and associated struct */
        ti->ti_ii->count--;
        if (!ti->ti_ii->count && strcasecmp("default", ti->ti_ii->name)) {
                /* no more db's using this and it's not the default */
                for(ti_tmp = global_i; ti_tmp->next != ti->ti_ii; ti_tmp = ti_tmp->next)
                        ;
+               /* This bypasses this interp struct in the global hash */
                ti_tmp->next = ti->ti_ii->next;
+               Tcl_DeleteInterp(ti->ti_ii->interp);
+       }
+       return( 0 );
+}
+
+int
+tcl_back_db_destroy(
+               BackendDB *bd
+)
+{
+       struct tclinfo *ti = (struct tclinfo *) bd->be_private;
+
+       /*
+       * Now free up the allocated memory used
+       */
+       ti->ti_ii->count--;
+       if (!ti->ti_ii->count && strcasecmp("default", ti->ti_ii->name)) {
+               Tcl_Free(ti->ti_ii->interp);
                free(ti->ti_ii);
                free(ti);
        }
        free( bd->be_private );
        bd->be_private = NULL;
+
+       return( 0 );
 }