openldap/servers/slapd/back-shell/abandon.c
Kurt Zeilenga 72ba4cfb71 Use -lldap_r instead of -lldap -lthread.
Likely broke things for non-posix threadings....

Update -lldap_r implementation to:
	remove attribute support
	hide thread detachment
	provide concurrency accessors
	provide initialization function
	fix gethostby{addr,name}_r codes (not coverred by HAVE_REENTRANT_FUNCTIONS)
Update servers/libraries to use ldap_pvt_thread_ calls.
Cleanup server codes (no #ifdef HAVE_PTHREAD_THIS or _THATs)!
Removed -llthread
1999-01-28 04:34:55 +00:00

62 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"
void
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;
}
if ( forkandexec( si->si_abandon, &rfp, &wfp ) == -1 ) {
return;
}
/* 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 );
}