]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-tcl/tcl_close.c
Modified to use libtool's ltdl instead of gmodule
[openldap] / servers / slapd / back-tcl / tcl_close.c
index 007bb6c2b61a2f0c66f58ce9350874407c5d992b..f01b9eefa640747acf1c1d54346148904f5c5b8b 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * close.c - tcl close routines
+/* close.c - tcl close routines
+ *
+ * $Id: tcl_close.c,v 1.3 1999/02/17 01:02:11 bcollins Exp $
  *
  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
  *
@@ -21,36 +22,62 @@ tcl_back_close (
        BackendInfo * bi
 )
 {
-       return 0;
+       Tcl_DeleteInterp (global_i->interp);
+
+       return (0);
 }
 
 int
-tcl_back_destroy(
-               BackendInfo *bi
+tcl_back_destroy (
+       BackendInfo * bi
 )
 {
-               ldap_pvt_thread_mutex_destroy( &tcl_interpreter_mutex );
+       free (global_i->interp);
+       free (global_i);
+       ldap_pvt_thread_mutex_destroy (&tcl_interpreter_mutex);
 
-               return 0;
+       return (0);
 }
 
 int
-tcl_back_db_destroy(
-               BackendDB *bd
+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)) {
+       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)
-                       ;
+               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;
-               free(ti->ti_ii);
-               free(ti);
+               Tcl_DeleteInterp (ti->ti_ii->interp);
        }
-       free( bd->be_private );
+       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)) {
+               free (ti->ti_ii->interp);
+               free (ti->ti_ii);
+               free (ti);
+       }
+       free (bd->be_private);
        bd->be_private = NULL;
+
+       return (0);
 }