Patch: Non-unique msgid for abandon in back-<shell,tcl> (ITS#1793)

================
Written by Hallvard B. Furuseth and placed into the public domain.
This software is not subject to any license of the University of Oslo.
			================

It has just occurred to me - duh - that the process ID of a back-shell
command is a perfectly good unique ID for it, and more useful than
any connection id/message id thingy.  Doesn't need extra arguments
to the shell commands either, except a pid: line to abandon.
And msgid: can still be removed in a future version.
Here is a patch.


Hallvard B. Furuseth <h.b.furuseth@usit.uio.no>, May 2002.
This commit is contained in:
Kurt Zeilenga 2002-06-05 16:40:16 +00:00
parent 1064f52dae
commit 951ca2bd68
10 changed files with 23 additions and 52 deletions

View File

@ -15,10 +15,8 @@ make it easy to tie an existing database to the
front-end.
.SH WARNING
.B "This backend's calling conventions have changed since OpenLDAP 2.0."
The operations receive a new "opid:" (operation ID) line, to be used
instead of "msgid:".
The "msgid:" line will be removed in a future version.
Also, abandon now gets a new "abandonid:" line.
The abandon operation now gets a new "pid:" line.
The "msgid:" lines will be removed in a future version.
.SH CONFIGURATION
These
.B slapd.conf
@ -36,17 +34,15 @@ Each option is followed by the input lines that the program receives:
.B abandon <pathname> <argument>...
.nf
ABANDON
opid: <operation ID>
msgid: <message ID of operation to abandon>
<repeat { "suffix:" <database suffix DN> }>
abandonid: <operation ID of operation to abandon>
pid: <process ID of operation to abandon>
.fi
.TP
.B add <pathname> <argument>...
.nf
ADD
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
<entry in LDIF format>
.fi
@ -54,8 +50,7 @@ msgid: <message ID>
.B bind <pathname> <argument>...
.nf
BIND
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
method: <method number>
@ -66,8 +61,7 @@ cred: <credentials>
.B compare <pathname> <argument>...
.nf
COMPARE
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
<attribute>: <value>
@ -76,8 +70,7 @@ dn: <DN>
.B delete <pathname> <argument>...
.nf
DELETE
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
.fi
@ -85,8 +78,7 @@ dn: <DN>
.B modify <pathname> <argument>...
.nf
MODIFY
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
<repeat {
@ -99,8 +91,7 @@ dn: <DN>
.B modrdn <pathname> <argument>...
.nf
MODRDN
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
newrdn: <new RDN>
@ -111,8 +102,7 @@ deleteoldrdn: <0 or 1>
.B search <pathname> <argument>...
.nf
SEARCH
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
base: <base DN>
scope: <0-2, see ldap.h>
@ -127,16 +117,11 @@ attrs: <"all" or space-separated attribute list>
.B unbind <pathname> <argument>...
.nf
UNBIND
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <bound DN>
.fi
.LP
An
.I operation ID
is a "connection ID/message ID" string identifying an operation.
.LP
Note that you need only supply configuration lines for those commands you
want the backend to handle.
Operations for which a command is not supplied will be refused with an

View File

@ -38,24 +38,19 @@ shell_back_abandon(
break;
}
}
if( pid == -1 ) {
LDAP_STAILQ_FOREACH( o, &conn->c_pending_ops, o_next ) {
if ( o->o_msgid == msgid ) {
pid = (pid_t) o->o_private;
break;
}
}
}
ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
}
ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
if ( pid != -1 ) {
Debug( LDAP_DEBUG_ARGS, "shell killing pid %d\n",
if ( pid == -1 ) {
Debug( LDAP_DEBUG_ARGS, "shell could not find op %d\n", msgid, 0, 0 );
return 0;
}
/* no abandon command defined - just kill the process handling it */
if ( si->si_abandon == NULL ) {
Debug( LDAP_DEBUG_ARGS, "shell killing pid %d\n",
(int) pid, 0, 0 );
kill( pid, SIGTERM );
} else {
Debug( LDAP_DEBUG_ARGS, "shell could not find op %d\n",
msgid, 0, 0 );
}
kill( pid, SIGTERM );
return 0;
}
@ -65,10 +60,9 @@ shell_back_abandon(
/* write out the request to the abandon process */
fprintf( wfp, "ABANDON\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %d\n", msgid );
print_suffixes( wfp, be );
fprintf( wfp, "abandonid: %ld/%d\n", op->o_connid, msgid );
fprintf( wfp, "pid: %ld\n", (long) pid );
fclose( wfp );
/* no result from abandon */

View File

@ -41,7 +41,6 @@ shell_back_add(
/* write out the request to the add process */
fprintf( wfp, "ADD\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
ldap_pvt_thread_mutex_lock( &entry2str_mutex );

View File

@ -46,7 +46,6 @@ shell_back_bind(
/* write out the request to the bind process */
fprintf( wfp, "BIND\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn->bv_val );

View File

@ -48,7 +48,6 @@ shell_back_compare(
/* write out the request to the compare process */
fprintf( wfp, "COMPARE\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn->bv_val );

View File

@ -42,7 +42,6 @@ shell_back_delete(
/* write out the request to the delete process */
fprintf( wfp, "DELETE\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn->bv_val );

View File

@ -45,7 +45,6 @@ shell_back_modify(
/* write out the request to the modify process */
fprintf( wfp, "MODIFY\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn->bv_val );

View File

@ -60,7 +60,6 @@ shell_back_modrdn(
/* write out the request to the modrdn process */
fprintf( wfp, "MODRDN\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn->bv_val );

View File

@ -51,7 +51,6 @@ shell_back_search(
/* write out the request to the search process */
fprintf( wfp, "SEARCH\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "base: %s\n", base->bv_val );

View File

@ -36,7 +36,6 @@ shell_back_unbind(
/* write out the request to the unbind process */
fprintf( wfp, "UNBIND\n" );
fprintf( wfp, "opid: %ld/%ld\n", op->o_connid, (long) op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", (conn->c_dn.bv_len ? conn->c_dn.bv_val : "") );