Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
oceanbase
obproxy
提交
db9b7c9a
O
obproxy
项目概览
oceanbase
/
obproxy
1 年多 前同步成功
通知
11
Star
100
Fork
70
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obproxy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
db9b7c9a
编写于
6月 05, 2021
作者:
W
wgs13579
提交者:
guangshu.wgs
6月 07, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix coverity bug
上级
5d57e2ad
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
78 addition
and
171 deletion
+78
-171
src/obproxy/obutils/ob_config_server_processor.cpp
src/obproxy/obutils/ob_config_server_processor.cpp
+2
-2
src/obproxy/obutils/ob_hot_upgrade_processor.cpp
src/obproxy/obutils/ob_hot_upgrade_processor.cpp
+45
-41
src/obproxy/obutils/ob_proxy_config_utils.cpp
src/obproxy/obutils/ob_proxy_config_utils.cpp
+2
-2
src/obproxy/opsql/Makemodule.am
src/obproxy/opsql/Makemodule.am
+1
-3
src/obproxy/opsql/expr_resolver/ob_proxy_obj_caster.cpp
src/obproxy/opsql/expr_resolver/ob_proxy_obj_caster.cpp
+0
-37
src/obproxy/opsql/expr_resolver/ob_proxy_obj_caster.h
src/obproxy/opsql/expr_resolver/ob_proxy_obj_caster.h
+0
-43
unittest/obproxy/foo_server.cpp
unittest/obproxy/foo_server.cpp
+4
-1
unittest/obproxy/ob_expr_parser_checker.cpp
unittest/obproxy/ob_expr_parser_checker.cpp
+1
-0
unittest/obproxy/ob_func_expr_parser_checker.cpp
unittest/obproxy/ob_func_expr_parser_checker.cpp
+1
-0
unittest/obproxy/obproxy_parser_test.cpp
unittest/obproxy/obproxy_parser_test.cpp
+1
-0
unittest/obproxy/test_config_server_processor.cpp
unittest/obproxy/test_config_server_processor.cpp
+9
-3
unittest/obproxy/test_fast_zlib_stream_compressor.cpp
unittest/obproxy/test_fast_zlib_stream_compressor.cpp
+6
-20
unittest/obproxy/test_io_buffer.cpp
unittest/obproxy/test_io_buffer.cpp
+1
-3
unittest/obproxy/test_mysql_transaction_analyzer.cpp
unittest/obproxy/test_mysql_transaction_analyzer.cpp
+1
-2
unittest/obproxy/test_zlib_stream_compressor.cpp
unittest/obproxy/test_zlib_stream_compressor.cpp
+4
-14
未找到文件。
src/obproxy/obutils/ob_config_server_processor.cpp
浏览文件 @
db9b7c9a
...
...
@@ -938,7 +938,7 @@ int ObConfigServerProcessor::do_fetch_proxy_bin(const char *bin_save_path, const
LOG_WARN
(
"fail to fetch new proxy bin"
,
K
(
bin_url
),
K
(
bin_save_path
),
K
(
ret
));
}
else
{
}
if
(
fd
>
0
)
{
if
(
fd
>
=
0
)
{
::
close
(
fd
);
}
}
...
...
@@ -1085,7 +1085,7 @@ int ObConfigServerProcessor::get_kernel_release_by_redhat(ObProxyKernelRelease &
"release"
,
get_kernel_release_string
(
release
));
}
if
(
fd
>
0
)
{
if
(
fd
>
=
0
)
{
::
close
(
fd
);
}
return
ret
;
...
...
src/obproxy/obutils/ob_hot_upgrade_processor.cpp
浏览文件 @
db9b7c9a
...
...
@@ -223,28 +223,30 @@ int get_binary_md5(const char *binary, char *md5_buf, const int64_t md5_buf_len)
}
else
if
(
OB_UNLIKELY
(
0
!=
sigaction
(
SIGCHLD
,
&
action
,
&
old_action
)))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"fail to sigaction SIGCHLD"
,
KERRMSGS
,
K
(
ret
));
}
else
if
(
OB_ISNULL
((
fp
=
popen
(
shell_str
,
"r"
))))
{
ret
=
ob_get_sys_errno
();
LOG_WARN
(
"failed to popen fp"
,
K
(
shell_str
),
K
(
binary
),
KERRMSGS
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
fgets
(
md5_buf
,
static_cast
<
int32_t
>
(
md5_buf_len
),
fp
)))
{
ret
=
ob_get_sys_errno
();
LOG_WARN
(
"fail to fgets md5_str"
,
K
(
shell_str
),
K
(
md5_buf
),
KERRMSGS
,
K
(
ret
));
}
else
{
LOG_INFO
(
"succeed to get binary md5"
,
K
(
shell_str
),
K
(
md5_buf
),
K
(
md5_buf_len
));
}
if
(
OB_LIKELY
(
NULL
!=
fp
))
{
if
(
-
1
==
pclose
(
fp
))
{
if
(
OB_ISNULL
((
fp
=
popen
(
shell_str
,
"r"
))))
{
ret
=
ob_get_sys_errno
();
LOG_WARN
(
"failed to pclose fp"
,
K
(
fp
),
KERRMSGS
,
K
(
ret
));
LOG_WARN
(
"failed to popen fp"
,
K
(
shell_str
),
K
(
binary
),
KERRMSGS
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
fgets
(
md5_buf
,
static_cast
<
int32_t
>
(
md5_buf_len
),
fp
)))
{
ret
=
ob_get_sys_errno
();
LOG_WARN
(
"fail to fgets md5_str"
,
K
(
shell_str
),
K
(
md5_buf
),
KERRMSGS
,
K
(
ret
));
}
else
{
fp
=
NULL
;
LOG_INFO
(
"succeed to get binary md5"
,
K
(
shell_str
),
K
(
md5_buf
),
K
(
md5_buf_len
))
;
}
}
if
(
OB_UNLIKELY
(
0
!=
sigaction
(
SIGCHLD
,
&
old_action
,
NULL
)))
{
//reset it
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"fail to sigaction SIGCHLD"
,
KERRMSGS
,
K
(
ret
));
if
(
OB_LIKELY
(
NULL
!=
fp
))
{
if
(
-
1
==
pclose
(
fp
))
{
ret
=
ob_get_sys_errno
();
LOG_WARN
(
"failed to pclose fp"
,
K
(
fp
),
KERRMSGS
,
K
(
ret
));
}
else
{
fp
=
NULL
;
}
}
if
(
OB_UNLIKELY
(
0
!=
sigaction
(
SIGCHLD
,
&
old_action
,
NULL
)))
{
//reset it
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"fail to sigaction SIGCHLD"
,
KERRMSGS
,
K
(
ret
));
}
}
}
...
...
@@ -588,37 +590,39 @@ int ObHotUpgradeProcessor::check_proxy_bin_release(const char *binary)
}
else
if
(
OB_UNLIKELY
(
0
!=
sigaction
(
SIGCHLD
,
&
action
,
&
old_action
)))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"fail to sigaction SIGCHLD"
,
KERRMSGS
,
K
(
ret
));
}
else
if
(
OB_ISNULL
((
fp
=
popen
(
shell_str
,
"r"
))))
{
ret
=
ob_get_sys_errno
();
LOG_WARN
(
"failed to popen fp"
,
K
(
shell_str
),
K
(
binary
),
KERRMSGS
,
K
(
ret
));
}
else
{
char
*
result_buf
=
shell_str
;
MEMSET
(
result_buf
,
0
,
MAX_SHELL_STR_LENGTH
);
fgets
(
result_buf
,
static_cast
<
int32_t
>
(
MAX_SHELL_STR_LENGTH
),
fp
);
if
(
0
!=
STRLEN
(
result_buf
)
&&
(
NULL
!=
strstr
(
result_buf
,
".el"
)
||
NULL
!=
strstr
(
result_buf
,
".alios"
)))
{
if
(
OB_FAIL
(
get_global_config_server_processor
().
check_kernel_release
(
result_buf
)))
{
LOG_WARN
(
"failed to parser linux kernel release in result_buf"
,
K
(
result_buf
),
K
(
ret
));
if
(
OB_ISNULL
((
fp
=
popen
(
shell_str
,
"r"
))))
{
ret
=
ob_get_sys_errno
();
LOG_WARN
(
"failed to popen fp"
,
K
(
shell_str
),
K
(
binary
),
KERRMSGS
,
K
(
ret
));
}
else
{
char
*
result_buf
=
shell_str
;
MEMSET
(
result_buf
,
0
,
MAX_SHELL_STR_LENGTH
);
fgets
(
result_buf
,
static_cast
<
int32_t
>
(
MAX_SHELL_STR_LENGTH
),
fp
);
if
(
0
!=
STRLEN
(
result_buf
)
&&
(
NULL
!=
strstr
(
result_buf
,
".el"
)
||
NULL
!=
strstr
(
result_buf
,
".alios"
)))
{
if
(
OB_FAIL
(
get_global_config_server_processor
().
check_kernel_release
(
result_buf
)))
{
LOG_WARN
(
"failed to parser linux kernel release in result_buf"
,
K
(
result_buf
),
K
(
ret
));
}
else
{
LOG_INFO
(
"succeed to check proxy binary release"
,
K
(
result_buf
));
}
}
else
{
LOG_INFO
(
"
succeed to check proxy binary release
"
,
K
(
result_buf
));
LOG_INFO
(
"
maybe upgrade to old proxy, treat it succ
"
,
K
(
result_buf
));
}
}
else
{
LOG_INFO
(
"maybe upgrade to old proxy, treat it succ"
,
K
(
result_buf
));
}
}
if
(
OB_LIKELY
(
NULL
!=
fp
))
{
if
(
-
1
==
pclose
(
fp
))
{
ret
=
ob_get_sys_errno
();
LOG_WARN
(
"failed to pclose fp"
,
K
(
fp
),
KERRMSGS
,
K
(
ret
));
}
else
{
fp
=
NULL
;
if
(
OB_LIKELY
(
NULL
!=
fp
))
{
if
(
-
1
==
pclose
(
fp
))
{
ret
=
ob_get_sys_errno
();
LOG_WARN
(
"failed to pclose fp"
,
K
(
fp
),
KERRMSGS
,
K
(
ret
));
}
else
{
fp
=
NULL
;
}
}
}
if
(
OB_UNLIKELY
(
0
!=
sigaction
(
SIGCHLD
,
&
old_action
,
NULL
)))
{
//reset it
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"fail to sigaction SIGCHLD"
,
KERRMSGS
,
K
(
ret
));
if
(
OB_UNLIKELY
(
0
!=
sigaction
(
SIGCHLD
,
&
old_action
,
NULL
)))
{
//reset it
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"fail to sigaction SIGCHLD"
,
KERRMSGS
,
K
(
ret
));
}
}
if
(
NULL
!=
shell_str
)
{
...
...
src/obproxy/obutils/ob_proxy_config_utils.cpp
浏览文件 @
db9b7c9a
...
...
@@ -708,7 +708,7 @@ int ObProxyFileUtils::write_and_backup_file(const char *path, const char *tmp_pa
}
}
}
if
(
fd
>
0
)
{
if
(
fd
>
=
0
)
{
::
close
(
fd
);
}
}
...
...
@@ -792,7 +792,7 @@ int ObProxyFileUtils::read_from_file(const char *dir, const char *file_name,
}
else
if
(
OB_LIKELY
(
read_len
<
len
))
{
buf
[
read_len
]
=
'\0'
;
}
if
(
fd
>
0
)
::
close
(
fd
);
if
(
fd
>
=
0
)
::
close
(
fd
);
}
}
...
...
src/obproxy/opsql/Makemodule.am
浏览文件 @
db9b7c9a
...
...
@@ -29,9 +29,7 @@ obproxy/opsql/expr_parser/ob_expr_parser.h
opsql_expr_resolver_sources:=\
obproxy/opsql/expr_resolver/ob_expr_resolver.h\
obproxy/opsql/expr_resolver/ob_expr_resolver.cpp\
obproxy/opsql/expr_resolver/ob_proxy_obj_caster.h\
obproxy/opsql/expr_resolver/ob_proxy_obj_caster.cpp
obproxy/opsql/expr_resolver/ob_expr_resolver.cpp
opsql_func_expr_parser_sources:=\
obproxy/opsql/func_expr_parser/ob_func_expr_parser_lex.c\
...
...
src/obproxy/opsql/expr_resolver/ob_proxy_obj_caster.cpp
已删除
100644 → 0
浏览文件 @
5d57e2ad
/**
* Copyright (c) 2021 OceanBase
* OceanBase Database Proxy(ODP) is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#include "opsql/expr_resolver/ob_proxy_obj_caster.h"
using
namespace
oceanbase
::
common
;
namespace
oceanbase
{
namespace
obproxy
{
namespace
opsql
{
ObProxyObjCaster
::
ObProxyObjCaster
(
ObIAllocator
&
allocator
)
:
allocator_
(
allocator
)
,
casted_cell_
()
,
cast_ctx_
(
&
allocator_
,
NULL
,
CM_NONE
,
CS_TYPE_UTF8MB4_GENERAL_CI
)
{
}
int
ObProxyObjCaster
::
cast
(
const
ObObj
orig_obj
,
const
ObObjType
expect_type
,
const
ObObj
*&
res_obj
)
{
return
ObObjCasterV2
::
to_type
(
expect_type
,
cast_ctx_
,
orig_obj
,
casted_cell_
,
res_obj
);
}
}
// end of opsql
}
// end of obproxy
}
// end of oceanbase
src/obproxy/opsql/expr_resolver/ob_proxy_obj_caster.h
已删除
100644 → 0
浏览文件 @
5d57e2ad
/**
* Copyright (c) 2021 OceanBase
* OceanBase Database Proxy(ODP) is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#ifndef OBPROXY_OBJ_CASTER_H
#define OBPROXY_OBJ_CASTER_H
#include "common/ob_object.h"
#include "common/ob_obj_cast.h"
namespace
oceanbase
{
namespace
common
{
class
ObIAllocator
;
}
namespace
obproxy
{
namespace
opsql
{
class
ObProxyObjCaster
{
public:
explicit
ObProxyObjCaster
(
common
::
ObIAllocator
&
allocator
);
int
cast
(
const
common
::
ObObj
orig_obj
,
const
common
::
ObObjType
expect_type
,
const
common
::
ObObj
*&
res_obj
);
private:
common
::
ObIAllocator
&
allocator_
;
common
::
ObObj
casted_cell_
;
common
::
ObCastCtx
cast_ctx_
;
};
}
// end of namespace opsql
}
// end of namespace obproxy
}
// end of namespace oceanbase
#endif // OBPROXY_OBJ_CASTER_H
unittest/obproxy/foo_server.cpp
浏览文件 @
db9b7c9a
...
...
@@ -142,8 +142,11 @@ void FooServer::run()
}
memset
(
line
,
0
,
MAX_LINE
);
total_size
=
0
;
while
((
read_size
=
read
(
sock_fd
,
line
+
total_size
,
MAX_LINE
))
>
0
)
{
while
((
read_size
=
read
(
sock_fd
,
line
+
total_size
,
MAX_LINE
-
total_size
))
>
0
)
{
total_size
+=
read_size
;
if
(
total_size
>=
MAX_LINE
)
{
break
;
}
}
if
(
total_size
==
0
)
{
...
...
unittest/obproxy/ob_expr_parser_checker.cpp
浏览文件 @
db9b7c9a
...
...
@@ -85,6 +85,7 @@ ObProxyParseString ObExprParserChecker::get_value(std::string &extra_str, const
std
::
size_t
&
pos
)
{
ObProxyParseString
ret_str
;
memset
(
&
ret_str
,
0
,
sizeof
(
ObProxyParseString
));
ret_str
.
str_len_
=
0
;
std
::
size_t
key_index
=
extra_str
.
find
(
key_name
,
pos
);
if
(
key_index
!=
std
::
string
::
npos
)
{
...
...
unittest/obproxy/ob_func_expr_parser_checker.cpp
浏览文件 @
db9b7c9a
...
...
@@ -63,6 +63,7 @@ ObProxyParseString ObFuncExprParserChecker::get_value(std::string &extra_str, co
std
::
size_t
&
pos
)
{
ObProxyParseString
ret_str
;
memset
(
&
ret_str
,
0
,
sizeof
(
ObProxyParseString
));
ret_str
.
str_len_
=
0
;
std
::
size_t
key_index
=
extra_str
.
find
(
key_name
,
pos
);
if
(
key_index
!=
std
::
string
::
npos
)
{
...
...
unittest/obproxy/obproxy_parser_test.cpp
浏览文件 @
db9b7c9a
...
...
@@ -106,6 +106,7 @@ void do_parser_test(ObProxyMysqlRequest& client_request, std::string query_str)
ObProxyParseString
get_value
(
std
::
string
&
extra_str
,
const
char
*
key_name
,
std
::
size_t
&
pos
)
{
ObProxyParseString
ret_str
;
memset
(
&
ret_str
,
0
,
sizeof
(
ObProxyParseString
));
ret_str
.
str_len_
=
0
;
std
::
size_t
key_index
=
extra_str
.
find
(
key_name
,
pos
);
if
(
key_index
!=
std
::
string
::
npos
)
{
...
...
unittest/obproxy/test_config_server_processor.cpp
浏览文件 @
db9b7c9a
...
...
@@ -289,14 +289,17 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_proxy_bin)
//test short timeout
const
char
*
bin_url
=
""
;
int
fd
=
0
;
int
fd
=
-
1
;
if
((
fd
=
::
open
(
save_path
,
O_WRONLY
|
O_CREAT
,
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
|
S_IROTH
))
>
0
)
{
ret
=
config_processor_
.
fetch_by_curl
(
bin_url
,
1L
,
reinterpret_cast
<
void
*>
(
fd
),
config_processor_
.
write_proxy_bin
);
}
if
(
fd
>
0
)
close
(
fd
);
if
(
fd
>=
0
)
{
close
(
fd
);
fd
=
-
1
;
}
ASSERT_EQ
(
OB_CURL_ERROR
,
ret
);
remove
(
save_path
);
...
...
@@ -310,7 +313,10 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_proxy_bin)
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
|
S_IROTH
))
>
0
)
{
ret
=
config_processor_
.
fetch_by_curl
(
wrong_bin_url
,
fetch_timeout
,
reinterpret_cast
<
void
*>
((
int64_t
)
fd
),
config_processor_
.
write_proxy_bin
);
}
if
(
fd
>
0
)
close
(
fd
);
if
(
fd
>=
0
)
{
close
(
fd
);
fd
=
-
1
;
}
ASSERT_EQ
(
OB_CURL_ERROR
,
ret
);
remove
(
save_path
);
...
...
unittest/obproxy/test_fast_zlib_stream_compressor.cpp
浏览文件 @
db9b7c9a
...
...
@@ -35,9 +35,9 @@ TEST_F(TestFastZlibStreamCompressor, test_simple)
ObFastZlibStreamCompressor
compressor1
;
int
ret
=
OB_SUCCESS
;
int64_t
buff_len
=
1024
*
1024
;
char
*
src_buf
=
new
char
[
buff_len
]
;
char
*
second_src_buf
=
new
char
[
buff_len
]
;
char
*
compress_buf
=
new
char
[
buff_len
]
;
char
src_buf
[
buff_len
]
=
"
\0
"
;
char
second_src_buf
[
buff_len
]
=
"
\0
"
;
char
compress_buf
[
buff_len
]
=
"
\0
"
;
int64_t
src_len
=
0
;
int64_t
filled_len
=
0
;
int64_t
filled_len2
=
0
;
...
...
@@ -76,13 +76,6 @@ TEST_F(TestFastZlibStreamCompressor, test_simple)
LOG_INFO
(
"one shot"
,
K
(
src_len
),
K
(
total_filled_len
),
K
(
filled_len2
));
}
delete
[]
src_buf
;
src_buf
=
NULL
;
delete
[]
second_src_buf
;
second_src_buf
=
NULL
;
delete
[]
compress_buf
;
compress_buf
=
NULL
;
};
TEST_F
(
TestFastZlibStreamCompressor
,
test_speed
)
...
...
@@ -93,9 +86,9 @@ TEST_F(TestFastZlibStreamCompressor, test_speed)
int
ret
=
OB_SUCCESS
;
int64_t
run_count
=
1000
;
int64_t
buff_len
=
8
*
1024
*
1024
;
char
*
src_buf
=
new
char
[
buff_len
]
;
char
*
second_src_buf
=
new
char
[
buff_len
]
;
char
*
compress_buf
=
new
char
[
buff_len
]
;
char
src_buf
[
buff_len
]
=
"
\0
"
;
char
second_src_buf
[
buff_len
]
=
"
\0
"
;
char
compress_buf
[
buff_len
]
=
"
\0
"
;
int64_t
src_len
=
0
;
int64_t
filled_len
=
0
;
int64_t
filled_len2
=
0
;
...
...
@@ -147,13 +140,6 @@ TEST_F(TestFastZlibStreamCompressor, test_speed)
"standard level0 compress cost"
,
cost_time_us3
,
"standard level6 compress cost"
,
cost_time_us4
);
}
delete
[]
src_buf
;
src_buf
=
NULL
;
delete
[]
second_src_buf
;
second_src_buf
=
NULL
;
delete
[]
compress_buf
;
compress_buf
=
NULL
;
};
...
...
unittest/obproxy/test_io_buffer.cpp
浏览文件 @
db9b7c9a
...
...
@@ -610,7 +610,7 @@ TEST_F(TestIOBuffer, test_OBMIOBufferReader_replace_with_char)
ASSERT_EQ
(
4
,
reader
->
get_block_count
());
ASSERT_EQ
(
g_size
,
reader
->
read_avail
());
char
*
target_buf
=
new
(
std
::
nothrow
)
char
[
g_size
]
;
char
target_buf
[
g_size
]
=
"
\0
"
;
char
mark
=
'*'
;
memset
(
target_buf
,
mark
,
g_size
);
...
...
@@ -624,8 +624,6 @@ TEST_F(TestIOBuffer, test_OBMIOBufferReader_replace_with_char)
ASSERT_EQ
(
0
,
memcmp
(
target_buf
,
b
->
start
(),
delta_size
));
ASSERT_NE
(
0
,
memcmp
(
target_buf
,
b
->
start
(),
buf_size
));
delete
[]
target_buf
;
target_buf
=
NULL
;
buffer_ptr_
->
destroy
();
check_buffer_clear
(
buffer_ptr_
);
op_reclaim_free
(
buffer_ptr_
);
...
...
unittest/obproxy/test_mysql_transaction_analyzer.cpp
浏览文件 @
db9b7c9a
...
...
@@ -77,7 +77,7 @@ void TestMysqlTransactionAnalyzer::analyze_mysql_response(
int
ret
=
OB_SUCCESS
;
bool
is_completed
=
false
;
bool
is_request_completed
=
false
;
char
*
resp
=
new
char
[
len
]
;
char
resp
[
len
]
=
"
\0
"
;
ret
=
covert_hex_to_string
(
hex
,
len
,
resp
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
ObString
resp_str
;
...
...
@@ -93,7 +93,6 @@ void TestMysqlTransactionAnalyzer::analyze_mysql_response(
ASSERT_TRUE
(
is_completed
);
ASSERT_TRUE
(
trans_analyzer
.
is_trans_completed
());
}
delete
[]
resp
;
}
void
TestMysqlTransactionAnalyzer
::
analyze_mysql_response
(
...
...
unittest/obproxy/test_zlib_stream_compressor.cpp
浏览文件 @
db9b7c9a
...
...
@@ -60,7 +60,7 @@ TEST_F(TestZlibStreamCompressor, test_simple)
ret
=
compressor1
.
add_compress_data
(
text
,
text_len
,
is_last_data
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
char
*
buf
=
new
char
[
len
]
;
char
buf
[
len
]
=
"
\0
"
;
int64_t
filled_len
=
-
1
;
ret
=
compressor1
.
compress
(
buf
,
len
,
filled_len
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
...
...
@@ -70,17 +70,12 @@ TEST_F(TestZlibStreamCompressor, test_simple)
ObZlibStreamCompressor
compressor2
;
ret
=
compressor2
.
add_decompress_data
(
buf
,
filled_len
);
ASSERT_EQ
(
OB_SUCCESS
,
ret
);
char
*
buf2
=
new
char
[
len
]
;
char
buf2
[
len
]
=
"
\0
"
;
int64_t
filled_len2
=
-
1
;
ret
=
compressor2
.
decompress
(
buf2
,
len
,
filled_len2
);
ASSERT_TRUE
(
len
>
filled_len2
);
buf2
[
filled_len2
]
=
'\0'
;
ASSERT_STREQ
(
buf2
,
text
);
delete
[]
buf
;
buf
=
NULL
;
delete
[]
buf2
;
buf2
=
NULL
;
};
TEST_F
(
TestZlibStreamCompressor
,
test_compress_and_decomress_stream
)
...
...
@@ -91,7 +86,7 @@ TEST_F(TestZlibStreamCompressor, test_compress_and_decomress_stream)
int64_t
len
=
text_len
*
2
;
int64_t
total_filled_len
=
0
;
char
*
buf
=
new
char
[
len
]
;
char
buf
[
len
]
=
"
\0
"
;
// 1. stream compress
ObZlibStreamCompressor
compressor1
;
for
(
int64_t
i
=
0
;
i
<
text_len
;
++
i
)
{
...
...
@@ -116,7 +111,7 @@ TEST_F(TestZlibStreamCompressor, test_compress_and_decomress_stream)
// 2.stream decompress
int64_t
len2
=
len
;
char
*
buf2
=
new
char
[
len2
]
;
char
buf2
[
len2
]
=
"
\0
"
;
total_filled_len
=
0
;
ObZlibStreamCompressor
compressor2
;
for
(
int64_t
i
=
0
;
i
<
compressed_len
;
++
i
)
{
...
...
@@ -139,11 +134,6 @@ TEST_F(TestZlibStreamCompressor, test_compress_and_decomress_stream)
LOG_INFO
(
"decompress complete"
,
"origin len"
,
total_filled_len
);
buf2
[
total_filled_len
]
=
'\0'
;
ASSERT_STREQ
(
buf2
,
text
);
delete
[]
buf
;
buf
=
NULL
;
delete
[]
buf2
;
buf2
=
NULL
;
}
TEST_F
(
TestZlibStreamCompressor
,
test_compress_and_decomress_stream2
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录