Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
365b9ba7
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,发现更多精彩内容 >>
未验证
提交
365b9ba7
编写于
10月 09, 2022
作者:
wafwerar
提交者:
GitHub
10月 09, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: shell source error (#17234)
上级
f298119e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
38 deletion
+34
-38
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+16
-24
source/util/src/tconfig.c
source/util/src/tconfig.c
+4
-6
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+14
-8
未找到文件。
source/os/src/osSysinfo.c
浏览文件 @
365b9ba7
...
@@ -154,8 +154,8 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
...
@@ -154,8 +154,8 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
return
-
1
;
return
-
1
;
}
}
char
*
line
=
NULL
;
char
line
[
1024
]
;
ssize_t
_bytes
=
taosGet
LineFile
(
pFile
,
&
line
);
ssize_t
_bytes
=
taosGet
sFile
(
pFile
,
sizeof
(
line
),
line
);
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
-
1
;
return
-
1
;
...
@@ -165,7 +165,6 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
...
@@ -165,7 +165,6 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
sscanf
(
line
,
"%s %"
PRIu64
" %"
PRIu64
" %"
PRIu64
" %"
PRIu64
,
cpu
,
&
cpuInfo
->
user
,
&
cpuInfo
->
nice
,
&
cpuInfo
->
system
,
sscanf
(
line
,
"%s %"
PRIu64
" %"
PRIu64
" %"
PRIu64
" %"
PRIu64
,
cpu
,
&
cpuInfo
->
user
,
&
cpuInfo
->
nice
,
&
cpuInfo
->
system
,
&
cpuInfo
->
idle
);
&
cpuInfo
->
idle
);
if
(
line
!=
NULL
)
taosMemoryFreeClear
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
#endif
#endif
return
0
;
return
0
;
...
@@ -194,8 +193,8 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
...
@@ -194,8 +193,8 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
return
-
1
;
return
-
1
;
}
}
char
*
line
=
NULL
;
char
line
[
1024
]
;
ssize_t
_bytes
=
taosGet
LineFile
(
pFile
,
&
line
);
ssize_t
_bytes
=
taosGet
sFile
(
pFile
,
sizeof
(
line
),
line
);
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
-
1
;
return
-
1
;
...
@@ -210,7 +209,6 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
...
@@ -210,7 +209,6 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
}
}
}
}
if
(
line
!=
NULL
)
taosMemoryFreeClear
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
#endif
#endif
return
0
;
return
0
;
...
@@ -286,14 +284,14 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
...
@@ -286,14 +284,14 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
snprintf
(
releaseName
,
maxLen
,
"Windows"
);
snprintf
(
releaseName
,
maxLen
,
"Windows"
);
return
0
;
return
0
;
#elif defined(_TD_DARWIN_64)
#elif defined(_TD_DARWIN_64)
char
*
line
=
NULL
;
char
line
[
1024
]
;
size_t
size
=
0
;
size_t
size
=
0
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
TdFilePtr
pFile
=
taosOpenFile
(
"/etc/os-release"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
"/etc/os-release"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
return
false
;
if
(
pFile
==
NULL
)
return
false
;
while
((
size
=
taosGet
LineFile
(
pFile
,
&
line
))
!=
-
1
)
{
while
((
size
=
taosGet
sFile
(
pFile
,
sizeof
(
line
),
line
))
!=
-
1
)
{
line
[
size
-
1
]
=
'\0'
;
line
[
size
-
1
]
=
'\0'
;
if
(
strncmp
(
line
,
"PRETTY_NAME"
,
11
)
==
0
)
{
if
(
strncmp
(
line
,
"PRETTY_NAME"
,
11
)
==
0
)
{
const
char
*
p
=
strchr
(
line
,
'='
)
+
1
;
const
char
*
p
=
strchr
(
line
,
'='
)
+
1
;
...
@@ -307,18 +305,17 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
...
@@ -307,18 +305,17 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
}
}
}
}
if
(
line
!=
NULL
)
taosMemoryFree
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
code
;
return
code
;
#else
#else
char
*
line
=
NULL
;
char
line
[
1024
]
;
size_t
size
=
0
;
size_t
size
=
0
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
TdFilePtr
pFile
=
taosOpenFile
(
"/etc/os-release"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
"/etc/os-release"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
return
false
;
if
(
pFile
==
NULL
)
return
false
;
while
((
size
=
taosGet
LineFile
(
pFile
,
&
line
))
!=
-
1
)
{
while
((
size
=
taosGet
sFile
(
pFile
,
sizeof
(
line
),
line
))
!=
-
1
)
{
line
[
size
-
1
]
=
'\0'
;
line
[
size
-
1
]
=
'\0'
;
if
(
strncmp
(
line
,
"PRETTY_NAME"
,
11
)
==
0
)
{
if
(
strncmp
(
line
,
"PRETTY_NAME"
,
11
)
==
0
)
{
const
char
*
p
=
strchr
(
line
,
'='
)
+
1
;
const
char
*
p
=
strchr
(
line
,
'='
)
+
1
;
...
@@ -332,7 +329,6 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
...
@@ -332,7 +329,6 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
}
}
}
}
if
(
line
!=
NULL
)
taosMemoryFree
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
code
;
return
code
;
#endif
#endif
...
@@ -374,7 +370,7 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
...
@@ -374,7 +370,7 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
return
code
;
return
code
;
#else
#else
char
*
line
=
NULL
;
char
line
[
1024
]
;
size_t
size
=
0
;
size_t
size
=
0
;
int32_t
done
=
0
;
int32_t
done
=
0
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
...
@@ -383,7 +379,7 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
...
@@ -383,7 +379,7 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
TdFilePtr
pFile
=
taosOpenFile
(
"/proc/cpuinfo"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
"/proc/cpuinfo"
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
return
code
;
if
(
pFile
==
NULL
)
return
code
;
while
(
done
!=
3
&&
(
size
=
taosGet
LineFile
(
pFile
,
&
line
))
!=
-
1
)
{
while
(
done
!=
3
&&
(
size
=
taosGet
sFile
(
pFile
,
sizeof
(
line
),
line
))
!=
-
1
)
{
line
[
size
-
1
]
=
'\0'
;
line
[
size
-
1
]
=
'\0'
;
if
(((
done
&
1
)
==
0
)
&&
strncmp
(
line
,
"model name"
,
10
)
==
0
)
{
if
(((
done
&
1
)
==
0
)
&&
strncmp
(
line
,
"model name"
,
10
)
==
0
)
{
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
const
char
*
v
=
strchr
(
line
,
':'
)
+
2
;
...
@@ -398,7 +394,6 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
...
@@ -398,7 +394,6 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
if
(
strncmp
(
line
,
"processor"
,
9
)
==
0
)
coreCount
+=
1
;
if
(
strncmp
(
line
,
"processor"
,
9
)
==
0
)
coreCount
+=
1
;
}
}
if
(
line
!=
NULL
)
taosMemoryFree
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
if
(
code
!=
0
&&
(
done
&
1
)
==
0
)
{
if
(
code
!=
0
&&
(
done
&
1
)
==
0
)
{
...
@@ -517,9 +512,9 @@ int32_t taosGetProcMemory(int64_t *usedKB) {
...
@@ -517,9 +512,9 @@ int32_t taosGetProcMemory(int64_t *usedKB) {
}
}
ssize_t
_bytes
=
0
;
ssize_t
_bytes
=
0
;
char
*
line
=
NULL
;
char
line
[
1024
]
;
while
(
!
taosEOFFile
(
pFile
))
{
while
(
!
taosEOFFile
(
pFile
))
{
_bytes
=
taosGet
LineFile
(
pFile
,
&
line
);
_bytes
=
taosGet
sFile
(
pFile
,
sizeof
(
line
),
line
);
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
if
((
_bytes
<
0
)
||
(
line
==
NULL
))
{
break
;
break
;
}
}
...
@@ -537,7 +532,6 @@ int32_t taosGetProcMemory(int64_t *usedKB) {
...
@@ -537,7 +532,6 @@ int32_t taosGetProcMemory(int64_t *usedKB) {
char
tmp
[
10
];
char
tmp
[
10
];
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
usedKB
);
sscanf
(
line
,
"%s %"
PRId64
,
tmp
,
usedKB
);
if
(
line
!=
NULL
)
taosMemoryFreeClear
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
0
;
return
0
;
#endif
#endif
...
@@ -631,12 +625,12 @@ int32_t taosGetProcIO(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int
...
@@ -631,12 +625,12 @@ int32_t taosGetProcIO(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int
if
(
pFile
==
NULL
)
return
-
1
;
if
(
pFile
==
NULL
)
return
-
1
;
ssize_t
_bytes
=
0
;
ssize_t
_bytes
=
0
;
char
*
line
=
NULL
;
char
line
[
1024
]
;
char
tmp
[
24
];
char
tmp
[
24
];
int
readIndex
=
0
;
int
readIndex
=
0
;
while
(
!
taosEOFFile
(
pFile
))
{
while
(
!
taosEOFFile
(
pFile
))
{
_bytes
=
taosGet
LineFile
(
pFile
,
&
line
);
_bytes
=
taosGet
sFile
(
pFile
,
sizeof
(
line
),
line
);
if
(
_bytes
<
10
||
line
==
NULL
)
{
if
(
_bytes
<
10
||
line
==
NULL
)
{
break
;
break
;
}
}
...
@@ -658,7 +652,6 @@ int32_t taosGetProcIO(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int
...
@@ -658,7 +652,6 @@ int32_t taosGetProcIO(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, int
if
(
readIndex
>=
4
)
break
;
if
(
readIndex
>=
4
)
break
;
}
}
if
(
line
!=
NULL
)
taosMemoryFreeClear
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
if
(
readIndex
<
4
)
{
if
(
readIndex
<
4
)
{
...
@@ -709,7 +702,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
...
@@ -709,7 +702,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
if
(
pFile
==
NULL
)
return
-
1
;
if
(
pFile
==
NULL
)
return
-
1
;
ssize_t
_bytes
=
0
;
ssize_t
_bytes
=
0
;
char
*
line
=
NULL
;
char
line
[
1024
]
;
while
(
!
taosEOFFile
(
pFile
))
{
while
(
!
taosEOFFile
(
pFile
))
{
int64_t
o_rbytes
=
0
;
int64_t
o_rbytes
=
0
;
...
@@ -724,7 +717,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
...
@@ -724,7 +717,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
int64_t
nouse6
=
0
;
int64_t
nouse6
=
0
;
char
nouse0
[
200
]
=
{
0
};
char
nouse0
[
200
]
=
{
0
};
_bytes
=
taosGet
LineFile
(
pFile
,
&
line
);
_bytes
=
taosGet
sFile
(
pFile
,
sizeof
(
line
),
line
);
if
(
_bytes
<
0
)
{
if
(
_bytes
<
0
)
{
break
;
break
;
}
}
...
@@ -743,7 +736,6 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
...
@@ -743,7 +736,6 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
*
transmit_bytes
=
o_tbytes
;
*
transmit_bytes
=
o_tbytes
;
}
}
if
(
line
!=
NULL
)
taosMemoryFreeClear
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
0
;
return
0
;
...
...
source/util/src/tconfig.c
浏览文件 @
365b9ba7
...
@@ -714,7 +714,7 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) {
...
@@ -714,7 +714,7 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) {
}
}
int32_t
cfgLoadFromEnvFile
(
SConfig
*
pConfig
,
const
char
*
envFile
)
{
int32_t
cfgLoadFromEnvFile
(
SConfig
*
pConfig
,
const
char
*
envFile
)
{
char
*
line
=
NULL
,
*
name
,
*
value
,
*
value2
,
*
value3
;
char
line
[
1024
]
,
*
name
,
*
value
,
*
value2
,
*
value3
;
int32_t
olen
,
vlen
,
vlen2
,
vlen3
;
int32_t
olen
,
vlen
,
vlen2
,
vlen3
;
int32_t
code
=
0
;
int32_t
code
=
0
;
ssize_t
_bytes
=
0
;
ssize_t
_bytes
=
0
;
...
@@ -743,7 +743,7 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
...
@@ -743,7 +743,7 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
name
=
value
=
value2
=
value3
=
NULL
;
name
=
value
=
value2
=
value3
=
NULL
;
olen
=
vlen
=
vlen2
=
vlen3
=
0
;
olen
=
vlen
=
vlen2
=
vlen3
=
0
;
_bytes
=
taosGet
LineFile
(
pFile
,
&
line
);
_bytes
=
taosGet
sFile
(
pFile
,
sizeof
(
line
),
line
);
if
(
_bytes
<=
0
)
{
if
(
_bytes
<=
0
)
{
break
;
break
;
}
}
...
@@ -775,14 +775,13 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
...
@@ -775,14 +775,13 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
}
}
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
if
(
line
!=
NULL
)
taosMemoryFreeClear
(
line
);
uInfo
(
"load from env cfg file %s success"
,
filepath
);
uInfo
(
"load from env cfg file %s success"
,
filepath
);
return
0
;
return
0
;
}
}
int32_t
cfgLoadFromCfgFile
(
SConfig
*
pConfig
,
const
char
*
filepath
)
{
int32_t
cfgLoadFromCfgFile
(
SConfig
*
pConfig
,
const
char
*
filepath
)
{
char
*
line
=
NULL
,
*
name
,
*
value
,
*
value2
,
*
value3
;
char
line
[
1024
]
,
*
name
,
*
value
,
*
value2
,
*
value3
;
int32_t
olen
,
vlen
,
vlen2
,
vlen3
;
int32_t
olen
,
vlen
,
vlen2
,
vlen3
;
ssize_t
_bytes
=
0
;
ssize_t
_bytes
=
0
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -804,7 +803,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
...
@@ -804,7 +803,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
name
=
value
=
value2
=
value3
=
NULL
;
name
=
value
=
value2
=
value3
=
NULL
;
olen
=
vlen
=
vlen2
=
vlen3
=
0
;
olen
=
vlen
=
vlen2
=
vlen3
=
0
;
_bytes
=
taosGet
LineFile
(
pFile
,
&
line
);
_bytes
=
taosGet
sFile
(
pFile
,
sizeof
(
line
),
line
);
if
(
_bytes
<=
0
)
{
if
(
_bytes
<=
0
)
{
break
;
break
;
}
}
...
@@ -836,7 +835,6 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
...
@@ -836,7 +835,6 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
}
}
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
if
(
line
!=
NULL
)
taosMemoryFreeClear
(
line
);
if
(
code
==
0
||
(
code
!=
0
&&
terrno
==
TSDB_CODE_CFG_NOT_FOUND
))
{
if
(
code
==
0
||
(
code
!=
0
&&
terrno
==
TSDB_CODE_CFG_NOT_FOUND
))
{
uInfo
(
"load from cfg file %s success"
,
filepath
);
uInfo
(
"load from cfg file %s success"
,
filepath
);
...
...
tools/shell/src/shellEngine.c
浏览文件 @
365b9ba7
...
@@ -88,9 +88,15 @@ int32_t shellRunSingleCommand(char *command) {
...
@@ -88,9 +88,15 @@ int32_t shellRunSingleCommand(char *command) {
if
(
shellRegexMatch
(
command
,
"^[
\t
]*source[
\t
]+[^ ]+[
\t
;]*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
if
(
shellRegexMatch
(
command
,
"^[
\t
]*source[
\t
]+[^ ]+[
\t
;]*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
/* If source file. */
/* If source file. */
char
*
c_ptr
=
strtok
(
command
,
" ;"
);
char
*
c_ptr
=
strtok
(
command
,
" ;"
);
assert
(
c_ptr
!=
NULL
);
if
(
c_ptr
==
NULL
)
{
shellRunSingleCommandImp
(
command
);
return
0
;
}
c_ptr
=
strtok
(
NULL
,
" ;"
);
c_ptr
=
strtok
(
NULL
,
" ;"
);
assert
(
c_ptr
!=
NULL
);
if
(
c_ptr
==
NULL
)
{
shellRunSingleCommandImp
(
command
);
return
0
;
}
shellSourceFile
(
c_ptr
);
shellSourceFile
(
c_ptr
);
return
0
;
return
0
;
}
}
...
@@ -781,9 +787,9 @@ void shellReadHistory() {
...
@@ -781,9 +787,9 @@ void shellReadHistory() {
TdFilePtr
pFile
=
taosOpenFile
(
pHistory
->
file
,
TD_FILE_READ
|
TD_FILE_STREAM
);
TdFilePtr
pFile
=
taosOpenFile
(
pHistory
->
file
,
TD_FILE_READ
|
TD_FILE_STREAM
);
if
(
pFile
==
NULL
)
return
;
if
(
pFile
==
NULL
)
return
;
char
*
line
=
NULL
;
char
*
line
=
taosMemoryMalloc
(
TSDB_MAX_ALLOWED_SQL_LEN
+
1
)
;
int32_t
read_size
=
0
;
int32_t
read_size
=
0
;
while
((
read_size
=
taosGet
LineFile
(
pFile
,
&
line
))
!=
-
1
)
{
while
((
read_size
=
taosGet
sFile
(
pFile
,
TSDB_MAX_ALLOWED_SQL_LEN
,
line
))
!=
-
1
)
{
line
[
read_size
-
1
]
=
'\0'
;
line
[
read_size
-
1
]
=
'\0'
;
taosMemoryFree
(
pHistory
->
hist
[
pHistory
->
hend
]);
taosMemoryFree
(
pHistory
->
hist
[
pHistory
->
hend
]);
pHistory
->
hist
[
pHistory
->
hend
]
=
strdup
(
line
);
pHistory
->
hist
[
pHistory
->
hend
]
=
strdup
(
line
);
...
@@ -795,7 +801,7 @@ void shellReadHistory() {
...
@@ -795,7 +801,7 @@ void shellReadHistory() {
}
}
}
}
if
(
line
!=
NULL
)
taosMemoryFree
(
line
);
taosMemoryFreeClear
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
int64_t
file_size
;
int64_t
file_size
;
if
(
taosStatFile
(
pHistory
->
file
,
&
file_size
,
NULL
)
==
0
&&
file_size
>
SHELL_MAX_COMMAND_SIZE
)
{
if
(
taosStatFile
(
pHistory
->
file
,
&
file_size
,
NULL
)
==
0
&&
file_size
>
SHELL_MAX_COMMAND_SIZE
)
{
...
@@ -859,7 +865,6 @@ void shellSourceFile(const char *file) {
...
@@ -859,7 +865,6 @@ void shellSourceFile(const char *file) {
int32_t
read_len
=
0
;
int32_t
read_len
=
0
;
char
*
cmd
=
taosMemoryCalloc
(
1
,
TSDB_MAX_ALLOWED_SQL_LEN
+
1
);
char
*
cmd
=
taosMemoryCalloc
(
1
,
TSDB_MAX_ALLOWED_SQL_LEN
+
1
);
size_t
cmd_len
=
0
;
size_t
cmd_len
=
0
;
char
*
line
=
NULL
;
char
fullname
[
PATH_MAX
]
=
{
0
};
char
fullname
[
PATH_MAX
]
=
{
0
};
char
sourceFileCommand
[
PATH_MAX
+
8
]
=
{
0
};
char
sourceFileCommand
[
PATH_MAX
+
8
]
=
{
0
};
...
@@ -877,7 +882,8 @@ void shellSourceFile(const char *file) {
...
@@ -877,7 +882,8 @@ void shellSourceFile(const char *file) {
return
;
return
;
}
}
while
((
read_len
=
taosGetLineFile
(
pFile
,
&
line
))
!=
-
1
)
{
char
*
line
=
taosMemoryMalloc
(
TSDB_MAX_ALLOWED_SQL_LEN
+
1
);
while
((
read_len
=
taosGetsFile
(
pFile
,
TSDB_MAX_ALLOWED_SQL_LEN
,
line
))
!=
-
1
)
{
if
(
read_len
>=
TSDB_MAX_ALLOWED_SQL_LEN
)
continue
;
if
(
read_len
>=
TSDB_MAX_ALLOWED_SQL_LEN
)
continue
;
line
[
--
read_len
]
=
'\0'
;
line
[
--
read_len
]
=
'\0'
;
...
@@ -904,7 +910,7 @@ void shellSourceFile(const char *file) {
...
@@ -904,7 +910,7 @@ void shellSourceFile(const char *file) {
}
}
taosMemoryFree
(
cmd
);
taosMemoryFree
(
cmd
);
if
(
line
!=
NULL
)
taosMemoryFree
(
line
);
taosMemoryFreeClear
(
line
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录