fix: ret error
This commit is contained in:
parent
2ed4aeb0da
commit
ef8367fbb4
|
@ -94,7 +94,7 @@ static int32_t generateConfigFile(char* confDir) {
|
|||
#endif
|
||||
);
|
||||
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);
|
||||
(void)taosCloseFile(&pFile);
|
||||
code = terrno;
|
||||
|
|
|
@ -102,9 +102,8 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
|
|||
ts.tv_sec = tv.tv_sec;
|
||||
}
|
||||
|
||||
int32_t rc = taosThreadCondTimedWait(&pVnode->poolNotEmpty, &pVnode->mutex, &ts);
|
||||
if (rc && rc != ETIMEDOUT) {
|
||||
code = TAOS_SYSTEM_ERROR(rc);
|
||||
code = taosThreadCondTimedWait(&pVnode->poolNotEmpty, &pVnode->mutex, &ts);
|
||||
if (code && code != TSDB_CODE_TIMEOUT_ERROR) {
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,11 +158,12 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
|||
char *taosFqdnEnvItem = NULL;
|
||||
char *taosFqdn = getenv("TAOS_FQDN");
|
||||
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);
|
||||
if (taosFqdnEnvItem != NULL) {
|
||||
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);
|
||||
} else {
|
||||
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) {
|
||||
int ret = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
ret = taosThreadMutexLock(&sem->mutex);
|
||||
if (ret) {
|
||||
return ret;
|
||||
code = taosThreadMutexLock(&sem->mutex);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
if (sem->count <= 0) {
|
||||
struct timespec ts = {0};
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) {
|
||||
ret = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
(void)taosThreadMutexUnlock(&sem->mutex);
|
||||
terrno = ret;
|
||||
return ret;
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
||||
ts.tv_sec += ms / 1000;
|
||||
|
@ -399,22 +399,18 @@ int32_t tsem2_timewait(tsem2_t* sem, int64_t ms) {
|
|||
ts.tv_nsec %= 1000000000;
|
||||
|
||||
while (sem->count <= 0) {
|
||||
ret = taosThreadCondTimedWait(&sem->cond, &sem->mutex, &ts);
|
||||
if (ret != 0) {
|
||||
code = taosThreadCondTimedWait(&sem->cond, &sem->mutex, &ts);
|
||||
if (code != 0) {
|
||||
(void)taosThreadMutexUnlock(&sem->mutex);
|
||||
if (errno == ETIMEDOUT) {
|
||||
return TSDB_CODE_TIMEOUT_ERROR;
|
||||
} else {
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sem->count--;
|
||||
|
||||
ret = taosThreadMutexUnlock(&sem->mutex);
|
||||
return ret;
|
||||
code = taosThreadMutexUnlock(&sem->mutex);
|
||||
return code;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -235,19 +235,22 @@ int32_t taosThreadCondWait(TdThreadCond *cond, TdThreadMutex *mutex) {
|
|||
|
||||
int32_t taosThreadCondTimedWait(TdThreadCond *cond, TdThreadMutex *mutex, const struct timespec *abstime) {
|
||||
#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 (GetLastError() == ERROR_TIMEOUT) {
|
||||
return ETIMEDOUT;
|
||||
DWORD error = GetLastError();
|
||||
if (error == ERROR_TIMEOUT) {
|
||||
return TSDB_CODE_TIMEOUT_ERROR;
|
||||
}
|
||||
return EINVAL;
|
||||
return TAOS_SYSTEM_WINAPI_ERROR(error);
|
||||
#else
|
||||
int32_t code = pthread_cond_timedwait(cond, mutex, abstime);
|
||||
if (code && code != ETIMEDOUT) {
|
||||
terrno = TAOS_SYSTEM_ERROR(code);
|
||||
return terrno;
|
||||
if(code == ETIMEDOUT) {
|
||||
return TSDB_CODE_TIMEOUT_ERROR;
|
||||
} else if (code) {
|
||||
return TAOS_SYSTEM_ERROR(code);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return code;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue