Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5f3ce43e
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
5f3ce43e
编写于
1月 29, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
c3b84da1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
12 deletion
+33
-12
src/util/src/tlog.c
src/util/src/tlog.c
+33
-12
未找到文件。
src/util/src/tlog.c
浏览文件 @
5f3ce43e
...
...
@@ -68,6 +68,8 @@ int8_t tsAsyncLog = 1;
float
tsTotalLogDirGB
=
0
;
float
tsAvailLogDirGB
=
0
;
float
tsMinimalLogDirGB
=
1
.
0
f
;
int64_t
asyncLogLostLines
=
0
;
#ifdef _TD_POWER_
char
tsLogDir
[
TSDB_FILENAME_LEN
]
=
"/var/log/power"
;
#else
...
...
@@ -527,10 +529,27 @@ static void taosLogBuffDestroy(SLogBuff *tLogBuff) {
}
#endif
static
void
taosCopyLogBuffer
(
SLogBuff
*
tLogBuff
,
int32_t
start
,
int32_t
end
,
char
*
msg
,
int32_t
msgLen
)
{
if
(
start
>
end
)
{
memcpy
(
LOG_BUF_BUFFER
(
tLogBuff
)
+
end
,
msg
,
msgLen
);
}
else
{
if
(
LOG_BUF_SIZE
(
tLogBuff
)
-
end
<
msgLen
)
{
memcpy
(
LOG_BUF_BUFFER
(
tLogBuff
)
+
end
,
msg
,
LOG_BUF_SIZE
(
tLogBuff
)
-
end
);
memcpy
(
LOG_BUF_BUFFER
(
tLogBuff
),
msg
+
LOG_BUF_SIZE
(
tLogBuff
)
-
end
,
msgLen
-
LOG_BUF_SIZE
(
tLogBuff
)
+
end
);
}
else
{
memcpy
(
LOG_BUF_BUFFER
(
tLogBuff
)
+
end
,
msg
,
msgLen
);
}
}
LOG_BUF_END
(
tLogBuff
)
=
(
LOG_BUF_END
(
tLogBuff
)
+
msgLen
)
%
LOG_BUF_SIZE
(
tLogBuff
);
}
static
int32_t
taosPushLogBuffer
(
SLogBuff
*
tLogBuff
,
char
*
msg
,
int32_t
msgLen
)
{
int32_t
start
=
0
;
int32_t
end
=
0
;
int32_t
remainSize
=
0
;
static
int64_t
lostLine
=
0
;
char
tmpBuf
[
40
]
=
{
0
};
int32_t
tmpBufLen
=
0
;
if
(
tLogBuff
==
NULL
||
tLogBuff
->
stop
)
return
-
1
;
...
...
@@ -540,22 +559,24 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen)
remainSize
=
(
start
>
end
)
?
(
end
-
start
-
1
)
:
(
start
+
LOG_BUF_SIZE
(
tLogBuff
)
-
end
-
1
);
if
(
remainSize
<=
msgLen
)
{
if
(
lostLine
>
0
)
{
sprintf
(
tmpBuf
,
"
\n
...Lost %"
PRId64
" lines here...
\n
"
,
lostLine
);
tmpBufLen
=
strlen
(
tmpBuf
);
}
if
(
remainSize
<=
msgLen
||
((
lostLine
>
0
)
&&
(
remainSize
<=
(
msgLen
+
tmpBufLen
))))
{
lostLine
++
;
asyncLogLostLines
++
;
pthread_mutex_unlock
(
&
LOG_BUF_MUTEX
(
tLogBuff
));
return
-
1
;
}
if
(
start
>
end
)
{
memcpy
(
LOG_BUF_BUFFER
(
tLogBuff
)
+
end
,
msg
,
msgLen
);
}
else
{
if
(
LOG_BUF_SIZE
(
tLogBuff
)
-
end
<
msgLen
)
{
memcpy
(
LOG_BUF_BUFFER
(
tLogBuff
)
+
end
,
msg
,
LOG_BUF_SIZE
(
tLogBuff
)
-
end
);
memcpy
(
LOG_BUF_BUFFER
(
tLogBuff
),
msg
+
LOG_BUF_SIZE
(
tLogBuff
)
-
end
,
msgLen
-
LOG_BUF_SIZE
(
tLogBuff
)
+
end
);
}
else
{
memcpy
(
LOG_BUF_BUFFER
(
tLogBuff
)
+
end
,
msg
,
msgLen
);
}
if
(
lostLine
>
0
)
{
taosCopyLogBuffer
(
tLogBuff
,
start
,
end
,
tmpBuf
,
tmpBufLen
);
lostLine
=
0
;
}
LOG_BUF_END
(
tLogBuff
)
=
(
LOG_BUF_END
(
tLogBuff
)
+
msgLen
)
%
LOG_BUF_SIZE
(
tLogBuff
);
taosCopyLogBuffer
(
tLogBuff
,
LOG_BUF_START
(
tLogBuff
),
LOG_BUF_END
(
tLogBuff
),
msg
,
msgLen
);
// TODO : put string in the buffer
...
...
@@ -603,7 +624,7 @@ static void *taosAsyncOutputLog(void *param) {
// Polling the buffer
while
(
1
)
{
log_size
=
taosPollLogBuffer
(
tLogBuff
,
tempBuffer
,
TSDB_DEFAULT_LOG_BUF_UNIT
);
log_size
=
taosPollLogBuffer
(
tLogBuff
,
tempBuffer
,
sizeof
(
tempBuffer
)
);
if
(
log_size
)
{
taosWrite
(
tLogBuff
->
fd
,
tempBuffer
,
log_size
);
LOG_BUF_START
(
tLogBuff
)
=
(
LOG_BUF_START
(
tLogBuff
)
+
log_size
)
%
LOG_BUF_SIZE
(
tLogBuff
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录