master - cleanup: tiny speedup of lib_dir checking
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9f0e27a18c60193feae83e458f821efc6ac64683 Commit: 9f0e27a18c60193feae83e458f821efc6ac64683 Parent: 0fcdc8a020afcafa182da93922c171604cf3035e Author: Zdenek Kabelac <[email protected]> AuthorDate: Fri Dec 6 16:35:54 2013 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Tue Dec 10 11:15:48 2013 +0100
cleanup: tiny speedup of lib_dir checking
Instead of repeated lookup of global/library_dir - remember first search in command context - saves couple lines in debug output...
--- WHATS_NEW | 1 + lib/commands/toolcontext.c | 2 ++ lib/commands/toolcontext.h | 1 + lib/misc/sharedlib.c | 7 ++++--- 4 files changed, 8 insertions(+), 3 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.105 - ===================================== + Cache global library dir in command context. Return success when inserting dirs and links into device cache. Test for remote exclusive activation after activation fails. Support lvconvert --merge for thin snapshots.
lib/commands/toolcontext.c +2 -0
@@ -1654,6 +1654,8 @@ int refresh_toolcontext(struct cmd_context *cmd) cmd->hosttags =0 ; + cmd->lib_dir =NULL ; +if (!_init_lvm_conf (cmd))return 0 ;
lib/commands/toolcontext.h +1 -0
@@ -121,6 +121,7 @@ struct cmd_context {struct dm_list tags;int hosttags; +const char *lib_dir;/* Cache value global/library_dir */ char system_dir[PATH_MAX ];char dev_dir[PATH_MAX ];char proc_dir[PATH_MAX ];
lib/misc/sharedlib.c +4 -3
@@ -16,6 +16,7 @@#include "lib.h" #include "config.h" #include "sharedlib.h" +#include "toolcontext.h" #include <limits.h> #include <sys/stat.h>
@@ -25,13 +26,13 @@ void get_shared_library_path(struct cmd_context *cmd, const char *libname, char *path, size_t path_len) {struct stat info; -const char *lib_dir;/* If libname doesn't begin with '/' then use lib_dir/libname, * if present */ if (libname[0 ] =='/' || - !(lib_dir =find_config_tree_str (cmd, global_library_dir_CFG,NULL )) || - (dm_snprintf (path, path_len,"%s/%s" , lib_dir, + (!cmd->lib_dir && + !(cmd->lib_dir =find_config_tree_str (cmd, global_library_dir_CFG,NULL ))) || + (dm_snprintf (path, path_len,"%s/%s" , cmd->lib_dir, libname) ==-1 ) ||stat (path, &info) ==-1 ) {strncpy (path, libname, path_len -1 ); path[path_len -1 ] ='\0' ;