Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
65a28796
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看板
提交
65a28796
编写于
1月 16, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1207
上级
a47e778b
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
151 addition
and
90 deletion
+151
-90
src/dnode/src/dnodeSystem.c
src/dnode/src/dnodeSystem.c
+34
-41
src/kit/shell/src/shellMain.c
src/kit/shell/src/shellMain.c
+5
-7
src/os/inc/os.h
src/os/inc/os.h
+1
-0
src/os/inc/osSignal.h
src/os/inc/osSignal.h
+56
-0
src/os/inc/osWindows.h
src/os/inc/osWindows.h
+0
-18
src/os/src/detail/osSignal.c
src/os/src/detail/osSignal.c
+38
-0
src/os/src/linux/linuxEnv.c
src/os/src/linux/linuxEnv.c
+4
-0
src/os/src/windows/wSysinfo.c
src/os/src/windows/wSysinfo.c
+0
-2
src/sync/src/syncArbitrator.c
src/sync/src/syncArbitrator.c
+11
-18
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+1
-3
tests/tsim/src/simMain.c
tests/tsim/src/simMain.c
+1
-1
未找到文件。
src/dnode/src/dnodeSystem.c
浏览文件 @
65a28796
...
...
@@ -19,8 +19,10 @@
#include "tconfig.h"
#include "dnodeMain.h"
static
void
signal_handler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
static
tsem_t
exitSem
;
static
void
siguser1Handler
(
int32_t
signum
);
static
void
siguser2Handler
(
int32_t
signum
);
static
void
sigintHandler
(
int32_t
signum
);
int32_t
main
(
int32_t
argc
,
char
*
argv
[])
{
int
dump_config
=
0
;
...
...
@@ -28,7 +30,7 @@ int32_t main(int32_t argc, char *argv[]) {
// Set global configuration file
for
(
int32_t
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
if
(
i
<
argc
-
1
)
{
if
(
strlen
(
argv
[
++
i
])
>=
TSDB_FILENAME_LEN
)
{
printf
(
"config file path overflow"
);
exit
(
EXIT_FAILURE
);
...
...
@@ -80,8 +82,8 @@ int32_t main(int32_t argc, char *argv[]) {
taosSetRandomFileFailOutput
(
NULL
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"--random-file-fail-factor"
)
==
0
)
{
if
(
(
i
+
1
)
<
argc
)
{
int
factor
=
atoi
(
argv
[
i
+
1
]);
if
(
(
i
+
1
)
<
argc
)
{
int
factor
=
atoi
(
argv
[
i
+
1
]);
printf
(
"The factor of random failure is %d
\n
"
,
factor
);
taosSetRandomFileFailFactor
(
factor
);
}
else
{
...
...
@@ -93,7 +95,7 @@ int32_t main(int32_t argc, char *argv[]) {
}
if
(
0
!=
dump_config
)
{
tscEmbedded
=
1
;
tscEmbedded
=
1
;
taosInitGlobalCfg
();
taosReadGlobalLogCfg
();
...
...
@@ -112,14 +114,12 @@ int32_t main(int32_t argc, char *argv[]) {
}
/* Set termination handler. */
struct
sigaction
act
=
{{
0
}};
act
.
sa_flags
=
SA_SIGINFO
;
act
.
sa_sigaction
=
signal_handler
;
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGHUP
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
sigaction
(
SIGUSR1
,
&
act
,
NULL
);
sigaction
(
SIGUSR2
,
&
act
,
NULL
);
taosSetSignal
(
SIGUSR1
,
siguser1Handler
);
taosSetSignal
(
SIGUSR2
,
siguser2Handler
);
taosSetSignal
(
SIGTERM
,
sigintHandler
);
taosSetSignal
(
SIGHUP
,
sigintHandler
);
taosSetSignal
(
SIGINT
,
sigintHandler
);
taosSetSignal
(
SIGABRT
,
sigintHandler
);
// Open /var/log/syslog file to record information.
openlog
(
"TDengine:"
,
LOG_PID
|
LOG_CONS
|
LOG_NDELAY
,
LOG_LOCAL1
);
...
...
@@ -147,32 +147,25 @@ int32_t main(int32_t argc, char *argv[]) {
return
EXIT_SUCCESS
;
}
static
void
signal_handler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
)
{
if
(
signum
==
SIGUSR1
)
{
taosCfgDynamicOptions
(
"debugFlag 143"
);
return
;
}
if
(
signum
==
SIGUSR2
)
{
taosCfgDynamicOptions
(
"resetlog"
);
return
;
}
syslog
(
LOG_INFO
,
"Shut down signal is %d"
,
signum
);
syslog
(
LOG_INFO
,
"Shutting down TDengine service..."
);
// clean the system.
dInfo
(
"shut down signal is %d, sender PID:%d cmdline:%s"
,
signum
,
sigInfo
->
si_pid
,
taosGetCmdlineByPID
(
sigInfo
->
si_pid
));
// protect the application from receive another signal
struct
sigaction
act
=
{{
0
}};
#ifndef WINDOWS
act
.
sa_handler
=
SIG_IGN
;
#endif
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGHUP
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
sigaction
(
SIGUSR1
,
&
act
,
NULL
);
sigaction
(
SIGUSR2
,
&
act
,
NULL
);
// inform main thread to exit
tsem_post
(
&
exitSem
);
static
void
siguser1Handler
(
int32_t
signum
)
{
taosCfgDynamicOptions
(
"debugFlag 143"
);
}
static
void
siguser2Handler
(
int32_t
signum
)
{
taosCfgDynamicOptions
(
"resetlog"
);
}
static
void
sigintHandler
(
int32_t
signum
)
{
// clean the system.
dInfo
(
"shut down signal is %d"
,
signum
);
syslog
(
LOG_INFO
,
"Shut down signal is %d"
,
signum
);
syslog
(
LOG_INFO
,
"Shutting down TDengine service..."
);
// protect the application from receive another signal
taosIgnSignal
(
SIGUSR1
);
taosIgnSignal
(
SIGUSR2
);
taosIgnSignal
(
SIGTERM
);
taosIgnSignal
(
SIGHUP
);
taosIgnSignal
(
SIGINT
);
taosIgnSignal
(
SIGABRT
);
// inform main thread to exit
tsem_post
(
&
exitSem
);
}
\ No newline at end of file
src/kit/shell/src/shellMain.c
浏览文件 @
65a28796
...
...
@@ -21,7 +21,7 @@
pthread_t
pid
;
static
tsem_t
cancelSem
;
void
shellQueryInterruptHandler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
)
{
void
shellQueryInterruptHandler
(
int32_t
signum
)
{
tsem_post
(
&
cancelSem
);
}
...
...
@@ -130,12 +130,10 @@ int main(int argc, char* argv[]) {
pthread_create
(
&
spid
,
NULL
,
cancelHandler
,
NULL
);
/* Interrupt handler. */
struct
sigaction
act
;
memset
(
&
act
,
0
,
sizeof
(
struct
sigaction
));
act
.
sa_handler
=
shellQueryInterruptHandler
;
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
taosSetSignal
(
SIGTERM
,
shellQueryInterruptHandler
);
taosSetSignal
(
SIGINT
,
shellQueryInterruptHandler
);
taosSetSignal
(
SIGHUP
,
shellQueryInterruptHandler
);
taosSetSignal
(
SIGABRT
,
shellQueryInterruptHandler
);
/* Get grant information */
shellGetGrantInfo
(
con
);
...
...
src/os/inc/os.h
浏览文件 @
65a28796
...
...
@@ -62,6 +62,7 @@ extern "C" {
#include "osMemory.h"
#include "osRand.h"
#include "osSemphone.h"
#include "osSignal.h"
#include "osSocket.h"
#include "osString.h"
#include "osSysinfo.h"
...
...
src/os/inc/osSignal.h
0 → 100644
浏览文件 @
65a28796
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_OS_SIGNAL_H
#define TDENGINE_OS_SIGNAL_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "os.h"
#include "taosdef.h"
#include <signal.h>
#ifndef SIGALRM
#define SIGALRM 1234
#endif
#ifndef SIGHUP
#define SIGHUP 1234
#endif
#ifndef SIGCHLD
#define SIGCHLD 1234
#endif
#ifndef SIGUSR1
#define SIGUSR1 1234
#endif
#ifndef SIGUSR2
#define SIGUSR2 1234
#endif
typedef
void
(
*
FSignalHandler
)(
int32_t
signum
);
void
taosSetSignal
(
int32_t
signum
,
FSignalHandler
sigfp
);
void
taosIgnSignal
(
int32_t
signum
);
void
taosDflSignal
(
int32_t
signum
);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_TTIME_H
src/os/inc/osWindows.h
浏览文件 @
65a28796
...
...
@@ -191,24 +191,6 @@ int gettimeofday(struct timeval *ptv, void *pTimeZone);
#define PATH_MAX 256
#endif
//for signal, not dispose
#define SIGALRM 1234
#define SIGHUP 1234
#define SIGUSR1 1234
#define SIGUSR2 1234
#define SA_SIGINFO 1234
typedef
int
sigset_t
;
typedef
struct
siginfo_t
{
int
si_pid
;
}
siginfo_t
;
struct
sigaction
{
int
sa_flags
;
void
(
*
sa_handler
)(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
void
(
*
sa_sigaction
)(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
};
int
sigaction
(
int
,
struct
sigaction
*
,
void
*
);
typedef
struct
{
int
we_wordc
;
char
**
we_wordv
;
...
...
src/os/src/detail/osSignal.c
0 → 100644
浏览文件 @
65a28796
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tulog.h"
#ifndef TAOS_OS_FUNC_SIGNAL
void
taosSetSignal
(
int32_t
signum
,
FSignalHandler
sigfp
)
{
struct
sigaction
act
=
{{
0
}};
act
.
sa_handler
=
sigfp
;
sigaction
(
signum
,
&
act
,
NULL
);
}
void
taosIgnSignal
(
int32_t
signum
)
{
signal
(
signum
,
SIG_IGN
);
}
void
taosDflSignal
(
int32_t
signum
)
{
signal
(
signum
,
SIG_DFL
);
}
#endif
src/os/src/linux/linuxEnv.c
浏览文件 @
65a28796
...
...
@@ -43,6 +43,7 @@ void osInit() {
char
cmdline
[
1024
];
char
*
taosGetCmdlineByPID
(
int
pid
)
{
#if 0
sprintf(cmdline, "/proc/%d/cmdline", pid);
FILE* f = fopen(cmdline, "r");
if (f) {
...
...
@@ -54,4 +55,7 @@ char* taosGetCmdlineByPID(int pid) {
fclose(f);
}
return cmdline;
#else
return
""
;
#endif
}
src/os/src/windows/wSysinfo.c
浏览文件 @
65a28796
...
...
@@ -235,8 +235,6 @@ int taosSystem(const char *cmd) {
int
flock
(
int
fd
,
int
option
)
{
return
0
;
}
int
sigaction
(
int
sig
,
struct
sigaction
*
d
,
void
*
p
)
{
return
0
;
}
LONG
WINAPI
FlCrashDump
(
PEXCEPTION_POINTERS
ep
)
{
typedef
BOOL
(
WINAPI
*
FxMiniDumpWriteDump
)(
IN
HANDLE
hProcess
,
IN
DWORD
ProcessId
,
IN
HANDLE
hFile
,
IN
MINIDUMP_TYPE
DumpType
,
...
...
src/sync/src/syncArbitrator.c
浏览文件 @
65a28796
...
...
@@ -27,7 +27,7 @@
#include "syncInt.h"
#include "syncTcp.h"
static
void
arbSignalHandler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
static
void
arbSignalHandler
(
int32_t
signum
);
static
void
arbProcessIncommingConnection
(
SOCKET
connFd
,
uint32_t
sourceIp
);
static
void
arbProcessBrokenLink
(
int64_t
rid
);
static
int32_t
arbProcessPeerMsg
(
int64_t
rid
,
void
*
buffer
);
...
...
@@ -69,14 +69,10 @@ int32_t main(int32_t argc, char *argv[]) {
}
/* Set termination handler. */
struct
sigaction
act
=
{{
0
}};
act
.
sa_flags
=
SA_SIGINFO
;
act
.
sa_sigaction
=
arbSignalHandler
;
act
.
sa_handler
=
arbSignalHandler
;
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGHUP
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
taosSetSignal
(
SIGTERM
,
arbSignalHandler
);
taosSetSignal
(
SIGINT
,
arbSignalHandler
);
taosSetSignal
(
SIGHUP
,
arbSignalHandler
);
taosSetSignal
(
SIGABRT
,
arbSignalHandler
);
tsAsyncLog
=
0
;
strcat
(
arbLogPath
,
"/arbitrator.log"
);
...
...
@@ -174,16 +170,13 @@ static int32_t arbProcessPeerMsg(int64_t rid, void *buffer) {
return
0
;
}
static
void
arbSignalHandler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
)
{
struct
sigaction
act
=
{{
0
}};
#ifndef WINDOWS
act
.
sa_handler
=
SIG_IGN
;
#endif
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGHUP
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
static
void
arbSignalHandler
(
int32_t
signum
)
{
taosIgnSignal
(
SIGTERM
);
taosIgnSignal
(
SIGINT
);
taosIgnSignal
(
SIGABRT
);
taosIgnSignal
(
SIGHUP
);
sInfo
(
"shut down signal is %d
, sender PID:%d"
,
signum
,
sigInfo
->
si_pid
);
sInfo
(
"shut down signal is %d
"
,
signum
);
// inform main thread to exit
tsem_post
(
&
tsArbSem
);
...
...
tests/tsim/src/simExe.c
浏览文件 @
65a28796
...
...
@@ -314,9 +314,7 @@ bool simExecuteSystemCmd(SScript *script, char *option) {
simError
(
"script:%s, failed to execute %s , code %d, errno:%d %s, repeatTimes:%d"
,
script
->
fileName
,
buf
,
code
,
errno
,
strerror
(
errno
),
repeatTimes
);
taosMsleep
(
1000
);
#ifdef LINUX
signal
(
SIGCHLD
,
SIG_DFL
);
#endif
taosDflSignal
(
SIGCHLD
);
if
(
repeatTimes
++
>=
10
)
{
exit
(
0
);
}
...
...
tests/tsim/src/simMain.c
浏览文件 @
65a28796
...
...
@@ -51,7 +51,7 @@ int32_t main(int32_t argc, char *argv[]) {
}
simInfo
(
"simulator is running ..."
);
s
ignal
(
SIGINT
,
simHandleSignal
);
taosSetS
ignal
(
SIGINT
,
simHandleSignal
);
SScript
*
script
=
simParseScript
(
scriptFile
);
if
(
script
==
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录