Merge pull request #19197 from taosdata/TD-21541
fix: change system error code and avoid mem leak
This commit is contained in:
commit
d731d36093
|
@ -268,6 +268,11 @@ int mainWindows(int argc, char **argv) {
|
||||||
|
|
||||||
if (dmInit() != 0) {
|
if (dmInit() != 0) {
|
||||||
dError("failed to init dnode since %s", terrstr());
|
dError("failed to init dnode since %s", terrstr());
|
||||||
|
|
||||||
|
taosCleanupCfg();
|
||||||
|
taosCloseLog();
|
||||||
|
taosCleanupArgs();
|
||||||
|
taosConvDestroy();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1001,6 +1001,13 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
||||||
uv_loop_init(srv->loop);
|
uv_loop_init(srv->loop);
|
||||||
|
|
||||||
char pipeName[PATH_MAX];
|
char pipeName[PATH_MAX];
|
||||||
|
|
||||||
|
if (false == taosValidIpAndPort(srv->ip, srv->port)) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
tError("invalid ip/port, %d:%d, reason:%s", srv->ip, srv->port, terrstr());
|
||||||
|
goto End;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(WINDOWS) || defined(DARWIN)
|
#if defined(WINDOWS) || defined(DARWIN)
|
||||||
int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0);
|
int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
@ -1087,12 +1094,6 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (false == taosValidIpAndPort(srv->ip, srv->port)) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
tError("invalid ip/port, %d:%d, reason:%s", srv->ip, srv->port, terrstr());
|
|
||||||
goto End;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false == addHandleToAcceptloop(srv)) {
|
if (false == addHandleToAcceptloop(srv)) {
|
||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
|
@ -1185,8 +1186,8 @@ void transCloseServer(void* arg) {
|
||||||
// impl later
|
// impl later
|
||||||
SServerObj* srv = arg;
|
SServerObj* srv = arg;
|
||||||
|
|
||||||
tDebug("send quit msg to accept thread");
|
|
||||||
if (srv->inited) {
|
if (srv->inited) {
|
||||||
|
tDebug("send quit msg to accept thread");
|
||||||
uv_async_send(srv->pAcceptAsync);
|
uv_async_send(srv->pAcceptAsync);
|
||||||
taosThreadJoin(srv->thread, NULL);
|
taosThreadJoin(srv->thread, NULL);
|
||||||
SRV_RELEASE_UV(srv->loop);
|
SRV_RELEASE_UV(srv->loop);
|
||||||
|
|
|
@ -643,13 +643,10 @@ const char* tstrerror(int32_t err) {
|
||||||
// this is a system errno
|
// this is a system errno
|
||||||
if ((err & 0x00ff0000) == 0x00ff0000) {
|
if ((err & 0x00ff0000) == 0x00ff0000) {
|
||||||
int32_t code = err & 0x0000ffff;
|
int32_t code = err & 0x0000ffff;
|
||||||
if (code >= 0 && code < 36) {
|
// strerror can handle any invalid code
|
||||||
return strerror(code);
|
// invalid code return Unknown error
|
||||||
} else {
|
return strerror(code);
|
||||||
return "unknown err";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t s = 0;
|
int32_t s = 0;
|
||||||
int32_t e = sizeof(errors) / sizeof(errors[0]);
|
int32_t e = sizeof(errors) / sizeof(errors[0]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue