Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lzh_me
TDengine
提交
e6985f8e
TDengine
项目概览
lzh_me
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e6985f8e
编写于
6月 11, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
6月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2230 from taosdata/hotfix/snprintf
use snprintf whenever possible
上级
068cf108
d644273f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
15 deletion
+17
-15
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+6
-4
src/wal/src/walMain.c
src/wal/src/walMain.c
+11
-11
未找到文件。
src/rpc/src/rpcMain.c
浏览文件 @
e6985f8e
...
...
@@ -425,6 +425,8 @@ void rpcSendResponse(const SRpcMsg *pRsp) {
taosTmrReset
(
rpcProcessIdleTimer
,
pRpc
->
idleTime
,
pConn
,
pRpc
->
tmrCtrl
,
&
pConn
->
pIdleTimer
);
rpcSendMsgToPeer
(
pConn
,
msg
,
msgLen
);
pConn
->
secured
=
1
;
// connection shall be secured
pConn
->
pReqMsg
=
NULL
;
pConn
->
reqMsgLen
=
0
;
rpcUnlockConn
(
pConn
);
rpcDecRef
(
pRpc
);
// decrease the referene count
...
...
@@ -542,7 +544,7 @@ static void rpcCloseConn(void *thandle) {
if
(
pRpc
->
connType
==
TAOS_CONN_SERVER
)
{
char
hashstr
[
40
]
=
{
0
};
size_t
size
=
s
printf
(
hashstr
,
"%x:%x:%x:%d"
,
pConn
->
peerIp
,
pConn
->
linkUid
,
pConn
->
peerId
,
pConn
->
connType
);
size_t
size
=
s
nprintf
(
hashstr
,
sizeof
(
hashstr
)
,
"%x:%x:%x:%d"
,
pConn
->
peerIp
,
pConn
->
linkUid
,
pConn
->
peerId
,
pConn
->
connType
);
taosHashRemove
(
pRpc
->
hash
,
hashstr
,
size
);
rpcFreeMsg
(
pConn
->
pRspMsg
);
// it may have a response msg saved, but not request msg
...
...
@@ -592,7 +594,7 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
char
hashstr
[
40
]
=
{
0
};
SRpcHead
*
pHead
=
(
SRpcHead
*
)
pRecv
->
msg
;
size_t
size
=
s
printf
(
hashstr
,
"%x:%x:%x:%d"
,
pRecv
->
ip
,
pHead
->
linkUid
,
pHead
->
sourceId
,
pRecv
->
connType
);
size_t
size
=
s
nprintf
(
hashstr
,
sizeof
(
hashstr
)
,
"%x:%x:%x:%d"
,
pRecv
->
ip
,
pHead
->
linkUid
,
pHead
->
sourceId
,
pRecv
->
connType
);
// check if it is already allocated
SRpcConn
**
ppConn
=
(
SRpcConn
**
)(
taosHashGet
(
pRpc
->
hash
,
hashstr
,
size
));
...
...
@@ -682,7 +684,7 @@ static SRpcConn *rpcSetupConnToServer(SRpcReqContext *pContext) {
if
(
pConn
)
{
pConn
->
tretry
=
0
;
pConn
->
ahandle
=
pContext
->
ahandle
;
s
printf
(
pConn
->
info
,
"%s %p %p"
,
pRpc
->
label
,
pConn
,
pConn
->
ahandle
);
s
nprintf
(
pConn
->
info
,
sizeof
(
pConn
->
info
)
,
"%s %p %p"
,
pRpc
->
label
,
pConn
,
pConn
->
ahandle
);
pConn
->
tretry
=
0
;
}
else
{
tError
(
"%s %p, failed to set up connection(%s)"
,
pRpc
->
label
,
pContext
->
ahandle
,
tstrerror
(
terrno
));
...
...
@@ -811,7 +813,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) {
if
(
rpcIsReq
(
pHead
->
msgType
))
{
pConn
->
ahandle
=
(
void
*
)
pHead
->
ahandle
;
s
printf
(
pConn
->
info
,
"%s %p %p"
,
pRpc
->
label
,
pConn
,
pConn
->
ahandle
);
s
nprintf
(
pConn
->
info
,
sizeof
(
pConn
->
info
)
,
"%s %p %p"
,
pRpc
->
label
,
pConn
,
pConn
->
ahandle
);
}
sid
=
pConn
->
sid
;
...
...
src/wal/src/walMain.c
浏览文件 @
e6985f8e
...
...
@@ -44,7 +44,7 @@ typedef struct {
uint32_t
id
;
// increase continuously
int
num
;
// number of wal files
char
path
[
TSDB_FILENAME_LEN
];
char
name
[
TSDB_FILENAME_LEN
];
char
name
[
TSDB_FILENAME_LEN
+
16
];
pthread_mutex_t
mutex
;
}
SWal
;
...
...
@@ -108,7 +108,7 @@ void walClose(void *handle) {
if
(
pWal
->
keep
==
0
)
{
// remove all files in the directory
for
(
int
i
=
0
;
i
<
pWal
->
num
;
++
i
)
{
s
printf
(
pWal
->
name
,
"%s/%s%d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
-
i
);
s
nprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
)
,
"%s/%s%d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
-
i
);
if
(
remove
(
pWal
->
name
)
<
0
)
{
wError
(
"wal:%s, failed to remove"
,
pWal
->
name
);
}
else
{
...
...
@@ -140,7 +140,7 @@ int walRenew(void *handle) {
pWal
->
num
++
;
s
printf
(
pWal
->
name
,
"%s/%s%d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
);
s
nprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
)
,
"%s/%s%d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
);
pWal
->
fd
=
open
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
pWal
->
fd
<
0
)
{
...
...
@@ -152,7 +152,7 @@ int walRenew(void *handle) {
if
(
pWal
->
num
>
pWal
->
max
)
{
// remove the oldest wal file
char
name
[
TSDB_FILENAME_LEN
*
3
];
s
printf
(
name
,
"%s/%s%d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
-
pWal
->
max
);
s
nprintf
(
name
,
sizeof
(
name
)
,
"%s/%s%d"
,
pWal
->
path
,
walPrefix
,
pWal
->
id
-
pWal
->
max
);
if
(
remove
(
name
)
<
0
)
{
wError
(
"wal:%s, failed to remove(%s)"
,
name
,
strerror
(
errno
));
}
else
{
...
...
@@ -214,7 +214,7 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int))
int
plen
=
strlen
(
walPrefix
);
char
opath
[
TSDB_FILENAME_LEN
+
5
];
int
slen
=
s
printf
(
opath
,
"%s"
,
pWal
->
path
);
int
slen
=
s
nprintf
(
opath
,
sizeof
(
opath
)
,
"%s"
,
pWal
->
path
);
if
(
pWal
->
keep
==
0
)
strcpy
(
opath
+
slen
,
"/old"
);
...
...
@@ -245,7 +245,7 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int))
wTrace
(
"wal:%s, %d files will be restored"
,
opath
,
count
);
for
(
index
=
minId
;
index
<=
maxId
;
++
index
)
{
s
printf
(
pWal
->
name
,
"%s/%s%d"
,
opath
,
walPrefix
,
index
);
s
nprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
)
,
"%s/%s%d"
,
opath
,
walPrefix
,
index
);
terrno
=
walRestoreWalFile
(
pWal
,
pVnode
,
writeFp
);
if
(
terrno
<
0
)
break
;
}
...
...
@@ -264,7 +264,7 @@ int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int))
// open the existing WAL file in append mode
pWal
->
num
=
count
;
pWal
->
id
=
maxId
;
s
printf
(
pWal
->
name
,
"%s/%s%d"
,
opath
,
walPrefix
,
maxId
);
s
nprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
)
,
"%s/%s%d"
,
opath
,
walPrefix
,
maxId
);
pWal
->
fd
=
open
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
|
O_APPEND
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
pWal
->
fd
<
0
)
{
wError
(
"wal:%s, failed to open file(%s)"
,
pWal
->
name
,
strerror
(
errno
));
...
...
@@ -361,7 +361,7 @@ int walHandleExistingFiles(const char *path) {
char
nname
[
TSDB_FILENAME_LEN
*
3
];
char
opath
[
TSDB_FILENAME_LEN
];
s
printf
(
opath
,
"%s/old"
,
path
);
s
nprintf
(
opath
,
sizeof
(
opath
)
,
"%s/old"
,
path
);
struct
dirent
*
ent
;
DIR
*
dir
=
opendir
(
path
);
...
...
@@ -377,8 +377,8 @@ int walHandleExistingFiles(const char *path) {
int
count
=
0
;
while
((
ent
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strncmp
(
ent
->
d_name
,
walPrefix
,
plen
)
==
0
)
{
s
printf
(
oname
,
"%s/%s"
,
path
,
ent
->
d_name
);
s
printf
(
nname
,
"%s/old/%s"
,
path
,
ent
->
d_name
);
s
nprintf
(
oname
,
sizeof
(
oname
)
,
"%s/%s"
,
path
,
ent
->
d_name
);
s
nprintf
(
nname
,
sizeof
(
nname
)
,
"%s/old/%s"
,
path
,
ent
->
d_name
);
if
(
access
(
opath
,
F_OK
)
!=
0
)
{
if
(
mkdir
(
opath
,
0755
)
!=
0
)
{
wError
(
"wal:%s, failed to create directory:%s(%s)"
,
oname
,
opath
,
strerror
(
errno
));
...
...
@@ -416,7 +416,7 @@ static int walRemoveWalFiles(const char *path) {
while
((
ent
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strncmp
(
ent
->
d_name
,
walPrefix
,
plen
)
==
0
)
{
s
printf
(
name
,
"%s/%s"
,
path
,
ent
->
d_name
);
s
nprintf
(
name
,
sizeof
(
name
)
,
"%s/%s"
,
path
,
ent
->
d_name
);
if
(
remove
(
name
)
<
0
)
{
wError
(
"wal:%s, failed to remove(%s)"
,
name
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录