Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https并发通讯时,socket 有 double close 风险 #81

Open
duckpowermb opened this issue Dec 8, 2021 · 0 comments
Open

https并发通讯时,socket 有 double close 风险 #81

duckpowermb opened this issue Dec 8, 2021 · 0 comments

Comments

@duckpowermb
Copy link

duckpowermb commented Dec 8, 2021

https通讯场景下,使用 webclient_connect 连接成功后, socket fd同时保存在
session->tls_session->server_fd.fd 和 session->socket 中

通讯过程中,如果发生通讯错误, 则会主动调用 closesocket() 关闭通讯socket, 同时只把 session->socket 置为 -1.
此时 session->tls_session->server_fd.fd 中的 fd 号维持不变.
(参考 webclient_read / webclient_write 中的错误处理部分)

通讯过程结束时,如果用户直接使用 webclient_clean 清理现场 , 在https使用场景下,会根据 session->tls_session->server_fd.fd
判定socket是否已经关闭,如其值不为 -1 ,则使用closesocket 主动关闭一次,这里在并发场景下,会有socket double close 风险

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant