]> git.sur5r.net Git - openldap/blob - servers/slapd/back-tcl/tcl_abandon.c
Free IDL_CACHE locks
[openldap] / servers / slapd / back-tcl / tcl_abandon.c
1 /* $OpenLDAP$ */
2 /* abandon.c - tcl abandon routine
3  *
4  * Copyright 1999, Ben Collins <bcollins@debian.org>, All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted only
7  * as authorized by the OpenLDAP Public License.  A copy of this
8  * license is available at http://www.OpenLDAP.org/license.html or
9  * in file LICENSE in the top-level directory of the distribution.
10  */
11
12 #include "portable.h"
13
14 #include <stdio.h>
15
16 #include "slap.h"
17 #include "tcl_back.h"
18
19 int
20 tcl_back_abandon (
21         Operation * op,
22         SlapReply * rs
23 )
24 {
25         char *results, *command;
26         struct berval suf_tcl;
27         int code, err = 0;
28         struct tclinfo *ti = (struct tclinfo *) op->o_bd->be_private;
29
30         if (ti->ti_abandon.bv_len == 0) {
31                 return (-1);
32         }
33
34         if (tcl_merge_bvlist(op->o_bd->be_suffix, &suf_tcl) == NULL) {
35                 return (-1);
36         }
37
38         command = (char *) ch_malloc (ti->ti_abandon.bv_len + suf_tcl.bv_len
39                 + 80);
40         sprintf (command, "%s ABANDON {%ld/%ld} {%s} {%ld/%d}",
41                 ti->ti_abandon.bv_val, op->o_connid, (long) op->o_msgid,
42                 suf_tcl.bv_val, op->o_connid, op->oq_abandon.rs_msgid);
43         Tcl_Free (suf_tcl.bv_val);
44
45         ldap_pvt_thread_mutex_lock (&tcl_interpreter_mutex);
46         code = Tcl_GlobalEval (ti->ti_ii->interp, command);
47         results = (char *) ch_strdup (ti->ti_ii->interp->result);
48         ldap_pvt_thread_mutex_unlock (&tcl_interpreter_mutex);
49         free (command);
50
51         if (code != TCL_OK) {
52                 err = LDAP_OTHER;
53                 Debug (LDAP_DEBUG_SHELL, "tcl_abandon_error: %s\n", results,
54                         0, 0);
55         }
56
57         free (results);
58         return (err);
59 }