提交 829caf39 编写于 作者: B Bomin Zhang

td-1242: wait again if sem_wait returns EINTR

上级 a393cc75
......@@ -119,11 +119,8 @@ int32_t main(int32_t argc, char *argv[]) {
syslog(LOG_INFO, "Started TDengine service successfully.");
for (int res = tsem_wait(&exitSem); res != 0; res = tsem_wait(&exitSem)) {
if (errno != EINTR) {
syslog(LOG_ERR, "failed to wait exit semphore: %s", strerror(errno));
break;
}
if (tsem_wait(&exitSem) != 0) {
syslog(LOG_ERR, "failed to wait exit semphore: %s", strerror(errno));
}
dnodeCleanUpSystem();
......
......@@ -23,7 +23,7 @@ extern "C" {
#ifndef TAOS_OS_FUNC_SEMPHONE
#define tsem_t sem_t
#define tsem_init sem_init
#define tsem_wait sem_wait
int tsem_wait(tsem_t* sem);
#define tsem_post sem_post
#define tsem_destroy sem_destroy
#endif
......
......@@ -16,6 +16,18 @@
#define _DEFAULT_SOURCE
#include "os.h"
#ifndef TAOS_OS_FUNC_SEMPHONE
int tsem_wait(tsem_t* sem) {
int ret = 0;
do {
ret = sem_wait(sem);
} while (ret != 0 && errno == EINTR);
return ret;
}
#endif
#ifndef TAOS_OS_FUNC_SEMPHONE_PTHREAD
bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; }
......
......@@ -103,9 +103,7 @@ int main(int argc, char *argv[]) {
sInfo("TAOS arbitrator: %s:%d is running", tsNodeFqdn, tsArbitratorPort);
for (int res = tsem_wait(&tsArbSem); res != 0; res = tsem_wait(&tsArbSem)) {
if (errno != EINTR) break;
}
tsem_wait(&tsArbSem);
taosCloseTcpThreadPool(tsArbTcpPool);
sInfo("TAOS arbitrator is shut down\n");
......
......@@ -123,11 +123,6 @@ void *taosProcessSchedQueue(void *param) {
while (1) {
if (tsem_wait(&pSched->fullSem) != 0) {
if (errno == EINTR) {
/* sem_wait is interrupted by interrupt, ignore and continue */
uDebug("wait %s fullSem was interrupted", pSched->label);
continue;
}
uError("wait %s fullSem failed(%s)", pSched->label, strerror(errno));
}
if (pSched->stop) {
......@@ -163,12 +158,8 @@ int taosScheduleTask(void *qhandle, SSchedMsg *pMsg) {
return 0;
}
while (tsem_wait(&pSched->emptySem) != 0) {
if (errno != EINTR) {
uError("wait %s emptySem failed(%s)", pSched->label, strerror(errno));
break;
}
uDebug("wait %s emptySem was interrupted", pSched->label);
if (tsem_wait(&pSched->emptySem) != 0) {
uError("wait %s emptySem failed(%s)", pSched->label, strerror(errno));
}
if (pthread_mutex_lock(&pSched->queueMutex) != 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册