Merge pull request #3251 from taosdata/bugfix/td-1242
wait again when sem_wait returns EINTR
This commit is contained in:
commit
0a27418f74
|
@ -119,11 +119,8 @@ int32_t main(int32_t argc, char *argv[]) {
|
||||||
|
|
||||||
syslog(LOG_INFO, "Started TDengine service successfully.");
|
syslog(LOG_INFO, "Started TDengine service successfully.");
|
||||||
|
|
||||||
for (int res = tsem_wait(&exitSem); res != 0; res = tsem_wait(&exitSem)) {
|
if (tsem_wait(&exitSem) != 0) {
|
||||||
if (res != EINTR) {
|
syslog(LOG_ERR, "failed to wait exit semphore: %s", strerror(errno));
|
||||||
syslog(LOG_ERR, "failed to wait exit semphore: %d", res);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dnodeCleanUpSystem();
|
dnodeCleanUpSystem();
|
||||||
|
|
|
@ -23,7 +23,7 @@ extern "C" {
|
||||||
#ifndef TAOS_OS_FUNC_SEMPHONE
|
#ifndef TAOS_OS_FUNC_SEMPHONE
|
||||||
#define tsem_t sem_t
|
#define tsem_t sem_t
|
||||||
#define tsem_init sem_init
|
#define tsem_init sem_init
|
||||||
#define tsem_wait sem_wait
|
int tsem_wait(tsem_t* sem);
|
||||||
#define tsem_post sem_post
|
#define tsem_post sem_post
|
||||||
#define tsem_destroy sem_destroy
|
#define tsem_destroy sem_destroy
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,6 +16,18 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#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
|
#ifndef TAOS_OS_FUNC_SEMPHONE_PTHREAD
|
||||||
|
|
||||||
bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; }
|
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);
|
sInfo("TAOS arbitrator: %s:%d is running", tsNodeFqdn, tsArbitratorPort);
|
||||||
|
|
||||||
for (int res = tsem_wait(&tsArbSem); res != 0; res = tsem_wait(&tsArbSem)) {
|
tsem_wait(&tsArbSem);
|
||||||
if (res != EINTR) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosCloseTcpThreadPool(tsArbTcpPool);
|
taosCloseTcpThreadPool(tsArbTcpPool);
|
||||||
sInfo("TAOS arbitrator is shut down\n");
|
sInfo("TAOS arbitrator is shut down\n");
|
||||||
|
|
|
@ -123,11 +123,6 @@ void *taosProcessSchedQueue(void *param) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (tsem_wait(&pSched->fullSem) != 0) {
|
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));
|
uError("wait %s fullSem failed(%s)", pSched->label, strerror(errno));
|
||||||
}
|
}
|
||||||
if (pSched->stop) {
|
if (pSched->stop) {
|
||||||
|
@ -163,12 +158,8 @@ int taosScheduleTask(void *qhandle, SSchedMsg *pMsg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tsem_wait(&pSched->emptySem) != 0) {
|
if (tsem_wait(&pSched->emptySem) != 0) {
|
||||||
if (errno != EINTR) {
|
uError("wait %s emptySem failed(%s)", pSched->label, strerror(errno));
|
||||||
uError("wait %s emptySem failed(%s)", pSched->label, strerror(errno));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
uDebug("wait %s emptySem was interrupted", pSched->label);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_mutex_lock(&pSched->queueMutex) != 0)
|
if (pthread_mutex_lock(&pSched->queueMutex) != 0)
|
||||||
|
|
Loading…
Reference in New Issue