HDFS-15977. Call explicit_bzero only if it is available. (#2914)
Reviewed-by: Masatake Iwasaki <iwasakims@apache.org>
Reviewed-by: Inigo Goiri <inigoiri@apache.org>
(cherry picked from commit f0241ec216
)
Conflicts:
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/x-platform/syscall_linux.cc
This commit is contained in:
parent
ff26a7700d
commit
f1c0dc84cd
|
@ -48,6 +48,7 @@ find_package(GSasl)
|
|||
find_package(Threads)
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckSymbolExists)
|
||||
|
||||
# Check if thread_local is supported
|
||||
unset (THREAD_LOCAL_SUPPORTED CACHE)
|
||||
|
@ -141,6 +142,11 @@ else (NOT NO_SASL)
|
|||
message(STATUS "Compiling with NO SASL SUPPORT")
|
||||
endif (NOT NO_SASL)
|
||||
|
||||
check_symbol_exists(explicit_bzero "string.h" HAVE_EXPLICIT_BZERO)
|
||||
if(HAVE_EXPLICIT_BZERO)
|
||||
add_definitions(-DHAVE_EXPLICIT_BZERO)
|
||||
endif()
|
||||
|
||||
add_definitions(-DASIO_STANDALONE -DASIO_CPP11_DATE_TIME)
|
||||
|
||||
# Disable optimizations if compiling debug
|
||||
|
|
|
@ -1402,7 +1402,11 @@ int hdfsGetBlockLocations(hdfsFS fs, const char *path, struct hdfsBlockLocations
|
|||
hdfsBlockLocations *locations = new struct hdfsBlockLocations();
|
||||
(*locations_out) = locations;
|
||||
|
||||
#ifdef HAVE_EXPLICIT_BZERO
|
||||
explicit_bzero(locations, sizeof(*locations));
|
||||
#else
|
||||
bzero(locations, sizeof(*locations));
|
||||
#endif
|
||||
locations->fileLength = ppLocations->getFileLength();
|
||||
locations->isLastBlockComplete = ppLocations->isLastBlockComplete();
|
||||
locations->isUnderConstruction = ppLocations->isUnderConstruction();
|
||||
|
|
|
@ -475,7 +475,11 @@ TEST_F(HdfsExtTest, TestReadStats) {
|
|||
hdfsFile file = hdfsOpenFile(fs, path.c_str(), O_WRONLY, 0, 0, 0);
|
||||
EXPECT_NE(nullptr, file);
|
||||
void * buf = malloc(size);
|
||||
#ifdef HAVE_EXPLICIT_BZERO
|
||||
explicit_bzero(buf, size);
|
||||
#else
|
||||
bzero(buf, size);
|
||||
#endif
|
||||
EXPECT_EQ(size, hdfsWrite(fs, file, buf, size));
|
||||
free(buf);
|
||||
EXPECT_EQ(0, hdfsCloseFile(fs, file));
|
||||
|
|
|
@ -92,7 +92,11 @@ public:
|
|||
hdfsFile file = hdfsOpenFile(*this, path.c_str(), O_WRONLY, 0, 0, 0);
|
||||
EXPECT_NE(nullptr, file);
|
||||
void * buf = malloc(size);
|
||||
#ifdef HAVE_EXPLICIT_BZERO
|
||||
explicit_bzero(buf, size);
|
||||
#else
|
||||
bzero(buf, size);
|
||||
#endif
|
||||
EXPECT_EQ(1024, hdfsWrite(*this, file, buf, size));
|
||||
EXPECT_EQ(0, hdfsCloseFile(*this, file));
|
||||
free(buf);
|
||||
|
|
Loading…
Reference in New Issue