diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index e4a271d84507b3ce242c467ef109c14ee21300dc..70bc4df4ca78a5ee34e5cebbf9cffe1233154325 100755 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -68,7 +68,7 @@ void jniGetGlobalMethod(JNIEnv *env) { case 1: do { taosMsleep(0); - } while (__atomic_load_n(&__init, __ATOMIC_ACQUIRE) == 1); + } while (__sync_val_load_32(&__init) == 1); case 2: return; } @@ -108,7 +108,7 @@ void jniGetGlobalMethod(JNIEnv *env) { g_rowdataSetByteArrayFp = (*env)->GetMethodID(env, g_rowdataClass, "setByteArray", "(I[B)V"); (*env)->DeleteLocalRef(env, rowdataClass); - __atomic_store_n(&__init, 2, __ATOMIC_RELEASE); + __sync_val_restore_32(&__init, 2); jniTrace("native method register finished"); } diff --git a/src/os/darwin/inc/os.h b/src/os/darwin/inc/os.h index 485d3ab78840f053a2adae76413ef5d94eb84c05..217981d90c06904419ecad04d0c3636a68dfe5ae 100644 --- a/src/os/darwin/inc/os.h +++ b/src/os/darwin/inc/os.h @@ -59,6 +59,8 @@ #define __sync_val_compare_and_swap_32 __sync_val_compare_and_swap #define __sync_add_and_fetch_64 __sync_add_and_fetch #define __sync_add_and_fetch_32 __sync_add_and_fetch +int32_t __sync_val_load_32(int32_t *ptr); +void __sync_val_restore_32(int32_t *ptr, int32_t newval); #define SWAP(a, b, c) \ do { \ diff --git a/src/os/darwin/src/tdarwin.c b/src/os/darwin/src/tdarwin.c index 266370633d60b0145ce077109155899e56697c11..2f97c7c37699a769186cb57fc7e4e47274a1629c 100644 --- a/src/os/darwin/src/tdarwin.c +++ b/src/os/darwin/src/tdarwin.c @@ -415,4 +415,12 @@ int tsem_post(dispatch_semaphore_t *sem) { int tsem_destroy(dispatch_semaphore_t *sem) { return 0; +} + +int32_t __sync_val_load_32(int32_t *ptr) { + return __atomic_load_n(ptr, __ATOMIC_ACQUIRE); +} + +void __sync_val_restore_32(int32_t *ptr, int32_t newval) { + __atomic_store_n(ptr, newval, __ATOMIC_RELEASE); } \ No newline at end of file diff --git a/src/os/linux/inc/os.h b/src/os/linux/inc/os.h index e842f486e1c815ef7b5cb94d94c83084ff410684..47533a8544a937e171c9ff42b4b861f7407972e2 100644 --- a/src/os/linux/inc/os.h +++ b/src/os/linux/inc/os.h @@ -62,6 +62,8 @@ #define __sync_val_compare_and_swap_32 __sync_val_compare_and_swap #define __sync_add_and_fetch_64 __sync_add_and_fetch #define __sync_add_and_fetch_32 __sync_add_and_fetch +int32_t __sync_val_load_32(int32_t *ptr); +void __sync_val_restore_32(int32_t *ptr, int32_t newval); #define SWAP(a, b, c) \ do { \ diff --git a/src/os/linux/src/tlinux.c b/src/os/linux/src/tlinux.c index 251b53cbd2aad6f7d7c1cc5374e31add259dc13a..b5271006e251e2de81443f1127053b1db4f7672a 100644 --- a/src/os/linux/src/tlinux.c +++ b/src/os/linux/src/tlinux.c @@ -339,4 +339,12 @@ bool taosSkipSocketCheck() { } return false; -} \ No newline at end of file +} + +int32_t __sync_val_load_32(int32_t *ptr) { + return __atomic_load_n(ptr, __ATOMIC_ACQUIRE); +} + +void __sync_val_restore_32(int32_t *ptr, int32_t newval) { + __atomic_store_n(ptr, newval, __ATOMIC_RELEASE); +} diff --git a/src/os/windows/inc/os.h b/src/os/windows/inc/os.h index cb2fd2e0347bd64fa520ce245ccdf15668afdb12..c74709449d9106b5dceb59f1efc499cbf07d80f3 100644 --- a/src/os/windows/inc/os.h +++ b/src/os/windows/inc/os.h @@ -78,6 +78,8 @@ int32_t __sync_val_compare_and_swap_32(int32_t *ptr, int32_t oldval, int32_t new int32_t __sync_add_and_fetch_32(int32_t *ptr, int32_t val); int64_t __sync_val_compare_and_swap_64(int64_t *ptr, int64_t oldval, int64_t newval); int64_t __sync_add_and_fetch_64(int64_t *ptr, int64_t val); +int32_t __sync_val_load_32(int32_t *ptr); +void __sync_val_restore_32(int32_t *ptr, int32_t newval); #define SWAP(a, b, c) \ do { \ @@ -151,6 +153,8 @@ void wordfree(wordexp_t *pwordexp); int flock(int fd, int option); +int fsync(int filedes); + char *getpass(const char *prefix); char *strsep(char **stringp, const char *delim); diff --git a/src/os/windows/src/twindows.c b/src/os/windows/src/twindows.c index f2aa4d2c50f53b0f41b33dfbe9cb175f8efba094..2de719b0fdac035e7e5f460d3facddf19bf74457 100644 --- a/src/os/windows/src/twindows.c +++ b/src/os/windows/src/twindows.c @@ -47,7 +47,7 @@ int64_t taosGetPthreadId() { } int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optlen) { - if (level == SOL_TCP && optname == TCP_KEEPCNT) { + if (level == SOL_SOCKET && optname == TCP_KEEPCNT) { return 0; } @@ -78,6 +78,14 @@ int64_t __sync_add_and_fetch_64(int64_t *ptr, int64_t val) { return InterlockedAdd64(ptr, val); } +int32_t __sync_val_load_32(int32_t *ptr) { + return InterlockedOr(ptr, 0); +} + +void __sync_val_restore_32(int32_t *ptr, int32_t newval) { + InterlockedCompareExchange(ptr, *ptr, newval); +} + void tsPrintOsInfo() {} char *taosCharsetReplace(char *charsetstr) { @@ -178,6 +186,10 @@ int flock(int fd, int option) { return 0; } +int fsync(int filedes) { + return 0; +} + int sigaction(int sig, struct sigaction *d, void *p) { return 0; }