Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
9c3b907d
提交
9c3b907d
authored
1月 11, 2017
作者:
Mike Jerris
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-9934: [mod_redis] fix segfault on windows on close or connect failure
上级
3fde59fc
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
13 行增加
和
6 行删除
+13
-6
credis.c
src/mod/applications/mod_redis/credis.c
+13
-6
没有找到文件。
src/mod/applications/mod_redis/credis.c
浏览文件 @
9c3b907d
...
@@ -38,6 +38,8 @@
...
@@ -38,6 +38,8 @@
#if _MSC_VER < 1900
#if _MSC_VER < 1900
#define snprintf _snprintf
#define snprintf _snprintf
#endif
#endif
typedef
SOCKET
credis_socket_t
;
#define CREDIS_SOCK_INVALID INVALID_SOCKET
#else
#else
#include <unistd.h>
#include <unistd.h>
#include <sys/select.h>
#include <sys/select.h>
...
@@ -49,6 +51,8 @@
...
@@ -49,6 +51,8 @@
#include <netinet/in.h>
#include <netinet/in.h>
#endif
#endif
#include <arpa/inet.h>
#include <arpa/inet.h>
typedef
int
credis_socket_t
;
#define CREDIS_SOCK_INVALID -1
#endif
#endif
#include <fcntl.h>
#include <fcntl.h>
#include <errno.h>
#include <errno.h>
...
@@ -558,14 +562,19 @@ static int cr_sendfandreceive(REDIS rhnd, char recvtype, const char *format, ...
...
@@ -558,14 +562,19 @@ static int cr_sendfandreceive(REDIS rhnd, char recvtype, const char *format, ...
void
credis_close
(
REDIS
rhnd
)
void
credis_close
(
REDIS
rhnd
)
{
{
if
(
rhnd
->
fd
>
0
)
if
(
rhnd
->
fd
!=
CREDIS_SOCK_INVALID
)
#ifdef _MSC_VER
closesocket
(
rhnd
->
fd
);
#else
close
(
rhnd
->
fd
);
close
(
rhnd
->
fd
);
#endif
cr_delete
(
rhnd
);
cr_delete
(
rhnd
);
}
}
REDIS
credis_connect
(
const
char
*
host
,
int
port
,
int
timeout
)
REDIS
credis_connect
(
const
char
*
host
,
int
port
,
int
timeout
)
{
{
int
fd
,
yes
=
1
;
credis_socket_t
fd
=
CREDIS_SOCK_INVALID
;
int
yes
=
1
;
struct
sockaddr_in
sa
;
struct
sockaddr_in
sa
;
REDIS
rhnd
;
REDIS
rhnd
;
int
valid
=
0
;
int
valid
=
0
;
...
@@ -578,7 +587,7 @@ REDIS credis_connect(const char *host, int port, int timeout)
...
@@ -578,7 +587,7 @@ REDIS credis_connect(const char *host, int port, int timeout)
if
(
port
==
0
)
if
(
port
==
0
)
port
=
6379
;
port
=
6379
;
if
((
fd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
==
-
1
||
if
((
fd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
==
CREDIS_SOCK_INVALID
||
setsockopt
(
fd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
&
yes
,
sizeof
(
yes
))
==
-
1
||
setsockopt
(
fd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
&
yes
,
sizeof
(
yes
))
==
-
1
||
setsockopt
(
fd
,
IPPROTO_TCP
,
TCP_NODELAY
,
&
yes
,
sizeof
(
yes
))
==
-
1
)
setsockopt
(
fd
,
IPPROTO_TCP
,
TCP_NODELAY
,
&
yes
,
sizeof
(
yes
))
==
-
1
)
goto
error
;
goto
error
;
...
@@ -612,9 +621,7 @@ REDIS credis_connect(const char *host, int port, int timeout)
...
@@ -612,9 +621,7 @@ REDIS credis_connect(const char *host, int port, int timeout)
return
rhnd
;
return
rhnd
;
error:
error:
if
(
fd
>=
0
)
credis_close
(
rhnd
);
close
(
fd
);
cr_delete
(
rhnd
);
return
NULL
;
return
NULL
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论