From: Pierangelo Masarati Date: Mon, 28 Mar 2005 18:51:02 +0000 (+0000) Subject: document missing feature; avoid the risk of returning argv in an inconsistent state... X-Git-Tag: OPENLDAP_AC_BP~1051 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=27e5fabb8b791c665754bc4a58126c3ec65842e9;p=openldap document missing feature; avoid the risk of returning argv in an inconsistent state when an error occurs --- diff --git a/doc/man/man5/slapo-pcache.5 b/doc/man/man5/slapo-pcache.5 index e925554d71..2fb88ae57a 100644 --- a/doc/man/man5/slapo-pcache.5 +++ b/doc/man/man5/slapo-pcache.5 @@ -78,6 +78,21 @@ used by the \fBproxytemplate\fP directive to define cacheable templates. Specifies a cacheable template and "time to live" (in sec) of queries belonging to the template. +.TP +.B response-callback { head | tail } +Specifies whether the response callback should be placed at the +.B tail +(the default) or at the +.B head +(actually, wherever the stacking sequence would make it appear) +of the callback list. This affects how the overlay interacts with other +overlays, since the proxycache overlay should be executed as early +as possible (and thus configured as late as possible), to get +a chance to return the cached results; however, if executed early +at response, it would cache entries that may be later "massaged" +by other databases and thus returned \fIafter\fP massaging the first +time, and \fIbefore\fP massaging when cached. + .LP The following adds a template with filter string \fB((&sn=)(givenName=))\fP and attributes mail, postaladdress, telephonenumber and a TTL of 1 hour. diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index f991d4987f..e75b79c741 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -1499,18 +1499,19 @@ proxy_cache_config( AttributeName* attr_name; AttributeName* attrarray; const char* text=NULL; - char *save_argv0 = NULL; + char *argv0 = NULL; int index, i; int num; int rc = 0; if ( strncasecmp( argv[0], "proxycache-", STRLENOF( "proxycache-" ) ) == 0 ) { - save_argv0 = argv[0]; - argv[0] += STRLENOF( "proxycache-" ); + argv0 = argv[0] + STRLENOF( "proxycache-" ); + } else { + argv0 = argv[0]; } - if ( strcasecmp( argv[0], "proxycache" ) == 0 ) { + if ( strcasecmp( argv0, "proxycache" ) == 0 ) { if ( argc < 6 ) { fprintf( stderr, "%s: line %d: missing arguments in \"proxycache" " " @@ -1549,7 +1550,7 @@ proxy_cache_config( qm->attr_sets[i].attrs = NULL; } - } else if ( strcasecmp( argv[0], "proxyattrset" ) == 0 ) { + } else if ( strcasecmp( argv0, "proxyattrset" ) == 0 ) { if ( argc < 3 ) { fprintf( stderr, "%s: line %d: missing arguments in \"proxyattrset " " \"\n", fname, lineno ); @@ -1581,7 +1582,7 @@ proxy_cache_config( attr_name->an_name.bv_len = 0; } } - } else if ( strcasecmp( argv[0], "proxytemplate" ) == 0 ) { + } else if ( strcasecmp( argv0, "proxytemplate" ) == 0 ) { if ( argc != 4 ) { fprintf( stderr, "%s: line %d: missing argument(s) in " "\"proxytemplate \" line\n", @@ -1625,7 +1626,7 @@ proxy_cache_config( temp->querystr.bv_val = NULL; cm->numtemplates++; - } else if ( strcasecmp( argv[0], "response-callback" ) == 0 ) { + } else if ( strcasecmp( argv0, "response-callback" ) == 0 ) { /* set to "tail" to put the response callback * at the end of the callback list; this is required * in case other overlays are present, so that the @@ -1653,13 +1654,12 @@ proxy_cache_config( } /* anything else */ else { + if ( argv0 != argv[0] ) { + return SLAP_CONF_UNKNOWN; + } rc = cm->db.bd_info->bi_db_config( &cm->db, fname, lineno, argc, argv ); } - if ( save_argv0 ) { - argv[0] = save_argv0; - } - return rc; }