openldap/servers/slapd/back-shell/abandon.c

62 lines
1.2 KiB
C
Raw Normal View History

1998-08-08 20:43:13 -04:00
/* abandon.c - shell backend abandon function */
/* $OpenLDAP$ */
2000-05-15 12:35:48 -04:00
/*
2003-01-03 15:20:47 -05:00
* Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
2000-05-15 12:35:48 -04:00
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
1998-08-08 20:43:13 -04:00
1998-10-24 21:41:42 -04:00
#include "portable.h"
1998-08-08 20:43:13 -04:00
#include <stdio.h>
1998-10-24 21:41:42 -04:00
#include <ac/socket.h>
#include <ac/string.h>
1998-08-08 20:43:13 -04:00
#include "slap.h"
#include "shell.h"
int
1998-08-08 20:43:13 -04:00
shell_back_abandon(
Operation *op,
SlapReply *rs )
1998-08-08 20:43:13 -04:00
{
struct shellinfo *si = (struct shellinfo *) op->o_bd->be_private;
1998-08-08 20:43:13 -04:00
FILE *rfp, *wfp;
pid_t pid;
1998-08-08 20:43:13 -04:00
Operation *o;
if ( si->si_abandon == NULL ) {
return 0;
}
pid = -1;
LDAP_STAILQ_FOREACH( o, &op->o_conn->c_ops, o_next ) {
if ( o->o_msgid == op->oq_abandon.rs_msgid ) {
pid = (pid_t) o->o_private;
break;
1998-08-08 20:43:13 -04:00
}
}
if ( pid == -1 ) {
Debug( LDAP_DEBUG_ARGS, "shell could not find op %ld\n",
(long) op->oq_abandon.rs_msgid, 0, 0 );
return 0;
}
1998-08-08 20:43:13 -04:00
if ( forkandexec( si->si_abandon, &rfp, &wfp ) == -1 ) {
return 0;
1998-08-08 20:43:13 -04:00
}
/* write out the request to the abandon process */
fprintf( wfp, "ABANDON\n" );
fprintf( wfp, "msgid: %d\n", op->oq_abandon.rs_msgid );
print_suffixes( wfp, op->o_bd );
fprintf( wfp, "pid: %ld\n", (long) pid );
1998-08-08 20:43:13 -04:00
fclose( wfp );
/* no result from abandon */
fclose( rfp );
return 0;
1998-08-08 20:43:13 -04:00
}