Mitigate extreme slowdown on systems without xattr.h or getfattr. Standard output was being spammed, resulting in a test that currently runs in around a minute to balloon out to almost 20.

This commit is contained in:
Ward Fisher 2024-07-16 12:19:16 -06:00
parent 5f89cd0c10
commit 848e85171a
4 changed files with 25 additions and 5 deletions

View File

@ -87,6 +87,11 @@ if(UNAME)
set(TMP_BUILDNAME "${osname}-${osrel}-${cpu}")
endif()
find_program(GETFATTR NAMES getfattr)
if(GETFATTR)
set(HAVE_GETFATTR TRUE)
endif()
# Define some Platforms
if(osname MATCHES "CYGWIN.*")
set(ISCYGWIN yes)

View File

@ -373,6 +373,9 @@ are set when opening a binary file on Windows. */
/* Define to 1 if you have the <ctype.h> header file. */
#cmakedefine HAVE_CTYPE_H 1
/* Define to 1 if you have the getfattr command line utility. */
#cmakedefine HAVE_GETFATTR 1
/* Define to 1 if you have the <sys/xattr.h> header file. */
#cmakedefine HAVE_SYS_XATTR_H

View File

@ -82,6 +82,12 @@ AC_LANG_POP([C])
if test $have_no_strict_aliasing = no; then
CFLAGS=$SAVE_CFLAGS
fi
##
# Check to see if we have getfattr
##
AC_CHECK_PROGS([HAVE_GETFATTR], [getfattr])
##
# Some files need to exist in build directories
# that do not correspond to their source directory, or

View File

@ -1648,16 +1648,22 @@ fprintf(stderr,"@@@ %s=|%s|\n",p,xvalue);
}
}
#else /*!HAVE_SYS_XATTR_H*/
#ifdef HAVE_GETFATTR
{
FILE *fp;
char cmd[4096];
memset(cmd,0,sizeof(cmd));
snprintf(cmd,sizeof(cmd),"getfattr %s | grep -c '.daos'",path);
if((fp = popen(cmd, "r")) != NULL) {
fscanf(fp, "%d", &rc);
pclose(fp);
snprintf(cmd,sizeof(cmd),"getfattr %s | grep -c '.daos'",path);
if((fp = popen(cmd, "r")) != NULL) {
fscanf(fp, "%d", &rc);
pclose(fp);
}
}
}
#else /*!HAVE_GETFATTR*/
/* We just can't test for DAOS container.*/
stat = 0;
#endif /*HAVE_GETFATTR*/
#endif /*HAVE_SYS_XATTR_H*/
}
/* Test for DAOS container */