File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
hadoop-common-project/hadoop-common/src/main
java/org/apache/hadoop/io/nativeio
native/src/org/apache/hadoop/io/nativeio Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ public String getMessage() {
141141 }
142142 }
143143
144- // Denotes the state of supporting PMDK. The value is set by JNI.
144+ // Denotes the state of supporting PMDK. The actual value is set via JNI.
145145 private static SupportState pmdkSupportState =
146146 SupportState .UNSUPPORTED ;
147147
Original file line number Diff line number Diff line change 3535#endif
3636
3737PmdkLibLoader * pmdkLoader ;
38+ // 1 represents loaded. Otherwise, not loaded.
39+ int pmdkLoaded ;
3840
3941/**
4042 * pmdk_load.c
4143 * Utility of loading the libpmem library and the required functions.
4244 * Building of this codes won't rely on any libpmem source codes, but running
4345 * into this will rely on successfully loading of the dynamic library.
44- *
4546 */
4647
4748static const char * load_functions () {
@@ -56,6 +57,10 @@ static const char* load_functions() {
5657 return NULL ;
5758}
5859
60+ /**
61+ * It should be idempotent to call this function for checking
62+ * whether PMDK lib is successfully loaded.
63+ */
5964void load_pmdk_lib (char * err , size_t err_len ) {
6065 const char * errMsg ;
6166 const char * library = NULL ;
@@ -67,10 +72,13 @@ void load_pmdk_lib(char* err, size_t err_len) {
6772
6873 err [0 ] = '\0' ;
6974
70- if (pmdkLoader != NULL ) {
75+ if (pmdkLoaded == 1 ) {
7176 return ;
7277 }
73- pmdkLoader = calloc (1 , sizeof (PmdkLibLoader ));
78+
79+ if (pmdkLoader == NULL ) {
80+ pmdkLoader = calloc (1 , sizeof (PmdkLibLoader ));
81+ }
7482
7583 // Load PMDK library
7684 #ifdef UNIX
@@ -103,4 +111,5 @@ void load_pmdk_lib(char* err, size_t err_len) {
103111 }
104112
105113 pmdkLoader -> libname = strdup (library );
114+ pmdkLoaded = 1 ;
106115}
You can’t perform that action at this time.
0 commit comments