openldap/servers/slapd/back-shell/abandon.c
Kurt Zeilenga 216049bd12 New Frontend->Backend Interface
Separates per backend type from per backend database initialization
	and startup.  Also supports per type / per backend shutdown.
New frontend startup/shutdown routines are also provided:
	slap_init() slap_startup() slap_shutdown() slap_destroy()
New frontend->backend startup/shutdown is managed by:
	backend_init() backend_startup() backend_shutdown backend_destroy
backend_init() now calls bi_init() to initial all function pointers
for the backend (excepting bi_init() which is now the only hardcoded
entry point).  New entry points are detailed in slap.h struct
backend_info.  backend_info is a per database type structure.
Besides the new startup/shutdown entry points, the new interface
also supports per backend type configuration options.  One could have:

	backend bdb2	(new Berkeley DB 2 backend)
	bdb2_home	/directory

	database bdb2
	...

	*** This code is fairly experimental ***
	*** Much cleanup and testing is still needed ***

see slap.h for details on struct backend_db and backend_info.
1999-02-05 09:03:47 +00:00

65 lines
1.3 KiB
C

/* abandon.c - shell backend abandon function */
#include "portable.h"
#include <stdio.h>
#include <signal.h>
#include <ac/socket.h>
#include <ac/string.h>
#include "slap.h"
#include "shell.h"
int
shell_back_abandon(
Backend *be,
Connection *conn,
Operation *op,
int msgid
)
{
struct shellinfo *si = (struct shellinfo *) be->be_private;
FILE *rfp, *wfp;
pid_t pid;
Operation *o;
/* no abandon command defined - just kill the process handling it */
if ( si->si_abandon == NULL ) {
ldap_pvt_thread_mutex_lock( &conn->c_opsmutex );
pid = -1;
for ( o = conn->c_ops; o != NULL; o = o->o_next ) {
if ( o->o_msgid == msgid ) {
pid = (pid_t) o->o_private;
break;
}
}
ldap_pvt_thread_mutex_unlock( &conn->c_opsmutex );
if ( pid != -1 ) {
Debug( LDAP_DEBUG_ARGS, "shell killing pid %d\n", pid,
0, 0 );
kill( pid, SIGTERM );
} else {
Debug( LDAP_DEBUG_ARGS, "shell could not find op %d\n",
msgid, 0, 0 );
}
return 0;
}
if ( forkandexec( si->si_abandon, &rfp, &wfp ) == -1 ) {
return 0;
}
/* write out the request to the abandon process */
fprintf( wfp, "ABANDON\n" );
fprintf( wfp, "msgid: %d\n", msgid );
print_suffixes( wfp, be );
fclose( wfp );
/* no result from abandon */
fclose( rfp );
return 0;
}