Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
b0b119
TDengine
提交
90944de1
TDengine
项目概览
b0b119
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
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,发现更多精彩内容 >>
未验证
提交
90944de1
编写于
1月 27, 2021
作者:
S
Shengliang Guan
提交者:
GitHub
1月 27, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5051 from freemine/mac
sem_timedwait porting issue
上级
a6cbb444
9dcee4f8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
29 deletion
+25
-29
src/dnode/src/dnodeTelemetry.c
src/dnode/src/dnodeTelemetry.c
+25
-29
未找到文件。
src/dnode/src/dnodeTelemetry.c
浏览文件 @
90944de1
...
...
@@ -31,12 +31,16 @@
#include "mnodeAcct.h"
#include "dnodeTelemetry.h"
static
tsem_t
tsExitSem
;
// sem_timedwait is NOT implemented on MacOSX
// thus, we use pthread_mutex_t/pthread_cond_t to simulate
static
pthread_mutex_t
tsExitLock
=
PTHREAD_MUTEX_INITIALIZER
;
static
pthread_cond_t
tsExitCond
=
PTHREAD_COND_INITIALIZER
;
static
volatile
int
tsExit
=
0
;
static
pthread_t
tsTelemetryThread
;
#define TELEMETRY_SERVER "telemetry.taosdata.com"
#define TELEMETRY_PORT 80
#define REPORT_INTERVAL 86400
#define REPORT_INTERVAL 86400
static
void
beginObject
(
SBufferWriter
*
bw
)
{
tbufWriteChar
(
bw
,
'{'
);
...
...
@@ -172,8 +176,8 @@ static void addMemoryInfo(SBufferWriter* bw) {
static
void
addVersionInfo
(
SBufferWriter
*
bw
)
{
addStringField
(
bw
,
"version"
,
version
);
addStringField
(
bw
,
"buildInfo"
,
buildinfo
);
addStringField
(
bw
,
"gitInfo"
,
gitinfo
);
addStringField
(
bw
,
"email"
,
tsEmail
);
addStringField
(
bw
,
"gitInfo"
,
gitinfo
);
addStringField
(
bw
,
"email"
,
tsEmail
);
}
static
void
addRuntimeInfo
(
SBufferWriter
*
bw
)
{
...
...
@@ -236,24 +240,19 @@ static void sendTelemetryReport() {
taosCloseSocket
(
fd
);
}
#ifdef __APPLE__
static
int
sem_timedwait
(
tsem_t
*
sem
,
struct
timespec
*
to
)
{
fprintf
(
stderr
,
"%s[%d]%s(): not implemented yet!
\n
"
,
basename
(
__FILE__
),
__LINE__
,
__func__
);
abort
();
}
#endif // __APPLE__
static
void
*
telemetryThread
(
void
*
param
)
{
struct
timespec
end
=
{
0
};
clock_gettime
(
CLOCK_REALTIME
,
&
end
);
end
.
tv_sec
+=
300
;
// wait 5 minutes before send first report
while
(
1
)
{
if
(
sem_timedwait
(
&
tsExitSem
,
&
end
)
==
0
)
{
break
;
}
else
if
(
errno
!=
ETIMEDOUT
)
{
continue
;
}
while
(
!
tsExit
)
{
int
r
=
0
;
struct
timespec
ts
=
end
;
pthread_mutex_lock
(
&
tsExitLock
);
r
=
pthread_cond_timedwait
(
&
tsExitCond
,
&
tsExitLock
,
&
ts
);
pthread_mutex_unlock
(
&
tsExitLock
);
if
(
r
==
0
)
break
;
if
(
r
!=
ETIMEDOUT
)
continue
;
if
(
sdbIsMaster
())
{
sendTelemetryReport
();
...
...
@@ -269,12 +268,12 @@ static void dnodeGetEmail(char* filepath) {
if
(
fd
<
0
)
{
return
;
}
if
(
taosRead
(
fd
,
(
void
*
)
tsEmail
,
TSDB_FQDN_LEN
)
<
0
)
{
dError
(
"failed to read %d bytes from file %s since %s"
,
TSDB_FQDN_LEN
,
filepath
,
strerror
(
errno
));
}
}
taosClose
(
fd
);
taosClose
(
fd
);
}
int32_t
dnodeInitTelemetry
()
{
...
...
@@ -282,13 +281,7 @@ int32_t dnodeInitTelemetry() {
return
0
;
}
dnodeGetEmail
(
"/usr/local/taos/email"
);
if
(
tsem_init
(
&
tsExitSem
,
0
,
0
)
==
-
1
)
{
// just log the error, it is ok for telemetry to fail
dTrace
(
"failed to create semaphore for telemetry, reason:%s"
,
strerror
(
errno
));
return
0
;
}
dnodeGetEmail
(
"/usr/local/taos/email"
);
pthread_attr_t
attr
;
pthread_attr_init
(
&
attr
);
...
...
@@ -310,8 +303,11 @@ void dnodeCleanupTelemetry() {
}
if
(
taosCheckPthreadValid
(
tsTelemetryThread
))
{
tsem_post
(
&
tsExitSem
);
pthread_mutex_lock
(
&
tsExitLock
);
tsExit
=
1
;
pthread_cond_signal
(
&
tsExitCond
);
pthread_mutex_unlock
(
&
tsExitLock
);
pthread_join
(
tsTelemetryThread
,
NULL
);
tsem_destroy
(
&
tsExitSem
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录