From 105d6b040a60e99ad0c0300b63e1494b6f73255f Mon Sep 17 00:00:00 2001 From: yaofei517 <41509375+yaofei517@users.noreply.github.com> Date: Sun, 23 May 2021 17:11:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwindows=E4=B8=8Bvscode?= =?UTF-8?q?=E8=B0=83=E8=AF=95go=E7=A8=8B=E5=BA=8F=E5=90=8D=E6=97=A0?= =?UTF-8?q?=E5=90=8E=E7=BC=80=E7=9A=84=E6=83=85=E5=86=B5=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=A8=8B=E5=BA=8Fcrash=20(#6176)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复windows下vscode调试go程序名无后缀的情况导致程序crash * 修复windows下vscode调试go程序时临时程序_debug_bin无后缀的情况,导致调用接口发生crash * 修复由于头文件排序导致编译错误 --- src/os/src/windows/wSemphone.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/os/src/windows/wSemphone.c b/src/os/src/windows/wSemphone.c index a3f0367ee1..878ceba791 100644 --- a/src/os/src/windows/wSemphone.c +++ b/src/os/src/windows/wSemphone.c @@ -14,6 +14,7 @@ */ #define _DEFAULT_SOURCE + #include "os.h" #include "taosdef.h" #include "tglobal.h" @@ -24,7 +25,7 @@ bool taosCheckPthreadValid(pthread_t thread) { return thread.p != NULL; } -void taosResetPthread(pthread_t *thread) { thread->p = 0; } +void taosResetPthread(pthread_t* thread) { thread->p = 0; } int64_t taosGetPthreadId(pthread_t thread) { #ifdef PTW32_VERSION @@ -34,27 +35,24 @@ int64_t taosGetPthreadId(pthread_t thread) { #endif } -int64_t taosGetSelfPthreadId() { - return GetCurrentThreadId(); -} +int64_t taosGetSelfPthreadId() { return GetCurrentThreadId(); } -bool taosComparePthread(pthread_t first, pthread_t second) { - return first.p == second.p; -} +bool taosComparePthread(pthread_t first, pthread_t second) { return first.p == second.p; } -int32_t taosGetPId() { - return GetCurrentProcessId(); -} +int32_t taosGetPId() { return GetCurrentProcessId(); } -int32_t taosGetCurrentAPPName(char *name, int32_t* len) { +int32_t taosGetCurrentAPPName(char* name, int32_t* len) { char filepath[1024] = {0}; GetModuleFileName(NULL, filepath, MAX_PATH); - *strrchr(filepath,'.') = '\0'; + char* sub = strrchr(filepath, '.'); + if (sub != NULL) { + *sub = '\0'; + } strcpy(name, filepath); if (len != NULL) { - *len = (int32_t) strlen(filepath); + *len = (int32_t)strlen(filepath); } return 0; -- GitLab