You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by aa...@apache.org on 2021/09/24 03:32:19 UTC
[hadoop] branch branch-3.3 updated: HDFS-15977. Call explicit_bzero
only if it is available. (#2914)
This is an automated email from the ASF dual-hosted git repository.
aajisaka pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.3 by this push:
new f1c0dc8 HDFS-15977. Call explicit_bzero only if it is available. (#2914)
f1c0dc8 is described below
commit f1c0dc84cd67493543120a7512d4bde3ac50dc74
Author: Akira Ajisaka <aa...@apache.org>
AuthorDate: Fri Apr 16 13:26:45 2021 +0900
HDFS-15977. Call explicit_bzero only if it is available. (#2914)
Reviewed-by: Masatake Iwasaki <iw...@apache.org>
Reviewed-by: Inigo Goiri <in...@apache.org>
(cherry picked from commit f0241ec2161f6eccdb9bdaf1cbcbee55be379217)
Conflicts:
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/x-platform/syscall_linux.cc
---
.../src/main/native/libhdfspp/CMakeLists.txt | 6 ++++++
.../src/main/native/libhdfspp/lib/bindings/c/hdfs.cc | 4 ++++
.../src/main/native/libhdfspp/tests/hdfs_ext_test.cc | 4 ++++
.../src/main/native/libhdfspp/tests/hdfspp_mini_dfs.h | 4 ++++
4 files changed, 18 insertions(+)
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt
index 2da5b6bb..f64eec1 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt
@@ -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
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
index 424bb6b..549da93 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
@@ -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();
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_ext_test.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_ext_test.cc
index fb55172..fba82b8 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_ext_test.cc
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_ext_test.cc
@@ -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));
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfspp_mini_dfs.h b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfspp_mini_dfs.h
index 98edbdc..320a958 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfspp_mini_dfs.h
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfspp_mini_dfs.h
@@ -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);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org