This is an automated email from the ASF dual-hosted git repository.
rakeshr pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 8e08f43 HDFS-16014: Fix an issue in checking native pmdk lib by
'hadoop checknative' command (#3762)
8e08f43 is described below
commit 8e08f43e0386e355c6e32282e5f5eadc5904ec2d
Author: PHILO-HE <[email protected]>
AuthorDate: Tue Dec 14 17:15:12 2021 +0800
HDFS-16014: Fix an issue in checking native pmdk lib by 'hadoop
checknative' command (#3762)
---
.../main/java/org/apache/hadoop/io/nativeio/NativeIO.java | 2 +-
.../native/src/org/apache/hadoop/io/nativeio/pmdk_load.c | 15 ++++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java
index 79b489b..ebe7f21 100644
---
a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java
+++
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java
@@ -141,7 +141,7 @@ public class NativeIO {
}
}
- // Denotes the state of supporting PMDK. The value is set by JNI.
+ // Denotes the state of supporting PMDK. The actual value is set via JNI.
private static SupportState pmdkSupportState =
SupportState.UNSUPPORTED;
diff --git
a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/pmdk_load.c
b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/pmdk_load.c
index 502508c..f1a1df5 100644
---
a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/pmdk_load.c
+++
b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/pmdk_load.c
@@ -35,13 +35,14 @@
#endif
PmdkLibLoader * pmdkLoader;
+// 1 represents loaded. Otherwise, not loaded.
+int pmdkLoaded;
/**
* pmdk_load.c
* Utility of loading the libpmem library and the required functions.
* Building of this codes won't rely on any libpmem source codes, but running
* into this will rely on successfully loading of the dynamic library.
- *
*/
static const char* load_functions() {
@@ -56,6 +57,10 @@ static const char* load_functions() {
return NULL;
}
+/**
+ * It should be idempotent to call this function for checking
+ * whether PMDK lib is successfully loaded.
+ */
void load_pmdk_lib(char* err, size_t err_len) {
const char* errMsg;
const char* library = NULL;
@@ -67,10 +72,13 @@ void load_pmdk_lib(char* err, size_t err_len) {
err[0] = '\0';
- if (pmdkLoader != NULL) {
+ if (pmdkLoaded == 1) {
return;
}
- pmdkLoader = calloc(1, sizeof(PmdkLibLoader));
+
+ if (pmdkLoader == NULL) {
+ pmdkLoader = calloc(1, sizeof(PmdkLibLoader));
+ }
// Load PMDK library
#ifdef UNIX
@@ -103,4 +111,5 @@ void load_pmdk_lib(char* err, size_t err_len) {
}
pmdkLoader->libname = strdup(library);
+ pmdkLoaded = 1;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]