Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Eclipse Foundation
Eclipse Paho C Client Library for the MQTT Protocol
提交
c3048f90
E
Eclipse Paho C Client Library for the MQTT Protocol
项目概览
镜像
/
Eclipse Foundation
/
Eclipse Paho C Client Library for the MQTT Protocol
大约 1 年 前同步成功
通知
251
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
Eclipse Paho C Client Library for the MQTT Protocol
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c3048f90
编写于
11月 29, 2022
作者:
I
Ian Craggs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Protect data structure alteration when creating sockets #1219 #1290
上级
5a9e2e40
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
2 deletion
+12
-2
src/MQTTClient.c
src/MQTTClient.c
+1
-1
src/Socket.c
src/Socket.c
+11
-1
未找到文件。
src/MQTTClient.c
浏览文件 @
c3048f90
...
...
@@ -250,7 +250,7 @@ static pthread_mutex_t mqttclient_mutex_store = PTHREAD_MUTEX_INITIALIZER;
static
mutex_type
mqttclient_mutex
=
&
mqttclient_mutex_store
;
static
pthread_mutex_t
socket_mutex_store
=
PTHREAD_MUTEX_INITIALIZER
;
static
mutex_type
socket_mutex
=
&
socket_mutex_store
;
mutex_type
socket_mutex
=
&
socket_mutex_store
;
static
pthread_mutex_t
subscribe_mutex_store
=
PTHREAD_MUTEX_INITIALIZER
;
static
mutex_type
subscribe_mutex
=
&
subscribe_mutex_store
;
...
...
src/Socket.c
浏览文件 @
c3048f90
...
...
@@ -74,6 +74,8 @@ Sockets mod_s;
static
fd_set
wset
;
#endif
extern
mutex_type
socket_mutex
;
/**
* Set a socket non-blocking, OS independently
* @param sock the socket to set non-blocking
...
...
@@ -268,6 +270,7 @@ int Socket_addSocket(SOCKET newSd)
int
rc
=
0
;
FUNC_ENTRY
;
Thread_lock_mutex
(
socket_mutex
);
mod_s
.
nfds
++
;
if
(
mod_s
.
fds_read
)
mod_s
.
fds_read
=
realloc
(
mod_s
.
fds_read
,
mod_s
.
nfds
*
sizeof
(
mod_s
.
fds_read
[
0
]));
...
...
@@ -307,6 +310,7 @@ int Socket_addSocket(SOCKET newSd)
Log
(
LOG_ERROR
,
-
1
,
"addSocket: setnonblocking"
);
exit:
Thread_unlock_mutex
(
socket_mutex
);
FUNC_EXIT_RC
(
rc
);
return
rc
;
}
...
...
@@ -1169,6 +1173,7 @@ int Socket_new(const char* addr, size_t addr_len, int port, SOCKET* sock)
if
(
rc
==
EINPROGRESS
||
rc
==
EWOULDBLOCK
)
{
SOCKET
*
pnewSd
=
(
SOCKET
*
)
malloc
(
sizeof
(
SOCKET
));
ListElement
*
result
=
NULL
;
if
(
!
pnewSd
)
{
...
...
@@ -1176,7 +1181,10 @@ int Socket_new(const char* addr, size_t addr_len, int port, SOCKET* sock)
goto
exit
;
}
*
pnewSd
=
*
sock
;
if
(
!
ListAppend
(
mod_s
.
connect_pending
,
pnewSd
,
sizeof
(
SOCKET
)))
Thread_lock_mutex
(
socket_mutex
);
result
=
ListAppend
(
mod_s
.
connect_pending
,
pnewSd
,
sizeof
(
SOCKET
));
Thread_unlock_mutex
(
socket_mutex
);
if
(
!
result
)
{
free
(
pnewSd
);
rc
=
PAHO_MEMORY_ERROR
;
...
...
@@ -1189,7 +1197,9 @@ int Socket_new(const char* addr, size_t addr_len, int port, SOCKET* sock)
as reported in https://github.com/eclipse/paho.mqtt.c/issues/135 */
if
(
rc
!=
0
&&
(
rc
!=
EINPROGRESS
)
&&
(
rc
!=
EWOULDBLOCK
))
{
Thread_lock_mutex
(
socket_mutex
);
Socket_close
(
*
sock
);
/* close socket and remove from our list of sockets */
Thread_unlock_mutex
(
socket_mutex
);
*
sock
=
SOCKET_ERROR
;
/* as initialized before */
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录