fix: ret error
This commit is contained in:
parent
2ed4aeb0da
commit
ef8367fbb4
|
@ -94,7 +94,7 @@ static int32_t generateConfigFile(char* confDir) {
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
uDebug("[rsync] conf:%s", confContent);
|
uDebug("[rsync] conf:%s", confContent);
|
||||||
if (taosWriteFile(pFile, confContent, strlen(confContent)) != TSDB_CODE_SUCCESS) {
|
if (taosWriteFile(pFile, confContent, strlen(confContent)) <= 0) {
|
||||||
uError("[rsync] write conf file error," ERRNO_ERR_FORMAT, ERRNO_ERR_DATA);
|
uError("[rsync] write conf file error," ERRNO_ERR_FORMAT, ERRNO_ERR_DATA);
|
||||||
(void)taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
|
|
@ -102,9 +102,8 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
|
||||||
ts.tv_sec = tv.tv_sec;
|
ts.tv_sec = tv.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rc = taosThreadCondTimedWait(&pVnode->poolNotEmpty, &pVnode->mutex, &ts);
|
code = taosThreadCondTimedWait(&pVnode->poolNotEmpty, &pVnode->mutex, &ts);
|
||||||
if (rc && rc != ETIMEDOUT) {
|
if (code && code != TSDB_CODE_TIMEOUT_ERROR) {
|
||||||
code = TAOS_SYSTEM_ERROR(rc);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,11 +158,12 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
||||||
char *taosFqdnEnvItem = NULL;
|
char *taosFqdnEnvItem = NULL;
|
||||||
char *taosFqdn = getenv("TAOS_FQDN");
|
char *taosFqdn = getenv("TAOS_FQDN");
|
||||||
if (taosFqdn != NULL) {
|
if (taosFqdn != NULL) {
|
||||||
int len = strlen("TAOS_FQDN=") + strlen(taosFqdn) + 1;
|
int subLen = strlen(taosFqdn);
|
||||||
|
int len = strlen("TAOS_FQDN=") + subLen + 1;
|
||||||
taosFqdnEnvItem = taosMemoryMalloc(len);
|
taosFqdnEnvItem = taosMemoryMalloc(len);
|
||||||
if (taosFqdnEnvItem != NULL) {
|
if (taosFqdnEnvItem != NULL) {
|
||||||
tstrncpy(taosFqdnEnvItem, "TAOS_FQDN=", len);
|
tstrncpy(taosFqdnEnvItem, "TAOS_FQDN=", len);
|
||||||
TAOS_STRNCAT(taosFqdnEnvItem, taosFqdn, strlen(taosFqdn));
|
TAOS_STRNCAT(taosFqdnEnvItem, taosFqdn, subLen);
|
||||||
fnInfo("[UDFD]Succsess to set TAOS_FQDN:%s", taosFqdn);
|
fnInfo("[UDFD]Succsess to set TAOS_FQDN:%s", taosFqdn);
|
||||||
} else {
|
} else {
|
||||||
fnError("[UDFD]Failed to allocate memory for TAOS_FQDN");
|
fnError("[UDFD]Failed to allocate memory for TAOS_FQDN");
|
||||||
|
|
|
@ -377,20 +377,20 @@ int32_t tsem2_wait(tsem2_t* sem) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsem2_timewait(tsem2_t* sem, int64_t ms) {
|
int32_t tsem2_timewait(tsem2_t* sem, int64_t ms) {
|
||||||
int ret = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
ret = taosThreadMutexLock(&sem->mutex);
|
code = taosThreadMutexLock(&sem->mutex);
|
||||||
if (ret) {
|
if (code) {
|
||||||
return ret;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sem->count <= 0) {
|
if (sem->count <= 0) {
|
||||||
struct timespec ts = {0};
|
struct timespec ts = {0};
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) {
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) {
|
||||||
ret = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
(void)taosThreadMutexUnlock(&sem->mutex);
|
(void)taosThreadMutexUnlock(&sem->mutex);
|
||||||
terrno = ret;
|
terrno = code;
|
||||||
return ret;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
ts.tv_sec += ms / 1000;
|
ts.tv_sec += ms / 1000;
|
||||||
|
@ -399,22 +399,18 @@ int32_t tsem2_timewait(tsem2_t* sem, int64_t ms) {
|
||||||
ts.tv_nsec %= 1000000000;
|
ts.tv_nsec %= 1000000000;
|
||||||
|
|
||||||
while (sem->count <= 0) {
|
while (sem->count <= 0) {
|
||||||
ret = taosThreadCondTimedWait(&sem->cond, &sem->mutex, &ts);
|
code = taosThreadCondTimedWait(&sem->cond, &sem->mutex, &ts);
|
||||||
if (ret != 0) {
|
if (code != 0) {
|
||||||
(void)taosThreadMutexUnlock(&sem->mutex);
|
(void)taosThreadMutexUnlock(&sem->mutex);
|
||||||
if (errno == ETIMEDOUT) {
|
return code;
|
||||||
return TSDB_CODE_TIMEOUT_ERROR;
|
|
||||||
} else {
|
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sem->count--;
|
sem->count--;
|
||||||
|
|
||||||
ret = taosThreadMutexUnlock(&sem->mutex);
|
code = taosThreadMutexUnlock(&sem->mutex);
|
||||||
return ret;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -235,19 +235,22 @@ int32_t taosThreadCondWait(TdThreadCond *cond, TdThreadMutex *mutex) {
|
||||||
|
|
||||||
int32_t taosThreadCondTimedWait(TdThreadCond *cond, TdThreadMutex *mutex, const struct timespec *abstime) {
|
int32_t taosThreadCondTimedWait(TdThreadCond *cond, TdThreadMutex *mutex, const struct timespec *abstime) {
|
||||||
#ifdef __USE_WIN_THREAD
|
#ifdef __USE_WIN_THREAD
|
||||||
if (!abstime) return EINVAL;
|
if (!abstime) return 0;
|
||||||
if (SleepConditionVariableCS(cond, mutex, (DWORD)(abstime->tv_sec * 1e3 + abstime->tv_nsec / 1e6))) return 0;
|
if (SleepConditionVariableCS(cond, mutex, (DWORD)(abstime->tv_sec * 1e3 + abstime->tv_nsec / 1e6))) return 0;
|
||||||
if (GetLastError() == ERROR_TIMEOUT) {
|
DWORD error = GetLastError();
|
||||||
return ETIMEDOUT;
|
if (error == ERROR_TIMEOUT) {
|
||||||
|
return TSDB_CODE_TIMEOUT_ERROR;
|
||||||
}
|
}
|
||||||
return EINVAL;
|
return TAOS_SYSTEM_WINAPI_ERROR(error);
|
||||||
#else
|
#else
|
||||||
int32_t code = pthread_cond_timedwait(cond, mutex, abstime);
|
int32_t code = pthread_cond_timedwait(cond, mutex, abstime);
|
||||||
if (code && code != ETIMEDOUT) {
|
if(code == ETIMEDOUT) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(code);
|
return TSDB_CODE_TIMEOUT_ERROR;
|
||||||
return terrno;
|
} else if (code) {
|
||||||
|
return TAOS_SYSTEM_ERROR(code);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return code;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue