From 22e0167d054c6880a66d51a7d86695fe2dd97f44 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Fri, 28 Aug 2009 00:16:50 +0000 Subject: libglusterfsclient: Enhance VMP searching logic Another attempt to enhance searching for VMP entries. There was a problem of returning the longest prefix match from all the VMPs without checking whether the number of matched components were same as the number of components in the candidate VMP. Signed-off-by: Anand V. Avati BUG: 209 (VMP parsing through fstab has issues) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=209 --- libglusterfsclient/src/libglusterfsclient.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libglusterfsclient') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index d8236cf3f92..699cd38eb14 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -1428,8 +1428,9 @@ _libgf_vmp_search_entry (char *path, int searchtype) } list_for_each_entry(entry, &vmplist.list, list) { + vmpcompcount = libgf_count_path_components (entry->vmp); matchcount = libgf_vmp_entry_match (entry, path); - if (matchcount > maxcount) { + if ((matchcount > maxcount) && (matchcount == vmpcompcount)) { maxcount = matchcount; maxentry = entry; } @@ -1439,6 +1440,7 @@ _libgf_vmp_search_entry (char *path, int searchtype) * match, this is used to check whether duplicate entries are present * in the vmplist. */ + vmpcompcount = 0; if ((searchtype == LIBGF_VMP_EXACT) && (maxentry)) { vmpcompcount = libgf_count_path_components (maxentry->vmp); if (vmpcompcount != matchcount) -- cgit