Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿啄debugIT
libfastcommon
提交
acc17549
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,体验更适合开发者的 AI 搜索 >>
提交
acc17549
编写于
9月 15, 2014
作者:
Y
yuqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
conn_pool_destroy close connections and free memory
上级
aafcd765
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
3 deletion
+30
-3
HISTORY
HISTORY
+1
-0
src/connection_pool.c
src/connection_pool.c
+29
-3
未找到文件。
HISTORY
浏览文件 @
acc17549
...
...
@@ -3,6 +3,7 @@ Version 1.07 2014-09-15
* increment alloc task buffer
* add function free_queue_alloc_connections
* check file size before log access header
* conn_pool_destroy close connections and free memory
Version 1.06 2014-08-27
* update source code from FastDFS V5.02
...
...
src/connection_pool.c
浏览文件 @
acc17549
...
...
@@ -31,9 +31,35 @@ int conn_pool_init(ConnectionPool *cp, int connect_timeout, \
return
hash_init
(
&
(
cp
->
hash_array
),
simple_hash
,
1024
,
0
.
75
);
}
int
coon_pool_close_connections
(
const
int
index
,
const
HashData
*
data
,
void
*
args
)
{
ConnectionManager
*
cm
;
cm
=
(
ConnectionManager
*
)
data
->
value
;
if
(
cm
!=
NULL
)
{
ConnectionNode
*
node
;
ConnectionNode
*
deleted
;
node
=
cm
->
head
;
while
(
node
!=
NULL
)
{
deleted
=
node
;
node
=
node
->
next
;
conn_pool_disconnect_server
(
deleted
->
conn
);
free
(
deleted
);
}
free
(
cm
);
}
return
0
;
}
void
conn_pool_destroy
(
ConnectionPool
*
cp
)
{
pthread_mutex_lock
(
&
cp
->
lock
);
hash_walk
(
&
(
cp
->
hash_array
),
coon_pool_close_connections
,
NULL
);
hash_destroy
(
&
(
cp
->
hash_array
));
pthread_mutex_unlock
(
&
cp
->
lock
);
...
...
@@ -174,7 +200,7 @@ ConnectionInfo *conn_pool_get_connection(ConnectionPool *cp,
return
NULL
;
}
bytes
=
sizeof
(
Connection
Info
)
+
sizeof
(
ConnectionNode
);
bytes
=
sizeof
(
Connection
Node
)
+
sizeof
(
ConnectionInfo
);
p
=
(
char
*
)
malloc
(
bytes
);
if
(
p
==
NULL
)
{
...
...
@@ -187,8 +213,8 @@ ConnectionInfo *conn_pool_get_connection(ConnectionPool *cp,
return
NULL
;
}
node
=
(
ConnectionNode
*
)
(
p
+
sizeof
(
ConnectionInfo
))
;
node
->
conn
=
(
ConnectionInfo
*
)
p
;
node
=
(
ConnectionNode
*
)
p
;
node
->
conn
=
(
ConnectionInfo
*
)
(
p
+
sizeof
(
ConnectionNode
))
;
node
->
manager
=
cm
;
node
->
next
=
NULL
;
node
->
atime
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录