From: Kurt Zeilenga Date: Wed, 5 Jun 2002 16:40:16 +0000 (+0000) Subject: Patch: Non-unique msgid for abandon in back- (ITS#1793) X-Git-Tag: OPENLDAP_REL_ENG_2_MP~20 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=951ca2bd683641460c97bfe0324fd87d0fb9256d;p=openldap Patch: Non-unique msgid for abandon in back- (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 , May 2002. --- diff --git a/doc/man/man5/slapd-shell.5 b/doc/man/man5/slapd-shell.5 index 0beee6d657..a880f68c6a 100644 --- a/doc/man/man5/slapd-shell.5 +++ b/doc/man/man5/slapd-shell.5 @@ -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 ... .nf ABANDON -opid: msgid: }> -abandonid: +pid: .fi .TP .B add ... .nf ADD -opid: -msgid: +msgid: }> .fi @@ -54,8 +50,7 @@ msgid: .B bind ... .nf BIND -opid: -msgid: +msgid: }> dn: method: @@ -66,8 +61,7 @@ cred: .B compare ... .nf COMPARE -opid: -msgid: +msgid: }> dn: : @@ -76,8 +70,7 @@ dn: .B delete ... .nf DELETE -opid: -msgid: +msgid: }> dn: .fi @@ -85,8 +78,7 @@ dn: .B modify ... .nf MODIFY -opid: -msgid: +msgid: }> dn: .B modrdn ... .nf MODRDN -opid: -msgid: +msgid: }> dn: newrdn: @@ -111,8 +102,7 @@ deleteoldrdn: <0 or 1> .B search ... .nf SEARCH -opid: -msgid: +msgid: }> base: scope: <0-2, see ldap.h> @@ -127,16 +117,11 @@ attrs: <"all" or space-separated attribute list> .B unbind ... .nf UNBIND -opid: -msgid: +msgid: }> 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 diff --git a/servers/slapd/back-shell/abandon.c b/servers/slapd/back-shell/abandon.c index cae990af5b..9761f23376 100644 --- a/servers/slapd/back-shell/abandon.c +++ b/servers/slapd/back-shell/abandon.c @@ -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 could not find op %d\n", msgid, 0, 0 ); + return 0; + } - if ( pid != -1 ) { - Debug( LDAP_DEBUG_ARGS, "shell killing pid %d\n", + /* 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 */ diff --git a/servers/slapd/back-shell/add.c b/servers/slapd/back-shell/add.c index 134416866b..1d08c0c088 100644 --- a/servers/slapd/back-shell/add.c +++ b/servers/slapd/back-shell/add.c @@ -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 ); diff --git a/servers/slapd/back-shell/bind.c b/servers/slapd/back-shell/bind.c index fe36059215..e41c06c1f2 100644 --- a/servers/slapd/back-shell/bind.c +++ b/servers/slapd/back-shell/bind.c @@ -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 ); diff --git a/servers/slapd/back-shell/compare.c b/servers/slapd/back-shell/compare.c index b5ef2d24eb..4b19e8f374 100644 --- a/servers/slapd/back-shell/compare.c +++ b/servers/slapd/back-shell/compare.c @@ -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 ); diff --git a/servers/slapd/back-shell/delete.c b/servers/slapd/back-shell/delete.c index e675f8062e..6d3b27908d 100644 --- a/servers/slapd/back-shell/delete.c +++ b/servers/slapd/back-shell/delete.c @@ -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 ); diff --git a/servers/slapd/back-shell/modify.c b/servers/slapd/back-shell/modify.c index 5acddbe994..0b1719eddd 100644 --- a/servers/slapd/back-shell/modify.c +++ b/servers/slapd/back-shell/modify.c @@ -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 ); diff --git a/servers/slapd/back-shell/modrdn.c b/servers/slapd/back-shell/modrdn.c index e2c7d64d5f..68bfed9795 100644 --- a/servers/slapd/back-shell/modrdn.c +++ b/servers/slapd/back-shell/modrdn.c @@ -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 ); diff --git a/servers/slapd/back-shell/search.c b/servers/slapd/back-shell/search.c index a1579e20e2..c8c1118172 100644 --- a/servers/slapd/back-shell/search.c +++ b/servers/slapd/back-shell/search.c @@ -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 ); diff --git a/servers/slapd/back-shell/unbind.c b/servers/slapd/back-shell/unbind.c index a4327f99e2..e54173d7ba 100644 --- a/servers/slapd/back-shell/unbind.c +++ b/servers/slapd/back-shell/unbind.c @@ -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 : "") );