diff options
author | Noriko Hosoi <nhosoi@kiki.usersys.redhat.com> | 2009-05-28 09:55:06 -0700 |
---|---|---|
committer | Noriko Hosoi <nhosoi@kiki.usersys.redhat.com> | 2009-05-28 09:55:06 -0700 |
commit | 67aca96ae2c53f74f896439840a82cbccbeb34cf (patch) | |
tree | ba1da5996985d5990ca5cb13db118983e6b85b2c /ldap/servers/plugins | |
parent | 586da77caf36591a261506e89dcc9e6a4db00036 (diff) | |
download | ds-67aca96ae2c53f74f896439840a82cbccbeb34cf.tar.gz ds-67aca96ae2c53f74f896439840a82cbccbeb34cf.tar.xz ds-67aca96ae2c53f74f896439840a82cbccbeb34cf.zip |
Use thread aware library for complex regex searches
For more details, see the design doc at http://directory.fedoraproject.org/wiki/Thread_Aware_Regex
Additional 2 unrelated changes are being made:
1) dbgen.pl.in: secretary and manager are having a dn format value "cn=...".
2) slapi_counter_sunos_sparcv9.S: adding "#define _ASM 1" to force to set an assembler code macro _ASM.
Diffstat (limited to 'ldap/servers/plugins')
-rw-r--r-- | ldap/servers/plugins/acl/acl.c | 27 | ||||
-rw-r--r-- | ldap/servers/plugins/syntaxes/string.c | 14 |
2 files changed, 18 insertions, 23 deletions
diff --git a/ldap/servers/plugins/acl/acl.c b/ldap/servers/plugins/acl/acl.c index 6e435559..f7f58650 100644 --- a/ldap/servers/plugins/acl/acl.c +++ b/ldap/servers/plugins/acl/acl.c @@ -3141,12 +3141,13 @@ int acl_match_substring ( Slapi_Filter *f, char *str, int exact_match) { int i, rc, len; - char *p; + char *p = NULL; char *end, *realval, *tmp; char pat[BUFSIZ]; char buf[BUFSIZ]; char *type, *initial, *final; char **any; + Slapi_Regex *re = NULL; if ( 0 != slapi_filter_get_subfilt ( f, &type, &initial, &any, &final ) ) { return (ACL_FALSE); @@ -3234,29 +3235,21 @@ acl_match_substring ( Slapi_Filter *f, char *str, int exact_match) ** Now we will compile the pattern and compare wth the string to ** see if the input string matches with the patteren or not. */ - slapd_re_lock(); - if ((p = slapd_re_comp (pat)) != 0) { + p = NULL; + re = slapi_re_comp( pat, &p ); + if (NULL == re) { slapi_log_error (SLAPI_LOG_ACL, plugin_name, - "acl_match_substring:re_comp failed (%s)\n", p); - slapd_re_unlock(); + "acl_match_substring:re_comp failed (%s)\n", p?p:"unknown"); return (ACL_ERR); } - /* re_exec() returns 1 if the string p1 matches the last compiled + /* slapi_re_exec() returns 1 if the string p1 matches the last compiled ** regular expression, 0 if the string p1 failed to match - ** (see man pages) - ** - ** IMPORTANT NOTE: If I use compile() and step() to do the patteren - ** matching, it seems that step() is leaking 1036 bytes/search - ** I couldn't figure out why it's leaking. */ - rc = slapd_re_exec( realval, -1 /* no timelimit */ ); - - slapd_re_unlock(); + rc = slapi_re_exec( re, realval, -1 /* no timelimit */ ); - if (tmp != NULL) { - slapi_ch_free ( (void **) &tmp ); - } + slapi_re_free(re); + slapi_ch_free ( (void **) &tmp ); if (rc == 1) { return ACL_TRUE; diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c index 138d98af..218cc762 100644 --- a/ldap/servers/plugins/syntaxes/string.c +++ b/ldap/servers/plugins/syntaxes/string.c @@ -208,7 +208,8 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char *final, time_t time_up = 0; time_t optime = 0; /* time op was initiated */ int timelimit = 0; /* search timelimit */ - Operation *op = NULL; + Operation *op = NULL; + Slapi_Regex *re = NULL; LDAPDebug( LDAP_DEBUG_FILTER, "=> string_filter_sub\n", 0, 0, 0 ); @@ -284,10 +285,11 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char *final, /* compile the regex */ p = (bigpat) ? bigpat : pat; - slapd_re_lock(); - if ( (tmpbuf = slapd_re_comp( p )) != 0 ) { + tmpbuf = NULL; + re = slapi_re_comp( p, &tmpbuf ); + if (NULL == re) { LDAPDebug( LDAP_DEBUG_ANY, "re_comp (%s) failed (%s): %s\n", - pat, p, tmpbuf ); + pat, p, tmpbuf?tmpbuf:"unknown" ); rc = LDAP_OPERATIONS_ERROR; goto bailout; } else { @@ -326,7 +328,7 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char *final, } value_normalize( realval, syntax, 1 /* trim leading blanks */ ); - tmprc = slapd_re_exec( realval, time_up ); + tmprc = slapi_re_exec( re, realval, time_up ); LDAPDebug( LDAP_DEBUG_TRACE, "re_exec (%s) %i\n", escape_string( realval, ebuf ), tmprc, 0 ); @@ -339,7 +341,7 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char *final, } } bailout: - slapd_re_unlock(); + slapi_re_free(re); slapi_ch_free((void**)&tmpbuf ); /* NULL is fine */ slapi_ch_free((void**)&bigpat ); /* NULL is fine */ |