Skip to content

Commit 61b8764

Browse files
aajisakadeepakdamri
authored andcommitted
HDFS-15977. Call explicit_bzero only if it is available. (apache#2914)
Reviewed-by: Masatake Iwasaki <[email protected]> Reviewed-by: Inigo Goiri <[email protected]> (cherry picked from commit f0241ec) Conflicts: hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/x-platform/syscall_linux.cc
1 parent 8c21f20 commit 61b8764

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ find_package(GSasl)
4848
find_package(Threads)
4949

5050
include(CheckCXXSourceCompiles)
51+
include(CheckSymbolExists)
5152

5253
# Check if thread_local is supported
5354
unset (THREAD_LOCAL_SUPPORTED CACHE)
@@ -141,6 +142,11 @@ else (NOT NO_SASL)
141142
message(STATUS "Compiling with NO SASL SUPPORT")
142143
endif (NOT NO_SASL)
143144

145+
check_symbol_exists(explicit_bzero "string.h" HAVE_EXPLICIT_BZERO)
146+
if(HAVE_EXPLICIT_BZERO)
147+
add_definitions(-DHAVE_EXPLICIT_BZERO)
148+
endif()
149+
144150
add_definitions(-DASIO_STANDALONE -DASIO_CPP11_DATE_TIME)
145151

146152
# Disable optimizations if compiling debug

hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,11 @@ int hdfsGetBlockLocations(hdfsFS fs, const char *path, struct hdfsBlockLocations
14021402
hdfsBlockLocations *locations = new struct hdfsBlockLocations();
14031403
(*locations_out) = locations;
14041404

1405+
#ifdef HAVE_EXPLICIT_BZERO
1406+
explicit_bzero(locations, sizeof(*locations));
1407+
#else
14051408
bzero(locations, sizeof(*locations));
1409+
#endif
14061410
locations->fileLength = ppLocations->getFileLength();
14071411
locations->isLastBlockComplete = ppLocations->isLastBlockComplete();
14081412
locations->isUnderConstruction = ppLocations->isUnderConstruction();

hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_ext_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,11 @@ TEST_F(HdfsExtTest, TestReadStats) {
475475
hdfsFile file = hdfsOpenFile(fs, path.c_str(), O_WRONLY, 0, 0, 0);
476476
EXPECT_NE(nullptr, file);
477477
void * buf = malloc(size);
478+
#ifdef HAVE_EXPLICIT_BZERO
479+
explicit_bzero(buf, size);
480+
#else
478481
bzero(buf, size);
482+
#endif
479483
EXPECT_EQ(size, hdfsWrite(fs, file, buf, size));
480484
free(buf);
481485
EXPECT_EQ(0, hdfsCloseFile(fs, file));

hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfspp_mini_dfs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ class HdfsHandle {
9292
hdfsFile file = hdfsOpenFile(*this, path.c_str(), O_WRONLY, 0, 0, 0);
9393
EXPECT_NE(nullptr, file);
9494
void * buf = malloc(size);
95+
#ifdef HAVE_EXPLICIT_BZERO
96+
explicit_bzero(buf, size);
97+
#else
9598
bzero(buf, size);
99+
#endif
96100
EXPECT_EQ(1024, hdfsWrite(*this, file, buf, size));
97101
EXPECT_EQ(0, hdfsCloseFile(*this, file));
98102
free(buf);

0 commit comments

Comments
 (0)