Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7330b0f8
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7330b0f8
编写于
11月 27, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove printf
上级
8bf34d89
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
134 addition
and
115 deletion
+134
-115
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+20
-1
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+1
-1
source/os/src/osDir.c
source/os/src/osDir.c
+5
-5
source/os/src/osFile.c
source/os/src/osFile.c
+2
-2
source/os/src/osSocket.c
source/os/src/osSocket.c
+48
-48
source/os/src/osString.c
source/os/src/osString.c
+1
-1
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+45
-45
source/os/src/osSystem.c
source/os/src/osSystem.c
+5
-5
source/os/src/osTimer.c
source/os/src/osTimer.c
+7
-7
未找到文件。
source/dnode/mgmt/impl/src/dndMnode.c
浏览文件 @
7330b0f8
...
@@ -198,7 +198,7 @@ static int32_t dndWriteMnodeFile(SDnode *pDnode) {
...
@@ -198,7 +198,7 @@ static int32_t dndWriteMnodeFile(SDnode *pDnode) {
snprintf
(
file
,
sizeof
(
file
),
"%s.bak"
,
pMgmt
->
file
);
snprintf
(
file
,
sizeof
(
file
),
"%s.bak"
,
pMgmt
->
file
);
FILE
*
fp
=
fopen
(
file
,
"w"
);
FILE
*
fp
=
fopen
(
file
,
"w"
);
if
(
fp
!
=
NULL
)
{
if
(
fp
=
=
NULL
)
{
terrno
=
TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR
;
terrno
=
TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR
;
dError
(
"failed to write %s since %s"
,
file
,
terrstr
());
dError
(
"failed to write %s since %s"
,
file
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -242,6 +242,21 @@ static int32_t dndWriteMnodeFile(SDnode *pDnode) {
...
@@ -242,6 +242,21 @@ static int32_t dndWriteMnodeFile(SDnode *pDnode) {
}
}
static
int32_t
dndStartMnodeWorker
(
SDnode
*
pDnode
)
{
static
int32_t
dndStartMnodeWorker
(
SDnode
*
pDnode
)
{
if
(
dndInitMnodeReadWorker
(
pDnode
)
!=
0
)
{
dError
(
"failed to start mnode read worker since %s"
,
terrstr
());
return
-
1
;
}
if
(
dndInitMnodeWriteWorker
(
pDnode
)
!=
0
)
{
dError
(
"failed to start mnode write worker since %s"
,
terrstr
());
return
-
1
;
}
if
(
dndInitMnodeSyncWorker
(
pDnode
)
!=
0
)
{
dError
(
"failed to start mnode sync worker since %s"
,
terrstr
());
return
-
1
;
}
if
(
dndAllocMnodeReadQueue
(
pDnode
)
!=
0
)
{
if
(
dndAllocMnodeReadQueue
(
pDnode
)
!=
0
)
{
dError
(
"failed to alloc mnode read queue since %s"
,
terrstr
());
dError
(
"failed to alloc mnode read queue since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -708,6 +723,7 @@ static int32_t dndAllocMnodeReadQueue(SDnode *pDnode) {
...
@@ -708,6 +723,7 @@ static int32_t dndAllocMnodeReadQueue(SDnode *pDnode) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
...
@@ -743,6 +759,7 @@ static int32_t dndAllocMnodeWriteQueue(SDnode *pDnode) {
...
@@ -743,6 +759,7 @@ static int32_t dndAllocMnodeWriteQueue(SDnode *pDnode) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
...
@@ -759,6 +776,7 @@ static int32_t dndAllocMnodeApplyQueue(SDnode *pDnode) {
...
@@ -759,6 +776,7 @@ static int32_t dndAllocMnodeApplyQueue(SDnode *pDnode) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
...
@@ -794,6 +812,7 @@ static int32_t dndAllocMnodeSyncQueue(SDnode *pDnode) {
...
@@ -794,6 +812,7 @@ static int32_t dndAllocMnodeSyncQueue(SDnode *pDnode) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
7330b0f8
...
@@ -31,9 +31,9 @@
...
@@ -31,9 +31,9 @@
#include "mnodeStable.h"
#include "mnodeStable.h"
#include "mnodeSync.h"
#include "mnodeSync.h"
#include "mnodeTelem.h"
#include "mnodeTelem.h"
#include "mnodeTrans.h"
#include "mnodeUser.h"
#include "mnodeUser.h"
#include "mnodeVgroup.h"
#include "mnodeVgroup.h"
#include "mnodeTrans.h"
SMnodeBak
tsMint
=
{
0
};
SMnodeBak
tsMint
=
{
0
};
...
...
source/os/src/osDir.c
浏览文件 @
7330b0f8
...
@@ -48,14 +48,14 @@ void taosRemoveDir(const char *dirname) {
...
@@ -48,14 +48,14 @@ void taosRemoveDir(const char *dirname) {
taosRemoveDir
(
filename
);
taosRemoveDir
(
filename
);
}
else
{
}
else
{
(
void
)
remove
(
filename
);
(
void
)
remove
(
filename
);
printf
(
"file:%s is removed
\n
"
,
filename
);
//
printf("file:%s is removed\n", filename);
}
}
}
}
closedir
(
dir
);
closedir
(
dir
);
rmdir
(
dirname
);
rmdir
(
dirname
);
printf
(
"dir:%s is removed
\n
"
,
dirname
);
//
printf("dir:%s is removed\n", dirname);
}
}
int32_t
taosDirExist
(
char
*
dirname
)
{
return
access
(
dirname
,
F_OK
);
}
int32_t
taosDirExist
(
char
*
dirname
)
{
return
access
(
dirname
,
F_OK
);
}
...
@@ -101,9 +101,9 @@ void taosRemoveOldFiles(char *dirname, int32_t keepDays) {
...
@@ -101,9 +101,9 @@ void taosRemoveOldFiles(char *dirname, int32_t keepDays) {
int32_t
days
=
(
int32_t
)(
ABS
(
sec
-
fileSec
)
/
86400
+
1
);
int32_t
days
=
(
int32_t
)(
ABS
(
sec
-
fileSec
)
/
86400
+
1
);
if
(
days
>
keepDays
)
{
if
(
days
>
keepDays
)
{
(
void
)
remove
(
filename
);
(
void
)
remove
(
filename
);
printf
(
"file:%s is removed, days:%d keepDays:%d"
,
filename
,
days
,
keepDays
);
//
printf("file:%s is removed, days:%d keepDays:%d", filename, days, keepDays);
}
else
{
}
else
{
printf
(
"file:%s won't be removed, days:%d keepDays:%d"
,
filename
,
days
,
keepDays
);
//
printf("file:%s won't be removed, days:%d keepDays:%d", filename, days, keepDays);
}
}
}
}
}
}
...
@@ -115,7 +115,7 @@ void taosRemoveOldFiles(char *dirname, int32_t keepDays) {
...
@@ -115,7 +115,7 @@ void taosRemoveOldFiles(char *dirname, int32_t keepDays) {
int32_t
taosExpandDir
(
char
*
dirname
,
char
*
outname
,
int32_t
maxlen
)
{
int32_t
taosExpandDir
(
char
*
dirname
,
char
*
outname
,
int32_t
maxlen
)
{
wordexp_t
full_path
;
wordexp_t
full_path
;
if
(
0
!=
wordexp
(
dirname
,
&
full_path
,
0
))
{
if
(
0
!=
wordexp
(
dirname
,
&
full_path
,
0
))
{
printf
(
"failed to expand path:%s since %s"
,
dirname
,
strerror
(
errno
));
//
printf("failed to expand path:%s since %s", dirname, strerror(errno));
wordfree
(
&
full_path
);
wordfree
(
&
full_path
);
return
-
1
;
return
-
1
;
}
}
...
...
source/os/src/osFile.c
浏览文件 @
7330b0f8
...
@@ -404,14 +404,14 @@ int32_t taosRenameFile(char *oldName, char *newName) {
...
@@ -404,14 +404,14 @@ int32_t taosRenameFile(char *oldName, char *newName) {
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
int32_t
code
=
MoveFileEx
(
oldName
,
newName
,
MOVEFILE_REPLACE_EXISTING
|
MOVEFILE_COPY_ALLOWED
);
int32_t
code
=
MoveFileEx
(
oldName
,
newName
,
MOVEFILE_REPLACE_EXISTING
|
MOVEFILE_COPY_ALLOWED
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
printf
(
"failed to rename file %s to %s, reason:%s"
,
oldName
,
newName
,
strerror
(
errno
));
//
printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
}
}
return
code
;
return
code
;
#else
#else
int32_t
code
=
rename
(
oldName
,
newName
);
int32_t
code
=
rename
(
oldName
,
newName
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
printf
(
"failed to rename file %s to %s, reason:%s"
,
oldName
,
newName
,
strerror
(
errno
));
//
printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
}
}
return
code
;
return
code
;
...
...
source/os/src/osSocket.c
浏览文件 @
7330b0f8
...
@@ -95,7 +95,7 @@ void taosShutDownSocketWR(SOCKET fd) {
...
@@ -95,7 +95,7 @@ void taosShutDownSocketWR(SOCKET fd) {
int32_t
taosSetNonblocking
(
SOCKET
sock
,
int32_t
on
)
{
int32_t
taosSetNonblocking
(
SOCKET
sock
,
int32_t
on
)
{
int32_t
flags
=
0
;
int32_t
flags
=
0
;
if
((
flags
=
fcntl
(
sock
,
F_GETFL
,
0
))
<
0
)
{
if
((
flags
=
fcntl
(
sock
,
F_GETFL
,
0
))
<
0
)
{
printf
(
"fcntl(F_GETFL) error: %d (%s)
\n
"
,
errno
,
strerror
(
errno
));
//
printf("fcntl(F_GETFL) error: %d (%s)\n", errno, strerror(errno));
return
1
;
return
1
;
}
}
...
@@ -105,7 +105,7 @@ int32_t taosSetNonblocking(SOCKET sock, int32_t on) {
...
@@ -105,7 +105,7 @@ int32_t taosSetNonblocking(SOCKET sock, int32_t on) {
flags
&=
~
O_NONBLOCK
;
flags
&=
~
O_NONBLOCK
;
if
((
flags
=
fcntl
(
sock
,
F_SETFL
,
flags
))
<
0
)
{
if
((
flags
=
fcntl
(
sock
,
F_SETFL
,
flags
))
<
0
)
{
printf
(
"fcntl(F_SETFL) error: %d (%s)
\n
"
,
errno
,
strerror
(
errno
));
//
printf("fcntl(F_SETFL) error: %d (%s)\n", errno, strerror(errno));
return
1
;
return
1
;
}
}
...
@@ -120,7 +120,7 @@ void taosBlockSIGPIPE() {
...
@@ -120,7 +120,7 @@ void taosBlockSIGPIPE() {
sigaddset
(
&
signal_mask
,
SIGPIPE
);
sigaddset
(
&
signal_mask
,
SIGPIPE
);
int32_t
rc
=
pthread_sigmask
(
SIG_BLOCK
,
&
signal_mask
,
NULL
);
int32_t
rc
=
pthread_sigmask
(
SIG_BLOCK
,
&
signal_mask
,
NULL
);
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
printf
(
"failed to block SIGPIPE"
);
//
printf("failed to block SIGPIPE");
}
}
}
}
...
@@ -130,7 +130,7 @@ void taosSetMaskSIGPIPE() {
...
@@ -130,7 +130,7 @@ void taosSetMaskSIGPIPE() {
sigaddset
(
&
signal_mask
,
SIGPIPE
);
sigaddset
(
&
signal_mask
,
SIGPIPE
);
int32_t
rc
=
pthread_sigmask
(
SIG_SETMASK
,
&
signal_mask
,
NULL
);
int32_t
rc
=
pthread_sigmask
(
SIG_SETMASK
,
&
signal_mask
,
NULL
);
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
printf
(
"failed to setmask SIGPIPE"
);
//
printf("failed to setmask SIGPIPE");
}
}
}
}
...
@@ -277,7 +277,7 @@ int32_t taosGetFqdn(char *fqdn) {
...
@@ -277,7 +277,7 @@ int32_t taosGetFqdn(char *fqdn) {
char
hostname
[
1024
];
char
hostname
[
1024
];
hostname
[
1023
]
=
'\0'
;
hostname
[
1023
]
=
'\0'
;
if
(
gethostname
(
hostname
,
1023
)
==
-
1
)
{
if
(
gethostname
(
hostname
,
1023
)
==
-
1
)
{
printf
(
"failed to get hostname, reason:%s"
,
strerror
(
errno
));
//
printf("failed to get hostname, reason:%s", strerror(errno));
return
-
1
;
return
-
1
;
}
}
...
@@ -294,7 +294,7 @@ int32_t taosGetFqdn(char *fqdn) {
...
@@ -294,7 +294,7 @@ int32_t taosGetFqdn(char *fqdn) {
#endif // __APPLE__
#endif // __APPLE__
int32_t
ret
=
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
result
);
int32_t
ret
=
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
result
);
if
(
!
result
)
{
if
(
!
result
)
{
printf
(
"failed to get fqdn, code:%d, reason:%s"
,
ret
,
gai_strerror
(
ret
));
//
printf("failed to get fqdn, code:%d, reason:%s", ret, gai_strerror(ret));
return
-
1
;
return
-
1
;
}
}
...
@@ -326,12 +326,12 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) {
...
@@ -326,12 +326,12 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) {
}
else
{
}
else
{
#ifdef EAI_SYSTEM
#ifdef EAI_SYSTEM
if
(
ret
==
EAI_SYSTEM
)
{
if
(
ret
==
EAI_SYSTEM
)
{
printf
(
"failed to get the ip address, fqdn:%s, since:%s"
,
fqdn
,
strerror
(
errno
));
//
printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, strerror(errno));
}
else
{
}
else
{
printf
(
"failed to get the ip address, fqdn:%s, since:%s"
,
fqdn
,
gai_strerror
(
ret
));
//
printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret));
}
}
#else
#else
printf
(
"failed to get the ip address, fqdn:%s, since:%s"
,
fqdn
,
gai_strerror
(
ret
));
//
printf("failed to get the ip address, fqdn:%s, since:%s", fqdn, gai_strerror(ret));
#endif
#endif
return
0xFFFFFFFF
;
return
0xFFFFFFFF
;
}
}
...
@@ -437,13 +437,13 @@ int32_t taosNonblockwrite(SOCKET fd, char *ptr, int32_t nbytes) {
...
@@ -437,13 +437,13 @@ int32_t taosNonblockwrite(SOCKET fd, char *ptr, int32_t nbytes) {
FD_SET
(
fd
,
&
fset
);
FD_SET
(
fd
,
&
fset
);
if
((
nready
=
select
((
int32_t
)(
fd
+
1
),
NULL
,
&
fset
,
NULL
,
&
tv
))
==
0
)
{
if
((
nready
=
select
((
int32_t
)(
fd
+
1
),
NULL
,
&
fset
,
NULL
,
&
tv
))
==
0
)
{
errno
=
ETIMEDOUT
;
errno
=
ETIMEDOUT
;
printf
(
"fd %d timeout, no enough space to write"
,
fd
);
//
printf("fd %d timeout, no enough space to write", fd);
break
;
break
;
}
else
if
(
nready
<
0
)
{
}
else
if
(
nready
<
0
)
{
if
(
errno
==
EINTR
)
continue
;
if
(
errno
==
EINTR
)
continue
;
printf
(
"select error, %d (%s)"
,
errno
,
strerror
(
errno
));
//
printf("select error, %d (%s)", errno, strerror(errno));
return
-
1
;
return
-
1
;
}
}
...
@@ -451,7 +451,7 @@ int32_t taosNonblockwrite(SOCKET fd, char *ptr, int32_t nbytes) {
...
@@ -451,7 +451,7 @@ int32_t taosNonblockwrite(SOCKET fd, char *ptr, int32_t nbytes) {
if
(
nwritten
<=
0
)
{
if
(
nwritten
<=
0
)
{
if
(
errno
==
EAGAIN
||
errno
==
EINTR
)
continue
;
if
(
errno
==
EAGAIN
||
errno
==
EINTR
)
continue
;
printf
(
"write error, %d (%s)"
,
errno
,
strerror
(
errno
));
//
printf("write error, %d (%s)", errno, strerror(errno));
return
-
1
;
return
-
1
;
}
}
...
@@ -477,21 +477,21 @@ int32_t taosReadn(SOCKET fd, char *ptr, int32_t nbytes) {
...
@@ -477,21 +477,21 @@ int32_t taosReadn(SOCKET fd, char *ptr, int32_t nbytes) {
FD_SET
(
fd
,
&
fset
);
FD_SET
(
fd
,
&
fset
);
if
((
nready
=
select
((
int32_t
)(
fd
+
1
),
NULL
,
&
fset
,
NULL
,
&
tv
))
==
0
)
{
if
((
nready
=
select
((
int32_t
)(
fd
+
1
),
NULL
,
&
fset
,
NULL
,
&
tv
))
==
0
)
{
errno
=
ETIMEDOUT
;
errno
=
ETIMEDOUT
;
printf
(
"fd %d timeout
\n
"
,
fd
);
//
printf("fd %d timeout\n", fd);
break
;
break
;
}
else
if
(
nready
<
0
)
{
}
else
if
(
nready
<
0
)
{
if
(
errno
==
EINTR
)
continue
;
if
(
errno
==
EINTR
)
continue
;
printf
(
"select error, %d (%s)"
,
errno
,
strerror
(
errno
));
//
printf("select error, %d (%s)", errno, strerror(errno));
return
-
1
;
return
-
1
;
}
}
if
((
nread
=
(
int32_t
)
taosReadSocket
(
fd
,
ptr
,
(
size_t
)
nleft
))
<
0
)
{
if
((
nread
=
(
int32_t
)
taosReadSocket
(
fd
,
ptr
,
(
size_t
)
nleft
))
<
0
)
{
if
(
errno
==
EINTR
)
continue
;
if
(
errno
==
EINTR
)
continue
;
printf
(
"read error, %d (%s)"
,
errno
,
strerror
(
errno
));
//
printf("read error, %d (%s)", errno, strerror(errno));
return
-
1
;
return
-
1
;
}
else
if
(
nread
==
0
)
{
}
else
if
(
nread
==
0
)
{
printf
(
"fd %d EOF"
,
fd
);
//
printf("fd %d EOF", fd);
break
;
// EOF
break
;
// EOF
}
}
...
@@ -507,7 +507,7 @@ SOCKET taosOpenUdpSocket(uint32_t ip, uint16_t port) {
...
@@ -507,7 +507,7 @@ SOCKET taosOpenUdpSocket(uint32_t ip, uint16_t port) {
SOCKET
sockFd
;
SOCKET
sockFd
;
int32_t
bufSize
=
1024000
;
int32_t
bufSize
=
1024000
;
printf
(
"open udp socket:0x%x:%hu"
,
ip
,
port
);
//
printf("open udp socket:0x%x:%hu", ip, port);
memset
((
char
*
)
&
localAddr
,
0
,
sizeof
(
localAddr
));
memset
((
char
*
)
&
localAddr
,
0
,
sizeof
(
localAddr
));
localAddr
.
sin_family
=
AF_INET
;
localAddr
.
sin_family
=
AF_INET
;
...
@@ -515,26 +515,26 @@ SOCKET taosOpenUdpSocket(uint32_t ip, uint16_t port) {
...
@@ -515,26 +515,26 @@ SOCKET taosOpenUdpSocket(uint32_t ip, uint16_t port) {
localAddr
.
sin_port
=
(
uint16_t
)
htons
(
port
);
localAddr
.
sin_port
=
(
uint16_t
)
htons
(
port
);
if
((
sockFd
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
))
<=
2
)
{
if
((
sockFd
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
))
<=
2
)
{
printf
(
"failed to open udp socket: %d (%s)"
,
errno
,
strerror
(
errno
));
//
printf("failed to open udp socket: %d (%s)", errno, strerror(errno));
taosCloseSocketNoCheck
(
sockFd
);
taosCloseSocketNoCheck
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
printf
(
"failed to set the send buffer size for UDP socket
\n
"
);
//
printf("failed to set the send buffer size for UDP socket\n");
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
printf
(
"failed to set the receive buffer size for UDP socket
\n
"
);
//
printf("failed to set the receive buffer size for UDP socket\n");
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
/* bind socket to local address */
/* bind socket to local address */
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
localAddr
,
sizeof
(
localAddr
))
<
0
)
{
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
localAddr
,
sizeof
(
localAddr
))
<
0
)
{
printf
(
"failed to bind udp socket: %d (%s), 0x%x:%hu"
,
errno
,
strerror
(
errno
),
ip
,
port
);
//
printf("failed to bind udp socket: %d (%s), 0x%x:%hu", errno, strerror(errno), ip, port);
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -551,7 +551,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
...
@@ -551,7 +551,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
sockFd
=
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
sockFd
=
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
sockFd
<=
2
)
{
if
(
sockFd
<=
2
)
{
printf
(
"failed to open the socket: %d (%s)"
,
errno
,
strerror
(
errno
));
//
printf("failed to open the socket: %d (%s)", errno, strerror(errno));
taosCloseSocketNoCheck
(
sockFd
);
taosCloseSocketNoCheck
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -559,19 +559,19 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
...
@@ -559,19 +559,19 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
/* set REUSEADDR option, so the portnumber can be re-used */
/* set REUSEADDR option, so the portnumber can be re-used */
int32_t
reuse
=
1
;
int32_t
reuse
=
1
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
printf
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
//
printf("setsockopt SO_REUSEADDR failed: %d (%s)", errno, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
printf
(
"failed to set the send buffer size for TCP socket
\n
"
);
//
printf("failed to set the send buffer size for TCP socket\n");
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
bufSize
,
sizeof
(
bufSize
))
!=
0
)
{
printf
(
"failed to set the receive buffer size for TCP socket
\n
"
);
//
printf("failed to set the receive buffer size for TCP socket\n");
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -584,8 +584,8 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
...
@@ -584,8 +584,8 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
/* bind socket to client address */
/* bind socket to client address */
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
clientAddr
,
sizeof
(
clientAddr
))
<
0
)
{
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
clientAddr
,
sizeof
(
clientAddr
))
<
0
)
{
printf
(
"bind tcp client socket failed, client(0x%x:0), dest(0x%x:%d), reason:(%s)"
,
clientIp
,
destIp
,
destPort
,
//
printf("bind tcp client socket failed, client(0x%x:0), dest(0x%x:%d), reason:(%s)", clientIp, destIp, destPort,
strerror
(
errno
));
//
strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -601,7 +601,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
...
@@ -601,7 +601,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
ret
=
connect
(
sockFd
,
(
struct
sockaddr
*
)
&
serverAddr
,
sizeof
(
serverAddr
));
ret
=
connect
(
sockFd
,
(
struct
sockaddr
*
)
&
serverAddr
,
sizeof
(
serverAddr
));
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
if
(
errno
==
EHOSTUNREACH
)
{
if
(
errno
==
EHOSTUNREACH
)
{
printf
(
"failed to connect socket, ip:0x%x, port:%hu(%s)"
,
destIp
,
destPort
,
strerror
(
errno
));
//
printf("failed to connect socket, ip:0x%x, port:%hu(%s)", destIp, destPort, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
else
if
(
errno
==
EINPROGRESS
||
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
}
else
if
(
errno
==
EINPROGRESS
||
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
...
@@ -612,19 +612,19 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
...
@@ -612,19 +612,19 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
int
res
=
poll
(
wfd
,
1
,
TCP_CONN_TIMEOUT
);
int
res
=
poll
(
wfd
,
1
,
TCP_CONN_TIMEOUT
);
if
(
res
==
-
1
||
res
==
0
)
{
if
(
res
==
-
1
||
res
==
0
)
{
printf
(
"failed to connect socket, ip:0x%x, port:%hu(poll error/conn timeout)"
,
destIp
,
destPort
);
//
printf("failed to connect socket, ip:0x%x, port:%hu(poll error/conn timeout)", destIp, destPort);
taosCloseSocket
(
sockFd
);
//
taosCloseSocket
(
sockFd
);
//
return
-
1
;
return
-
1
;
}
}
int
optVal
=
-
1
,
optLen
=
sizeof
(
int
);
int
optVal
=
-
1
,
optLen
=
sizeof
(
int
);
if
((
0
!=
taosGetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_ERROR
,
&
optVal
,
&
optLen
))
||
(
optVal
!=
0
))
{
if
((
0
!=
taosGetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_ERROR
,
&
optVal
,
&
optLen
))
||
(
optVal
!=
0
))
{
printf
(
"failed to connect socket, ip:0x%x, port:%hu(connect host error)"
,
destIp
,
destPort
);
//
printf("failed to connect socket, ip:0x%x, port:%hu(connect host error)", destIp, destPort);
taosCloseSocket
(
sockFd
);
//
taosCloseSocket
(
sockFd
);
//
return
-
1
;
return
-
1
;
}
}
ret
=
0
;
ret
=
0
;
}
else
{
// Other error
}
else
{
// Other error
printf
(
"failed to connect socket, ip:0x%x, port:%hu(target host cannot be reached)"
,
destIp
,
destPort
);
//
printf("failed to connect socket, ip:0x%x, port:%hu(target host cannot be reached)", destIp, destPort);
taosCloseSocket
(
sockFd
);
//
taosCloseSocket
(
sockFd
);
//
return
-
1
;
return
-
1
;
}
}
...
@@ -636,7 +636,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
...
@@ -636,7 +636,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
#endif
#endif
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
printf
(
"failed to connect socket, ip:0x%x, port:%hu(%s)"
,
destIp
,
destPort
,
strerror
(
errno
));
//
printf("failed to connect socket, ip:0x%x, port:%hu(%s)", destIp, destPort, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
sockFd
=
-
1
;
sockFd
=
-
1
;
}
else
{
}
else
{
...
@@ -649,7 +649,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
...
@@ -649,7 +649,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
int32_t
taosKeepTcpAlive
(
SOCKET
sockFd
)
{
int32_t
taosKeepTcpAlive
(
SOCKET
sockFd
)
{
int32_t
alive
=
1
;
int32_t
alive
=
1
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
void
*
)
&
alive
,
sizeof
(
alive
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
void
*
)
&
alive
,
sizeof
(
alive
))
<
0
)
{
printf
(
"fd:%d setsockopt SO_KEEPALIVE failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
//
printf("fd:%d setsockopt SO_KEEPALIVE failed: %d (%s)", sockFd, errno, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -658,21 +658,21 @@ int32_t taosKeepTcpAlive(SOCKET sockFd) {
...
@@ -658,21 +658,21 @@ int32_t taosKeepTcpAlive(SOCKET sockFd) {
// all fails on macosx
// all fails on macosx
int32_t
probes
=
3
;
int32_t
probes
=
3
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPCNT
,
(
void
*
)
&
probes
,
sizeof
(
probes
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPCNT
,
(
void
*
)
&
probes
,
sizeof
(
probes
))
<
0
)
{
printf
(
"fd:%d setsockopt SO_KEEPCNT failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
//
printf("fd:%d setsockopt SO_KEEPCNT failed: %d (%s)", sockFd, errno, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
int32_t
alivetime
=
10
;
int32_t
alivetime
=
10
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPIDLE
,
(
void
*
)
&
alivetime
,
sizeof
(
alivetime
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPIDLE
,
(
void
*
)
&
alivetime
,
sizeof
(
alivetime
))
<
0
)
{
printf
(
"fd:%d setsockopt SO_KEEPIDLE failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
//
printf("fd:%d setsockopt SO_KEEPIDLE failed: %d (%s)", sockFd, errno, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
int32_t
interval
=
3
;
int32_t
interval
=
3
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPINTVL
,
(
void
*
)
&
interval
,
sizeof
(
interval
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_TCP
,
TCP_KEEPINTVL
,
(
void
*
)
&
interval
,
sizeof
(
interval
))
<
0
)
{
printf
(
"fd:%d setsockopt SO_KEEPINTVL failed: %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
//
printf("fd:%d setsockopt SO_KEEPINTVL failed: %d (%s)", sockFd, errno, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -680,7 +680,7 @@ int32_t taosKeepTcpAlive(SOCKET sockFd) {
...
@@ -680,7 +680,7 @@ int32_t taosKeepTcpAlive(SOCKET sockFd) {
int32_t
nodelay
=
1
;
int32_t
nodelay
=
1
;
if
(
taosSetSockOpt
(
sockFd
,
IPPROTO_TCP
,
TCP_NODELAY
,
(
void
*
)
&
nodelay
,
sizeof
(
nodelay
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
IPPROTO_TCP
,
TCP_NODELAY
,
(
void
*
)
&
nodelay
,
sizeof
(
nodelay
))
<
0
)
{
printf
(
"fd:%d setsockopt TCP_NODELAY failed %d (%s)"
,
sockFd
,
errno
,
strerror
(
errno
));
//
printf("fd:%d setsockopt TCP_NODELAY failed %d (%s)", sockFd, errno, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -689,7 +689,7 @@ int32_t taosKeepTcpAlive(SOCKET sockFd) {
...
@@ -689,7 +689,7 @@ int32_t taosKeepTcpAlive(SOCKET sockFd) {
linger
.
l_onoff
=
1
;
linger
.
l_onoff
=
1
;
linger
.
l_linger
=
3
;
linger
.
l_linger
=
3
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_LINGER
,
(
void
*
)
&
linger
,
sizeof
(
linger
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_LINGER
,
(
void
*
)
&
linger
,
sizeof
(
linger
))
<
0
)
{
printf
(
"setsockopt SO_LINGER failed: %d (%s)"
,
errno
,
strerror
(
errno
));
//
printf("setsockopt SO_LINGER failed: %d (%s)", errno, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -702,7 +702,7 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
...
@@ -702,7 +702,7 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
SOCKET
sockFd
;
SOCKET
sockFd
;
int32_t
reuse
;
int32_t
reuse
;
printf
(
"open tcp server socket:0x%x:%hu"
,
ip
,
port
);
//
printf("open tcp server socket:0x%x:%hu", ip, port);
bzero
((
char
*
)
&
serverAdd
,
sizeof
(
serverAdd
));
bzero
((
char
*
)
&
serverAdd
,
sizeof
(
serverAdd
));
serverAdd
.
sin_family
=
AF_INET
;
serverAdd
.
sin_family
=
AF_INET
;
...
@@ -710,7 +710,7 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
...
@@ -710,7 +710,7 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
serverAdd
.
sin_port
=
(
uint16_t
)
htons
(
port
);
serverAdd
.
sin_port
=
(
uint16_t
)
htons
(
port
);
if
((
sockFd
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
))
<=
2
)
{
if
((
sockFd
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
))
<=
2
)
{
printf
(
"failed to open TCP socket: %d (%s)"
,
errno
,
strerror
(
errno
));
//
printf("failed to open TCP socket: %d (%s)", errno, strerror(errno));
taosCloseSocketNoCheck
(
sockFd
);
taosCloseSocketNoCheck
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -718,26 +718,26 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
...
@@ -718,26 +718,26 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
/* set REUSEADDR option, so the portnumber can be re-used */
/* set REUSEADDR option, so the portnumber can be re-used */
reuse
=
1
;
reuse
=
1
;
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
if
(
taosSetSockOpt
(
sockFd
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
void
*
)
&
reuse
,
sizeof
(
reuse
))
<
0
)
{
printf
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
//
printf("setsockopt SO_REUSEADDR failed: %d (%s)", errno, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
/* bind socket to server address */
/* bind socket to server address */
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
serverAdd
,
sizeof
(
serverAdd
))
<
0
)
{
if
(
bind
(
sockFd
,
(
struct
sockaddr
*
)
&
serverAdd
,
sizeof
(
serverAdd
))
<
0
)
{
printf
(
"bind tcp server socket failed, 0x%x:%hu(%s)"
,
ip
,
port
,
strerror
(
errno
));
//
printf("bind tcp server socket failed, 0x%x:%hu(%s)", ip, port, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
if
(
taosKeepTcpAlive
(
sockFd
)
<
0
)
{
if
(
taosKeepTcpAlive
(
sockFd
)
<
0
)
{
printf
(
"failed to set tcp server keep-alive option, 0x%x:%hu(%s)"
,
ip
,
port
,
strerror
(
errno
));
//
printf("failed to set tcp server keep-alive option, 0x%x:%hu(%s)", ip, port, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
if
(
listen
(
sockFd
,
1024
)
<
0
)
{
if
(
listen
(
sockFd
,
1024
)
<
0
)
{
printf
(
"listen tcp server socket failed, 0x%x:%hu(%s)"
,
ip
,
port
,
strerror
(
errno
));
//
printf("listen tcp server socket failed, 0x%x:%hu(%s)", ip, port, strerror(errno));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -767,16 +767,16 @@ int64_t taosCopyFds(SOCKET sfd, int32_t dfd, int64_t len) {
...
@@ -767,16 +767,16 @@ int64_t taosCopyFds(SOCKET sfd, int32_t dfd, int64_t len) {
int64_t
retLen
=
taosReadMsg
(
sfd
,
temp
,
(
int32_t
)
readLen
);
int64_t
retLen
=
taosReadMsg
(
sfd
,
temp
,
(
int32_t
)
readLen
);
if
(
readLen
!=
retLen
)
{
if
(
readLen
!=
retLen
)
{
printf
(
"read error, readLen:%"
PRId64
" retLen:%"
PRId64
" len:%"
PRId64
" leftLen:%"
PRId64
", reason:%s"
,
//
printf("read error, readLen:%" PRId64 " retLen:%" PRId64 " len:%" PRId64 " leftLen:%" PRId64 ", reason:%s",
readLen
,
retLen
,
len
,
leftLen
,
strerror
(
errno
));
//
readLen, retLen, len, leftLen, strerror(errno));
return
-
1
;
return
-
1
;
}
}
writeLen
=
taosWriteMsg
(
dfd
,
temp
,
(
int32_t
)
readLen
);
writeLen
=
taosWriteMsg
(
dfd
,
temp
,
(
int32_t
)
readLen
);
if
(
readLen
!=
writeLen
)
{
if
(
readLen
!=
writeLen
)
{
printf
(
"copy error, readLen:%"
PRId64
" writeLen:%"
PRId64
" len:%"
PRId64
" leftLen:%"
PRId64
", reason:%s"
,
//
printf("copy error, readLen:%" PRId64 " writeLen:%" PRId64 " len:%" PRId64 " leftLen:%" PRId64 ", reason:%s",
readLen
,
writeLen
,
len
,
leftLen
,
strerror
(
errno
));
//
readLen, writeLen, len, leftLen, strerror(errno));
return
-
1
;
return
-
1
;
}
}
...
...
source/os/src/osString.c
浏览文件 @
7330b0f8
...
@@ -277,7 +277,7 @@ char *strsep(char **stringp, const char *delim) {
...
@@ -277,7 +277,7 @@ char *strsep(char **stringp, const char *delim) {
char
*
getpass
(
const
char
*
prefix
)
{
char
*
getpass
(
const
char
*
prefix
)
{
static
char
passwd
[
TSDB_KEY_LEN
]
=
{
0
};
static
char
passwd
[
TSDB_KEY_LEN
]
=
{
0
};
memset
(
passwd
,
0
,
TSDB_KEY_LEN
);
memset
(
passwd
,
0
,
TSDB_KEY_LEN
);
printf
(
"%s"
,
prefix
);
//
printf("%s", prefix);
int32_t
index
=
0
;
int32_t
index
=
0
;
char
ch
;
char
ch
;
...
...
source/os/src/osSysinfo.c
浏览文件 @
7330b0f8
...
@@ -134,7 +134,7 @@ int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize) {
...
@@ -134,7 +134,7 @@ int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize) {
diskSize
->
used
=
(
int64_t
)(
i64TotalBytes
-
i64FreeBytes
);
diskSize
->
used
=
(
int64_t
)(
i64TotalBytes
-
i64FreeBytes
);
return
0
;
return
0
;
}
else
{
}
else
{
printf
(
"failed to get disk size, dataDir:%s errno:%s"
,
tsDataDir
,
strerror
(
errno
));
//
printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
...
@@ -205,12 +205,12 @@ void taosGetSystemInfo() {
...
@@ -205,12 +205,12 @@ void taosGetSystemInfo() {
}
}
void
taosKillSystem
()
{
void
taosKillSystem
()
{
printf
(
"function taosKillSystem, exit!"
);
//
printf("function taosKillSystem, exit!");
exit
(
0
);
exit
(
0
);
}
}
int
taosSystem
(
const
char
*
cmd
)
{
int
taosSystem
(
const
char
*
cmd
)
{
printf
(
"taosSystem not support"
);
//
printf("taosSystem not support");
return
-
1
;
return
-
1
;
}
}
...
@@ -280,7 +280,7 @@ static void taosGetSystemTimezone() {
...
@@ -280,7 +280,7 @@ static void taosGetSystemTimezone() {
{
{
int
n
=
readlink
(
"/etc/localtime"
,
buf
,
sizeof
(
buf
));
int
n
=
readlink
(
"/etc/localtime"
,
buf
,
sizeof
(
buf
));
if
(
n
<
0
)
{
if
(
n
<
0
)
{
printf
(
"read /etc/localtime error, reason:%s"
,
strerror
(
errno
));
//
printf("read /etc/localtime error, reason:%s", strerror(errno));
return
;
return
;
}
}
buf
[
n
]
=
'\0'
;
buf
[
n
]
=
'\0'
;
...
@@ -294,7 +294,7 @@ static void taosGetSystemTimezone() {
...
@@ -294,7 +294,7 @@ static void taosGetSystemTimezone() {
}
}
}
}
if
(
!
tz
||
0
==
strchr
(
tz
,
'/'
))
{
if
(
!
tz
||
0
==
strchr
(
tz
,
'/'
))
{
printf
(
"parsing /etc/localtime failed"
);
//
printf("parsing /etc/localtime failed");
return
;
return
;
}
}
...
@@ -321,7 +321,7 @@ static void taosGetSystemTimezone() {
...
@@ -321,7 +321,7 @@ static void taosGetSystemTimezone() {
-
timezone
/
3600
);
-
timezone
/
3600
);
// cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
// cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
printf
(
"timezone not configured, set to system default:%s"
,
tsTimezone
);
//
printf("timezone not configured, set to system default:%s", tsTimezone);
}
}
/*
/*
...
@@ -348,11 +348,11 @@ static void taosGetSystemLocale() { // get and set default locale
...
@@ -348,11 +348,11 @@ static void taosGetSystemLocale() { // get and set default locale
locale
=
setlocale
(
LC_CTYPE
,
""
);
locale
=
setlocale
(
LC_CTYPE
,
""
);
if
(
locale
==
NULL
)
{
if
(
locale
==
NULL
)
{
printf
(
"can't get locale from system, set it to en_US.UTF-8 since error:%d:%s"
,
errno
,
strerror
(
errno
));
//
printf("can't get locale from system, set it to en_US.UTF-8 since error:%d:%s", errno, strerror(errno));
strcpy
(
tsLocale
,
"en_US.UTF-8"
);
strcpy
(
tsLocale
,
"en_US.UTF-8"
);
}
else
{
}
else
{
tstrncpy
(
tsLocale
,
locale
,
TSDB_LOCALE_LEN
);
tstrncpy
(
tsLocale
,
locale
,
TSDB_LOCALE_LEN
);
printf
(
"locale not configured, set to system default:%s"
,
tsLocale
);
//
printf("locale not configured, set to system default:%s", tsLocale);
}
}
/* if user does not specify the charset, extract it from locale */
/* if user does not specify the charset, extract it from locale */
...
@@ -364,15 +364,15 @@ static void taosGetSystemLocale() { // get and set default locale
...
@@ -364,15 +364,15 @@ static void taosGetSystemLocale() { // get and set default locale
tstrncpy
(
tsCharset
,
revisedCharset
,
TSDB_LOCALE_LEN
);
tstrncpy
(
tsCharset
,
revisedCharset
,
TSDB_LOCALE_LEN
);
free
(
revisedCharset
);
free
(
revisedCharset
);
printf
(
"charset not configured, set to system default:%s"
,
tsCharset
);
//
printf("charset not configured, set to system default:%s", tsCharset);
}
else
{
}
else
{
strcpy
(
tsCharset
,
"UTF-8"
);
strcpy
(
tsCharset
,
"UTF-8"
);
printf
(
"can't get locale and charset from system, set it to UTF-8"
);
//
printf("can't get locale and charset from system, set it to UTF-8");
}
}
}
}
void
taosKillSystem
()
{
void
taosKillSystem
()
{
printf
(
"function taosKillSystem, exit!"
);
//
printf("function taosKillSystem, exit!");
exit
(
0
);
exit
(
0
);
}
}
...
@@ -432,7 +432,7 @@ bool taosGetSysMemory(float *memoryUsedMB) {
...
@@ -432,7 +432,7 @@ bool taosGetSysMemory(float *memoryUsedMB) {
}
}
int
taosSystem
(
const
char
*
cmd
)
{
int
taosSystem
(
const
char
*
cmd
)
{
printf
(
"un support funtion"
);
//
printf("un support funtion");
return
-
1
;
return
-
1
;
}
}
...
@@ -441,7 +441,7 @@ void taosSetCoreDump() {}
...
@@ -441,7 +441,7 @@ void taosSetCoreDump() {}
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SysDiskSize
*
diskSize
)
{
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SysDiskSize
*
diskSize
)
{
struct
statvfs
info
;
struct
statvfs
info
;
if
(
statvfs
(
dataDir
,
&
info
))
{
if
(
statvfs
(
dataDir
,
&
info
))
{
printf
(
"failed to get disk size, dataDir:%s errno:%s"
,
tsDataDir
,
strerror
(
errno
));
//
printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
else
{
}
else
{
...
@@ -535,7 +535,7 @@ bool taosGetSysMemory(float *memoryUsedMB) {
...
@@ -535,7 +535,7 @@ bool taosGetSysMemory(float *memoryUsedMB) {
bool
taosGetProcMemory
(
float
*
memoryUsedMB
)
{
bool
taosGetProcMemory
(
float
*
memoryUsedMB
)
{
FILE
*
fp
=
fopen
(
tsProcMemFile
,
"r"
);
FILE
*
fp
=
fopen
(
tsProcMemFile
,
"r"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
printf
(
"open file:%s failed"
,
tsProcMemFile
);
//
printf("open file:%s failed", tsProcMemFile);
return
false
;
return
false
;
}
}
...
@@ -555,7 +555,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
...
@@ -555,7 +555,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
}
}
if
(
line
==
NULL
)
{
if
(
line
==
NULL
)
{
printf
(
"read file:%s failed"
,
tsProcMemFile
);
//
printf("read file:%s failed", tsProcMemFile);
fclose
(
fp
);
fclose
(
fp
);
return
false
;
return
false
;
}
}
...
@@ -573,7 +573,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
...
@@ -573,7 +573,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
static
bool
taosGetSysCpuInfo
(
SysCpuInfo
*
cpuInfo
)
{
static
bool
taosGetSysCpuInfo
(
SysCpuInfo
*
cpuInfo
)
{
FILE
*
fp
=
fopen
(
tsSysCpuFile
,
"r"
);
FILE
*
fp
=
fopen
(
tsSysCpuFile
,
"r"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
printf
(
"open file:%s failed"
,
tsSysCpuFile
);
//
printf("open file:%s failed", tsSysCpuFile);
return
false
;
return
false
;
}
}
...
@@ -581,7 +581,7 @@ static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
...
@@ -581,7 +581,7 @@ static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
char
*
line
=
NULL
;
char
*
line
=
NULL
;
ssize_t
_bytes
=
getline
(
&
line
,
&
len
,
fp
);
ssize_t
_bytes
=
getline
(
&
line
,
&
len
,
fp
);
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
printf
(
"read file:%s failed"
,
tsSysCpuFile
);
//
printf("read file:%s failed", tsSysCpuFile);
fclose
(
fp
);
fclose
(
fp
);
return
false
;
return
false
;
}
}
...
@@ -598,7 +598,7 @@ static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
...
@@ -598,7 +598,7 @@ static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
static
bool
taosGetProcCpuInfo
(
ProcCpuInfo
*
cpuInfo
)
{
static
bool
taosGetProcCpuInfo
(
ProcCpuInfo
*
cpuInfo
)
{
FILE
*
fp
=
fopen
(
tsProcCpuFile
,
"r"
);
FILE
*
fp
=
fopen
(
tsProcCpuFile
,
"r"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
printf
(
"open file:%s failed"
,
tsProcCpuFile
);
//
printf("open file:%s failed", tsProcCpuFile);
return
false
;
return
false
;
}
}
...
@@ -606,7 +606,7 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
...
@@ -606,7 +606,7 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
char
*
line
=
NULL
;
char
*
line
=
NULL
;
ssize_t
_bytes
=
getline
(
&
line
,
&
len
,
fp
);
ssize_t
_bytes
=
getline
(
&
line
,
&
len
,
fp
);
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
printf
(
"read file:%s failed"
,
tsProcCpuFile
);
//
printf("read file:%s failed", tsProcCpuFile);
fclose
(
fp
);
fclose
(
fp
);
return
false
;
return
false
;
}
}
...
@@ -642,7 +642,7 @@ static void taosGetSystemTimezone() {
...
@@ -642,7 +642,7 @@ static void taosGetSystemTimezone() {
int
len
=
fread
(
buf
,
64
,
1
,
f
);
int
len
=
fread
(
buf
,
64
,
1
,
f
);
if
(
len
<
64
&&
ferror
(
f
))
{
if
(
len
<
64
&&
ferror
(
f
))
{
fclose
(
f
);
fclose
(
f
);
printf
(
"read /etc/timezone error, reason:%s"
,
strerror
(
errno
));
//
printf("read /etc/timezone error, reason:%s", strerror(errno));
return
;
return
;
}
}
...
@@ -681,7 +681,7 @@ static void taosGetSystemTimezone() {
...
@@ -681,7 +681,7 @@ static void taosGetSystemTimezone() {
snprintf
(
tsTimezone
,
TSDB_TIMEZONE_LEN
,
"%s (%s, %s%02d00)"
,
buf
,
tzname
[
daylight
],
tz
>=
0
?
"+"
:
"-"
,
abs
(
tz
));
snprintf
(
tsTimezone
,
TSDB_TIMEZONE_LEN
,
"%s (%s, %s%02d00)"
,
buf
,
tzname
[
daylight
],
tz
>=
0
?
"+"
:
"-"
,
abs
(
tz
));
// cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
// cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
printf
(
"timezone not configured, set to system default:%s"
,
tsTimezone
);
//
printf("timezone not configured, set to system default:%s", tsTimezone);
}
}
/*
/*
...
@@ -707,11 +707,11 @@ static void taosGetSystemLocale() { // get and set default locale
...
@@ -707,11 +707,11 @@ static void taosGetSystemLocale() { // get and set default locale
locale
=
setlocale
(
LC_CTYPE
,
""
);
locale
=
setlocale
(
LC_CTYPE
,
""
);
if
(
locale
==
NULL
)
{
if
(
locale
==
NULL
)
{
printf
(
"can't get locale from system, set it to en_US.UTF-8 since error:%d:%s"
,
errno
,
strerror
(
errno
));
//
printf("can't get locale from system, set it to en_US.UTF-8 since error:%d:%s", errno, strerror(errno));
strcpy
(
tsLocale
,
"en_US.UTF-8"
);
strcpy
(
tsLocale
,
"en_US.UTF-8"
);
}
else
{
}
else
{
tstrncpy
(
tsLocale
,
locale
,
TSDB_LOCALE_LEN
);
tstrncpy
(
tsLocale
,
locale
,
TSDB_LOCALE_LEN
);
printf
(
"locale not configured, set to system default:%s"
,
tsLocale
);
//
printf("locale not configured, set to system default:%s", tsLocale);
}
}
/* if user does not specify the charset, extract it from locale */
/* if user does not specify the charset, extract it from locale */
...
@@ -723,10 +723,10 @@ static void taosGetSystemLocale() { // get and set default locale
...
@@ -723,10 +723,10 @@ static void taosGetSystemLocale() { // get and set default locale
tstrncpy
(
tsCharset
,
revisedCharset
,
TSDB_LOCALE_LEN
);
tstrncpy
(
tsCharset
,
revisedCharset
,
TSDB_LOCALE_LEN
);
free
(
revisedCharset
);
free
(
revisedCharset
);
printf
(
"charset not configured, set to system default:%s"
,
tsCharset
);
//
printf("charset not configured, set to system default:%s", tsCharset);
}
else
{
}
else
{
strcpy
(
tsCharset
,
"UTF-8"
);
strcpy
(
tsCharset
,
"UTF-8"
);
printf
(
"can't get locale and charset from system, set it to UTF-8"
);
//
printf("can't get locale and charset from system, set it to UTF-8");
}
}
}
}
...
@@ -774,7 +774,7 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
...
@@ -774,7 +774,7 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SysDiskSize
*
diskSize
)
{
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SysDiskSize
*
diskSize
)
{
struct
statvfs
info
;
struct
statvfs
info
;
if
(
statvfs
(
dataDir
,
&
info
))
{
if
(
statvfs
(
dataDir
,
&
info
))
{
printf
(
"failed to get disk size, dataDir:%s errno:%s"
,
dataDir
,
strerror
(
errno
));
//
printf("failed to get disk size, dataDir:%s errno:%s", dataDir, strerror(errno));
return
-
1
;
return
-
1
;
}
else
{
}
else
{
diskSize
->
tsize
=
info
.
f_blocks
*
info
.
f_frsize
;
diskSize
->
tsize
=
info
.
f_blocks
*
info
.
f_frsize
;
...
@@ -788,7 +788,7 @@ bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
...
@@ -788,7 +788,7 @@ bool taosGetCardInfo(int64_t *bytes, int64_t *rbytes, int64_t *tbytes) {
*
bytes
=
0
;
*
bytes
=
0
;
FILE
*
fp
=
fopen
(
tsSysNetFile
,
"r"
);
FILE
*
fp
=
fopen
(
tsSysNetFile
,
"r"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
printf
(
"open file:%s failed"
,
tsSysNetFile
);
//
printf("open file:%s failed", tsSysNetFile);
return
false
;
return
false
;
}
}
...
@@ -864,7 +864,7 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
...
@@ -864,7 +864,7 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
double
totalBytes
=
(
double
)(
curBytes
-
lastBytes
)
/
1024
*
8
;
// Kb
double
totalBytes
=
(
double
)(
curBytes
-
lastBytes
)
/
1024
*
8
;
// Kb
*
bandSpeedKb
=
(
float
)(
totalBytes
/
(
double
)(
curTime
-
lastTime
));
*
bandSpeedKb
=
(
float
)(
totalBytes
/
(
double
)(
curTime
-
lastTime
));
// printf("bandwidth lastBytes:%ld, lastTime:%ld, curBytes:%ld, curTime:%ld,
//
//
printf("bandwidth lastBytes:%ld, lastTime:%ld, curBytes:%ld, curTime:%ld,
// speed:%f", lastBytes, lastTime, curBytes, curTime, *bandSpeed);
// speed:%f", lastBytes, lastTime, curBytes, curTime, *bandSpeed);
lastTime
=
curTime
;
lastTime
=
curTime
;
...
@@ -876,7 +876,7 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
...
@@ -876,7 +876,7 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
)
{
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
)
{
FILE
*
fp
=
fopen
(
tsProcIOFile
,
"r"
);
FILE
*
fp
=
fopen
(
tsProcIOFile
,
"r"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
printf
(
"open file:%s failed"
,
tsProcIOFile
);
//
printf("open file:%s failed", tsProcIOFile);
return
false
;
return
false
;
}
}
...
@@ -909,7 +909,7 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
...
@@ -909,7 +909,7 @@ bool taosReadProcIO(int64_t *rchars, int64_t *wchars) {
fclose
(
fp
);
fclose
(
fp
);
if
(
readIndex
<
2
)
{
if
(
readIndex
<
2
)
{
printf
(
"read file:%s failed"
,
tsProcIOFile
);
//
printf("read file:%s failed", tsProcIOFile);
return
false
;
return
false
;
}
}
...
@@ -964,7 +964,7 @@ void taosGetSystemInfo() {
...
@@ -964,7 +964,7 @@ void taosGetSystemInfo() {
void
taosKillSystem
()
{
void
taosKillSystem
()
{
// SIGINT
// SIGINT
printf
(
"taosd will shut down soon"
);
//
printf("taosd will shut down soon");
kill
(
tsProcId
,
2
);
kill
(
tsProcId
,
2
);
}
}
...
@@ -973,22 +973,22 @@ int taosSystem(const char *cmd) {
...
@@ -973,22 +973,22 @@ int taosSystem(const char *cmd) {
int
res
;
int
res
;
char
buf
[
1024
];
char
buf
[
1024
];
if
(
cmd
==
NULL
)
{
if
(
cmd
==
NULL
)
{
printf
(
"taosSystem cmd is NULL!"
);
//
printf("taosSystem cmd is NULL!");
return
-
1
;
return
-
1
;
}
}
if
((
fp
=
popen
(
cmd
,
"r"
))
==
NULL
)
{
if
((
fp
=
popen
(
cmd
,
"r"
))
==
NULL
)
{
printf
(
"popen cmd:%s error: %s"
,
cmd
,
strerror
(
errno
));
//
printf("popen cmd:%s error: %s", cmd, strerror(errno));
return
-
1
;
return
-
1
;
}
else
{
}
else
{
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
printf
(
"popen result:%s"
,
buf
);
//
printf("popen result:%s", buf);
}
}
if
((
res
=
pclose
(
fp
))
==
-
1
)
{
if
((
res
=
pclose
(
fp
))
==
-
1
)
{
printf
(
"close popen file pointer fp error!"
);
//
printf("close popen file pointer fp error!");
}
else
{
}
else
{
printf
(
"popen res is :%d"
,
res
);
//
printf("popen res is :%d", res);
}
}
return
res
;
return
res
;
...
@@ -1003,14 +1003,14 @@ void taosSetCoreDump(bool enable) {
...
@@ -1003,14 +1003,14 @@ void taosSetCoreDump(bool enable) {
struct
rlimit
rlim_new
;
struct
rlimit
rlim_new
;
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
#ifndef _ALPINE
#ifndef _ALPINE
printf
(
"the old unlimited para: rlim_cur=%"
PRIu64
", rlim_max=%"
PRIu64
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
//
printf("the old unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
#else
#else
printf
(
"the old unlimited para: rlim_cur=%llu, rlim_max=%llu"
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
//
printf("the old unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
#endif
#endif
rlim_new
.
rlim_cur
=
RLIM_INFINITY
;
rlim_new
.
rlim_cur
=
RLIM_INFINITY
;
rlim_new
.
rlim_max
=
RLIM_INFINITY
;
rlim_new
.
rlim_max
=
RLIM_INFINITY
;
if
(
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
)
!=
0
)
{
if
(
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
)
!=
0
)
{
printf
(
"set unlimited fail, error: %s"
,
strerror
(
errno
));
//
printf("set unlimited fail, error: %s", strerror(errno));
rlim_new
.
rlim_cur
=
rlim
.
rlim_max
;
rlim_new
.
rlim_cur
=
rlim
.
rlim_max
;
rlim_new
.
rlim_max
=
rlim
.
rlim_max
;
rlim_new
.
rlim_max
=
rlim
.
rlim_max
;
(
void
)
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
);
(
void
)
setrlimit
(
RLIMIT_CORE
,
&
rlim_new
);
...
@@ -1019,9 +1019,9 @@ void taosSetCoreDump(bool enable) {
...
@@ -1019,9 +1019,9 @@ void taosSetCoreDump(bool enable) {
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
#ifndef _ALPINE
#ifndef _ALPINE
printf
(
"the new unlimited para: rlim_cur=%"
PRIu64
", rlim_max=%"
PRIu64
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
//
printf("the new unlimited para: rlim_cur=%" PRIu64 ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
#else
#else
printf
(
"the new unlimited para: rlim_cur=%llu, rlim_max=%llu"
,
rlim
.
rlim_cur
,
rlim
.
rlim_max
);
//
printf("the new unlimited para: rlim_cur=%llu, rlim_max=%llu", rlim.rlim_cur, rlim.rlim_max);
#endif
#endif
}
}
...
@@ -1047,10 +1047,10 @@ void taosSetCoreDump(bool enable) {
...
@@ -1047,10 +1047,10 @@ void taosSetCoreDump(bool enable) {
old_len
=
sizeof
(
old_usespid
);
old_len
=
sizeof
(
old_usespid
);
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
printf
(
"_sysctl(kern_core_uses_pid) set fail: %s"
,
strerror
(
errno
));
//
printf("_sysctl(kern_core_uses_pid) set fail: %s", strerror(errno));
}
}
printf
(
"The old core_uses_pid[%"
PRIu64
"]: %d"
,
old_len
,
old_usespid
);
//
printf("The old core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
old_usespid
=
0
;
old_usespid
=
0
;
old_len
=
0
;
old_len
=
0
;
...
@@ -1063,10 +1063,10 @@ void taosSetCoreDump(bool enable) {
...
@@ -1063,10 +1063,10 @@ void taosSetCoreDump(bool enable) {
old_len
=
sizeof
(
old_usespid
);
old_len
=
sizeof
(
old_usespid
);
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
if
(
syscall
(
SYS__sysctl
,
&
args
)
==
-
1
)
{
printf
(
"_sysctl(kern_core_uses_pid) get fail: %s"
,
strerror
(
errno
));
//
printf("_sysctl(kern_core_uses_pid) get fail: %s", strerror(errno));
}
}
printf
(
"The new core_uses_pid[%"
PRIu64
"]: %d"
,
old_len
,
old_usespid
);
//
printf("The new core_uses_pid[%" PRIu64 "]: %d", old_len, old_usespid);
#endif
#endif
}
}
...
...
source/os/src/osSystem.c
浏览文件 @
7330b0f8
...
@@ -87,11 +87,11 @@ int taosSetConsoleEcho(bool on) {
...
@@ -87,11 +87,11 @@ int taosSetConsoleEcho(bool on) {
void
*
taosLoadDll
(
const
char
*
filename
)
{
void
*
taosLoadDll
(
const
char
*
filename
)
{
void
*
handle
=
dlopen
(
filename
,
RTLD_LAZY
);
void
*
handle
=
dlopen
(
filename
,
RTLD_LAZY
);
if
(
!
handle
)
{
if
(
!
handle
)
{
printf
(
"load dll:%s failed, error:%s"
,
filename
,
dlerror
());
//
printf("load dll:%s failed, error:%s", filename, dlerror());
return
NULL
;
return
NULL
;
}
}
printf
(
"dll %s loaded"
,
filename
);
//
printf("dll %s loaded", filename);
return
handle
;
return
handle
;
}
}
...
@@ -101,11 +101,11 @@ void* taosLoadSym(void* handle, char* name) {
...
@@ -101,11 +101,11 @@ void* taosLoadSym(void* handle, char* name) {
char
*
error
=
NULL
;
char
*
error
=
NULL
;
if
((
error
=
dlerror
())
!=
NULL
)
{
if
((
error
=
dlerror
())
!=
NULL
)
{
printf
(
"load sym:%s failed, error:%s"
,
name
,
dlerror
());
//
printf("load sym:%s failed, error:%s", name, dlerror());
return
NULL
;
return
NULL
;
}
}
printf
(
"sym %s loaded"
,
name
);
//
printf("sym %s loaded", name);
return
sym
;
return
sym
;
}
}
...
@@ -133,7 +133,7 @@ int taosSetConsoleEcho(bool on) {
...
@@ -133,7 +133,7 @@ int taosSetConsoleEcho(bool on) {
err
=
tcsetattr
(
STDIN_FILENO
,
TCSAFLUSH
,
&
term
);
err
=
tcsetattr
(
STDIN_FILENO
,
TCSAFLUSH
,
&
term
);
if
(
err
==
-
1
||
err
==
EINTR
)
{
if
(
err
==
-
1
||
err
==
EINTR
)
{
printf
(
"Cannot set the attribution of the terminal"
);
//
printf("Cannot set the attribution of the terminal");
return
-
1
;
return
-
1
;
}
}
...
...
source/os/src/osTimer.c
浏览文件 @
7330b0f8
...
@@ -170,7 +170,7 @@ static void *taosProcessAlarmSignal(void *tharg) {
...
@@ -170,7 +170,7 @@ static void *taosProcessAlarmSignal(void *tharg) {
sevent
.
sigev_signo
=
SIGALRM
;
sevent
.
sigev_signo
=
SIGALRM
;
if
(
timer_create
(
CLOCK_REALTIME
,
&
sevent
,
&
timerId
)
==
-
1
)
{
if
(
timer_create
(
CLOCK_REALTIME
,
&
sevent
,
&
timerId
)
==
-
1
)
{
printf
(
"Failed to create timer"
);
//
printf("Failed to create timer");
}
}
pthread_cleanup_push
(
taosDeleteTimer
,
&
timerId
);
pthread_cleanup_push
(
taosDeleteTimer
,
&
timerId
);
...
@@ -182,17 +182,17 @@ static void *taosProcessAlarmSignal(void *tharg) {
...
@@ -182,17 +182,17 @@ static void *taosProcessAlarmSignal(void *tharg) {
ts
.
it_interval
.
tv_nsec
=
1000000
*
MSECONDS_PER_TICK
;
ts
.
it_interval
.
tv_nsec
=
1000000
*
MSECONDS_PER_TICK
;
if
(
timer_settime
(
timerId
,
0
,
&
ts
,
NULL
))
{
if
(
timer_settime
(
timerId
,
0
,
&
ts
,
NULL
))
{
printf
(
"Failed to init timer"
);
//
printf("Failed to init timer");
return
NULL
;
return
NULL
;
}
}
int
signo
;
int
signo
;
while
(
!
stopTimer
)
{
while
(
!
stopTimer
)
{
if
(
sigwait
(
&
sigset
,
&
signo
))
{
if
(
sigwait
(
&
sigset
,
&
signo
))
{
printf
(
"Failed to wait signal: number %d"
,
signo
);
//
printf("Failed to wait signal: number %d", signo);
continue
;
continue
;
}
}
/* printf("Signal handling: number %d ......\n", signo); */
/*
//
printf("Signal handling: number %d ......\n", signo); */
callback
(
0
);
callback
(
0
);
}
}
...
@@ -208,10 +208,10 @@ int taosInitTimer(void (*callback)(int), int ms) {
...
@@ -208,10 +208,10 @@ int taosInitTimer(void (*callback)(int), int ms) {
int
code
=
pthread_create
(
&
timerThread
,
&
tattr
,
taosProcessAlarmSignal
,
callback
);
int
code
=
pthread_create
(
&
timerThread
,
&
tattr
,
taosProcessAlarmSignal
,
callback
);
pthread_attr_destroy
(
&
tattr
);
pthread_attr_destroy
(
&
tattr
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
printf
(
"failed to create timer thread"
);
//
printf("failed to create timer thread");
return
-
1
;
return
-
1
;
}
else
{
}
else
{
printf
(
"timer thread:0x%08"
PRIx64
" is created"
,
taosGetPthreadId
(
timerThread
));
//
printf("timer thread:0x%08" PRIx64 " is created", taosGetPthreadId(timerThread));
}
}
return
0
;
return
0
;
...
@@ -220,7 +220,7 @@ int taosInitTimer(void (*callback)(int), int ms) {
...
@@ -220,7 +220,7 @@ int taosInitTimer(void (*callback)(int), int ms) {
void
taosUninitTimer
()
{
void
taosUninitTimer
()
{
stopTimer
=
true
;
stopTimer
=
true
;
printf
(
"join timer thread:0x%08"
PRIx64
,
taosGetPthreadId
(
timerThread
));
//
printf("join timer thread:0x%08" PRIx64, taosGetPthreadId(timerThread));
pthread_join
(
timerThread
,
NULL
);
pthread_join
(
timerThread
,
NULL
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录