提交 ef8135a6 编写于 作者: S Shengliang Guan

TD-1057

上级 ed896f97
...@@ -295,6 +295,7 @@ bool taosCfgDynamicOptions(char *msg) { ...@@ -295,6 +295,7 @@ bool taosCfgDynamicOptions(char *msg) {
} }
static void doInitGlobalConfig(void) { static void doInitGlobalConfig(void) {
osInit();
SGlobalCfg cfg = {0}; SGlobalCfg cfg = {0};
// ip address // ip address
......
...@@ -33,7 +33,11 @@ extern "C" { ...@@ -33,7 +33,11 @@ extern "C" {
} \ } \
} }
typedef int SOCKET; typedef int SOCKET;
#endif #endif
#ifndef TAOS_OS_DEF_EPOLL
#define TAOS_EPOLL_WAIT_TIME -1
#endif
#define taosClose(x) taosCloseSocket(x) #define taosClose(x) taosCloseSocket(x)
......
...@@ -94,6 +94,9 @@ extern "C" { ...@@ -94,6 +94,9 @@ extern "C" {
typedef SOCKET eventfd_t; typedef SOCKET eventfd_t;
#define eventfd(a, b) -1 #define eventfd(a, b) -1
#define TAOS_OS_DEF_EPOLL
#define TAOS_EPOLL_WAIT_TIME 100
#define TAOS_OS_FUNC_STRING_WCHAR #define TAOS_OS_FUNC_STRING_WCHAR
int twcslen(const wchar_t *wcs); int twcslen(const wchar_t *wcs);
#define TAOS_OS_FUNC_STRING_GETLINE #define TAOS_OS_FUNC_STRING_GETLINE
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "tglobal.h" #include "tglobal.h"
#include "tulog.h" #include "tulog.h"
extern void taosWinSocketInit();
void osInit() { void osInit() {
strcpy(configDir, "C:/TDengine/cfg"); strcpy(configDir, "C:/TDengine/cfg");
strcpy(tsVnodeDir, "C:/TDengine/data"); strcpy(tsVnodeDir, "C:/TDengine/data");
...@@ -27,4 +29,5 @@ void osInit() { ...@@ -27,4 +29,5 @@ void osInit() {
strcpy(tsLogDir, "C:/TDengine/log"); strcpy(tsLogDir, "C:/TDengine/log");
strcpy(tsScriptDir, "C:/TDengine/script"); strcpy(tsScriptDir, "C:/TDengine/script");
strcpy(tsOsName, "Windows"); strcpy(tsOsName, "Windows");
taosWinSocketInit();
} }
\ No newline at end of file
...@@ -38,6 +38,7 @@ static void httpStopThread(HttpThread* pThread) { ...@@ -38,6 +38,7 @@ static void httpStopThread(HttpThread* pThread) {
eventfd_t fd = eventfd(1, 0); eventfd_t fd = eventfd(1, 0);
if (fd == -1) { if (fd == -1) {
httpError("%s, failed to create eventfd, will call pthread_cancel instead, which may result in data corruption: %s", pThread->label, strerror(errno)); httpError("%s, failed to create eventfd, will call pthread_cancel instead, which may result in data corruption: %s", pThread->label, strerror(errno));
pThread->stop = true;
pthread_cancel(pThread->thread); pthread_cancel(pThread->thread);
} else if (epoll_ctl(pThread->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) { } else if (epoll_ctl(pThread->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) {
httpError("%s, failed to call epoll_ctl, will call pthread_cancel instead, which may result in data corruption: %s", pThread->label, strerror(errno)); httpError("%s, failed to call epoll_ctl, will call pthread_cancel instead, which may result in data corruption: %s", pThread->label, strerror(errno));
......
...@@ -174,6 +174,7 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) { ...@@ -174,6 +174,7 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) {
if (fd == -1) { if (fd == -1) {
// failed to create eventfd, call pthread_cancel instead, which may result in data corruption: // failed to create eventfd, call pthread_cancel instead, which may result in data corruption:
tError("%s, failed to create eventfd(%s)", pThreadObj->label, strerror(errno)); tError("%s, failed to create eventfd(%s)", pThreadObj->label, strerror(errno));
pThreadObj->stop = true;
pthread_cancel(pThreadObj->thread); pthread_cancel(pThreadObj->thread);
} else if (epoll_ctl(pThreadObj->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) { } else if (epoll_ctl(pThreadObj->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) {
// failed to call epoll_ctl, call pthread_cancel instead, which may result in data corruption: // failed to call epoll_ctl, call pthread_cancel instead, which may result in data corruption:
...@@ -464,7 +465,7 @@ static void *taosProcessTcpData(void *param) { ...@@ -464,7 +465,7 @@ static void *taosProcessTcpData(void *param) {
SRecvInfo recvInfo; SRecvInfo recvInfo;
while (1) { while (1) {
int fdNum = epoll_wait(pThreadObj->pollFd, events, maxEvents, -1); int fdNum = epoll_wait(pThreadObj->pollFd, events, maxEvents, TAOS_EPOLL_WAIT_TIME);
if (pThreadObj->stop) { if (pThreadObj->stop) {
tDebug("%s TCP thread get stop event, exiting...", pThreadObj->label); tDebug("%s TCP thread get stop event, exiting...", pThreadObj->label);
break; break;
......
...@@ -184,7 +184,7 @@ static void *taosProcessTcpData(void *param) { ...@@ -184,7 +184,7 @@ static void *taosProcessTcpData(void *param) {
while (1) { while (1) {
if (pThread->stop) break; if (pThread->stop) break;
int fdNum = epoll_wait(pThread->pollFd, events, maxEvents, -1); int fdNum = epoll_wait(pThread->pollFd, events, maxEvents, TAOS_EPOLL_WAIT_TIME);
if (pThread->stop) { if (pThread->stop) {
uDebug("%p TCP epoll thread is exiting...", pThread); uDebug("%p TCP epoll thread is exiting...", pThread);
break; break;
...@@ -313,6 +313,7 @@ static void taosStopPoolThread(SThreadObj* pThread) { ...@@ -313,6 +313,7 @@ static void taosStopPoolThread(SThreadObj* pThread) {
// failed to create eventfd, call pthread_cancel instead, which may result in data corruption // failed to create eventfd, call pthread_cancel instead, which may result in data corruption
uError("failed to create eventfd(%s)", strerror(errno)); uError("failed to create eventfd(%s)", strerror(errno));
pthread_cancel(pThread->thread); pthread_cancel(pThread->thread);
pThread->stop = true;
} else if (epoll_ctl(pThread->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) { } else if (epoll_ctl(pThread->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) {
// failed to call epoll_ctl, call pthread_cancel instead, which may result in data corruption // failed to call epoll_ctl, call pthread_cancel instead, which may result in data corruption
uError("failed to call epoll_ctl(%s)", strerror(errno)); uError("failed to call epoll_ctl(%s)", strerror(errno));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册