Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿啄debugIT
libfastcommon
提交
ec22ab68
L
libfastcommon
项目概览
阿啄debugIT
/
libfastcommon
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libfastcommon
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ec22ab68
编写于
6月 28, 2020
作者:
Y
YuQing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bugfixed: uniq_addresses use FCAddressPtrArray
上级
fb03bf23
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
40 addition
and
22 deletion
+40
-22
HISTORY
HISTORY
+1
-1
src/server_id_func.c
src/server_id_func.c
+29
-20
src/server_id_func.h
src/server_id_func.h
+1
-1
src/tests/test_file_lock.c
src/tests/test_file_lock.c
+9
-0
未找到文件。
HISTORY
浏览文件 @
ec22ab68
Version 1.44 2020-06-
01
Version 1.44 2020-06-
28
* add test file src/tests/test_pthread_lock.c
* add uniq_skiplist.[hc]
* add function split_string_ex
...
...
src/server_id_func.c
浏览文件 @
ec22ab68
...
...
@@ -107,19 +107,19 @@ static int fc_server_calc_ip_port_count(FCServerConfig *ctx)
return
count
;
}
static
int
fc_server_check_alloc_group_addresses
(
FCAddressArray
*
array
)
static
int
fc_server_check_alloc_group_addresses
(
FCAddress
Ptr
Array
*
array
)
{
int
new_alloc
;
int
bytes
;
FCAddressInfo
*
new_addrs
;
FCAddressInfo
*
*
new_addrs
;
if
(
array
->
count
<
array
->
alloc
)
{
return
0
;
}
new_alloc
=
array
->
alloc
>
0
?
2
*
array
->
alloc
:
2
;
bytes
=
sizeof
(
FCAddressInfo
)
*
new_alloc
;
new_addrs
=
(
FCAddressInfo
*
)
malloc
(
bytes
);
bytes
=
sizeof
(
FCAddressInfo
*
)
*
new_alloc
;
new_addrs
=
(
FCAddressInfo
*
*
)
malloc
(
bytes
);
if
(
new_addrs
==
NULL
)
{
logError
(
"file: "
__FILE__
", line: %d, "
"malloc %d bytes fail"
,
__LINE__
,
bytes
);
...
...
@@ -128,7 +128,7 @@ static int fc_server_check_alloc_group_addresses(FCAddressArray *array)
memset
(
new_addrs
,
0
,
bytes
);
if
(
array
->
addrs
!=
NULL
)
{
memcpy
(
new_addrs
,
array
->
addrs
,
sizeof
(
FCAddressInfo
)
*
array
->
count
);
memcpy
(
new_addrs
,
array
->
addrs
,
sizeof
(
FCAddressInfo
*
)
*
array
->
count
);
free
(
array
->
addrs
);
}
...
...
@@ -138,24 +138,32 @@ static int fc_server_check_alloc_group_addresses(FCAddressArray *array)
}
static
FCAddressInfo
*
fc_server_add_to_uniq_addresses
(
FCAddress
Array
*
add
r_array
,
const
FCAddressInfo
*
addr
)
FCAddress
PtrArray
*
addr_pt
r_array
,
const
FCAddressInfo
*
addr
)
{
FCAddressInfo
*
p
;
FCAddressInfo
*
end
;
FCAddressInfo
**
pp
;
FCAddressInfo
**
end
;
end
=
addr_
array
->
addrs
+
add
r_array
->
count
;
for
(
p
=
addr_array
->
addrs
;
p
<
end
;
p
++
)
{
if
(
FC_CONNECTION_SERVER_EQUAL1
(
addr
->
conn
,
p
->
conn
))
{
return
p
;
end
=
addr_
ptr_array
->
addrs
+
addr_pt
r_array
->
count
;
for
(
p
p
=
addr_ptr_array
->
addrs
;
pp
<
end
;
p
p
++
)
{
if
(
FC_CONNECTION_SERVER_EQUAL1
(
addr
->
conn
,
(
*
pp
)
->
conn
))
{
return
*
p
p
;
}
}
if
(
fc_server_check_alloc_group_addresses
(
addr_array
)
!=
0
)
{
if
(
fc_server_check_alloc_group_addresses
(
addr_
ptr_
array
)
!=
0
)
{
return
NULL
;
}
p
=
addr_array
->
addrs
+
addr_array
->
count
;
p
=
(
FCAddressInfo
*
)
malloc
(
sizeof
(
FCAddressInfo
));
if
(
p
==
NULL
)
{
logError
(
"file: "
__FILE__
", line: %d, "
"malloc %d bytes fail"
,
__LINE__
,
(
int
)
sizeof
(
FCAddressInfo
));
return
NULL
;
}
*
p
=
*
addr
;
addr_
array
->
count
++
;
addr_
ptr_array
->
addrs
[
addr_ptr_array
->
count
++
]
=
p
;
return
p
;
}
...
...
@@ -168,8 +176,8 @@ static int fc_server_init_ip_port_array(FCServerConfig *ctx)
FCServerMap
*
map
;
FCServerInfo
*
server
;
FCServerInfo
*
send
;
FCAddressInfo
*
paddr
;
FCAddressInfo
*
pend
;
FCAddressInfo
*
*
paddr
;
FCAddressInfo
*
*
pend
;
map_array
=
&
ctx
->
sorted_server_arrays
.
by_ip_port
;
...
...
@@ -192,8 +200,8 @@ static int fc_server_init_ip_port_array(FCServerConfig *ctx)
pend
=
server
->
uniq_addresses
.
addrs
+
server
->
uniq_addresses
.
count
;
for
(
paddr
=
server
->
uniq_addresses
.
addrs
;
paddr
<
pend
;
paddr
++
)
{
map
->
server
=
server
;
FC_SET_STRING
(
map
->
ip_addr
,
paddr
->
conn
.
ip_addr
);
map
->
port
=
paddr
->
conn
.
port
;
FC_SET_STRING
(
map
->
ip_addr
,
(
*
paddr
)
->
conn
.
ip_addr
);
map
->
port
=
(
*
paddr
)
->
conn
.
port
;
map
++
;
}
}
...
...
@@ -737,14 +745,14 @@ static int fc_server_set_group_server_address(FCServerInfo *server,
if
(
addr
==
NULL
)
{
return
ENOMEM
;
}
if
((
result
=
fc_server_check_alloc_group_address_ptrs
(
&
group_addr
->
address_array
))
!=
0
)
{
return
result
;
}
group_addr
->
address_array
.
addrs
[
group_addr
->
address_array
.
count
]
=
addr
;
group_addr
->
address_array
.
count
++
;
group_addr
->
address_array
.
addrs
[
group_addr
->
address_array
.
count
++
]
=
addr
;
return
0
;
}
...
...
@@ -831,6 +839,7 @@ static int fc_server_set_host(FCServerConfig *ctx, FCServerInfo *server,
}
else
{
new_addr
=
addr
;
}
if
((
result
=
fc_server_set_group_server_address
(
server
,
group_addr
,
new_addr
))
!=
0
)
{
...
...
src/server_id_func.h
浏览文件 @
ec22ab68
...
...
@@ -65,7 +65,7 @@ typedef struct
typedef
struct
{
int
id
;
//server id
FCAddressArray
uniq_addresses
;
FCAddress
Ptr
Array
uniq_addresses
;
FCGroupAddresses
group_addrs
[
FC_MAX_GROUP_COUNT
];
}
FCServerInfo
;
...
...
src/tests/test_file_lock.c
浏览文件 @
ec22ab68
...
...
@@ -11,6 +11,12 @@
#include "fastcommon/logger.h"
#include "fastcommon/shared_func.h"
#define OneArgument(a) printf("One Argument func is called!\n")
#define TwoArguments(a, b) printf("Two Arguments func is called!\n")
#define TreeArguments(a, b, c) printf("Tree Arguments func is called!\n")
#define MacroKernel(_1, _2, _3, FUNC, ...) FUNC
#define Macro(...) MacroKernel(__VA_ARGS__, TreeArguments, TwoArguments, OneArgument, ...)(__VA_ARGS__)
static
inline
int
get_lock_info
(
int
fd
,
struct
flock
*
lock
)
{
int
result
;
...
...
@@ -43,6 +49,9 @@ int main(int argc, char *argv[])
char
buf
[
1024
];
struct
flock
lock
;
Macro
(
1
);
Macro
(
1
,
2
);
Macro
(
1
,
2
,
3
);
if
(
argc
<
2
)
{
fprintf
(
stderr
,
"Usage: %s <filename>
\n
"
,
argv
[
0
]);
return
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录