1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
1999-02-18 10:18:39 +08:00
|
|
|
/* close.c - tcl close routines
|
1999-02-15 03:20:14 +08:00
|
|
|
*
|
|
|
|
* Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted only
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "tcl_back.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
tcl_back_close (
|
|
|
|
BackendInfo * bi
|
|
|
|
)
|
|
|
|
{
|
1999-02-18 10:18:39 +08:00
|
|
|
Tcl_DeleteInterp (global_i->interp);
|
1999-02-17 09:55:03 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
return (0);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-02-18 10:18:39 +08:00
|
|
|
tcl_back_destroy (
|
|
|
|
BackendInfo * bi
|
1999-02-15 03:20:14 +08:00
|
|
|
)
|
|
|
|
{
|
1999-02-18 10:18:39 +08:00
|
|
|
free (global_i->interp);
|
|
|
|
free (global_i);
|
|
|
|
ldap_pvt_thread_mutex_destroy (&tcl_interpreter_mutex);
|
1999-02-15 03:20:14 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
return (0);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-02-18 10:18:39 +08:00
|
|
|
tcl_back_db_close (
|
|
|
|
BackendDB * bd
|
1999-02-15 03:20:14 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
struct tclinfo *ti = (struct tclinfo *) bd->be_private;
|
|
|
|
struct i_info *ti_tmp;
|
|
|
|
|
1999-02-17 09:55:03 +08:00
|
|
|
/* Disable the interp and associated struct */
|
1999-02-15 03:20:14 +08:00
|
|
|
ti->ti_ii->count--;
|
1999-02-18 10:18:39 +08:00
|
|
|
if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) {
|
1999-02-15 03:20:14 +08:00
|
|
|
/* no more db's using this and it's not the default */
|
1999-02-18 10:18:39 +08:00
|
|
|
for (ti_tmp = global_i; ti_tmp->next != ti->ti_ii; ti_tmp
|
|
|
|
= ti_tmp->next);
|
1999-02-17 09:55:03 +08:00
|
|
|
/* This bypasses this interp struct in the global hash */
|
1999-02-15 03:20:14 +08:00
|
|
|
ti_tmp->next = ti->ti_ii->next;
|
1999-02-18 10:18:39 +08:00
|
|
|
Tcl_DeleteInterp (ti->ti_ii->interp);
|
1999-02-17 09:55:03 +08:00
|
|
|
}
|
1999-02-18 10:18:39 +08:00
|
|
|
return (0);
|
1999-02-17 09:55:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-02-18 10:18:39 +08:00
|
|
|
tcl_back_db_destroy (
|
|
|
|
BackendDB * bd
|
1999-02-17 09:55:03 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
struct tclinfo *ti = (struct tclinfo *) bd->be_private;
|
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
/*
|
|
|
|
* Now free up the allocated memory used
|
|
|
|
*/
|
1999-02-17 09:55:03 +08:00
|
|
|
ti->ti_ii->count--;
|
1999-02-18 10:18:39 +08:00
|
|
|
if (!ti->ti_ii->count && strcasecmp ("default", ti->ti_ii->name)) {
|
|
|
|
free (ti->ti_ii->interp);
|
|
|
|
free (ti->ti_ii);
|
|
|
|
free (ti);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|
1999-02-18 10:18:39 +08:00
|
|
|
free (bd->be_private);
|
1999-02-15 03:20:14 +08:00
|
|
|
bd->be_private = NULL;
|
1999-02-17 09:55:03 +08:00
|
|
|
|
1999-02-18 10:18:39 +08:00
|
|
|
return (0);
|
1999-02-15 03:20:14 +08:00
|
|
|
}
|