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

[websocket]: Prevent crash on network disconnect during send #684

Merged

Conversation

david-cermak
Copy link
Collaborator

@david-cermak david-cermak commented Oct 31, 2024

When WiFi disconnects, `esp_websocket_client_task` continues polling
`esp_transport_poll_read()` with a default 1-second timeout.
If a timeout triggers `esp_websocket_client_abort_connection`,
certain resources are released.
However, if `esp_websocket_client_send_with_exact_opcode`
is still blocked at this point, it will cause a crash
when it times out and accesses the released handle.
This fix prevents potential crashes by ensuring proper
synchronization between abort and send functions.

Merges: #629


1.3.0

Features

  • add events for begin/end thread (d7fa24bc)
  • Make example to use certificate bundle (aecf6f80)
  • propagate esp_tls stack error and cert verify flags (234f579b)
  • Add option to set and use cert_common_name in Websocket client (3a6720de)
  • adding support for if_name when using WSS transport (333a6893)
  • allow updating reconnect timeout for retry backoffs (bd9f0627)
  • allow using external tcp transport handle (83ea2876)
  • adding support for keep_alive_enable when using WSS transport (c728eae5)

Bug Fixes

  • Prevent crash on network disconnect during send (a453ca1f)
  • use proper interface to delete semaphore (991ac40d)
  • Move client to different state when disconnecting (0d8f2a6d)
  • fix of websocket host example (5ccc018a)
  • don't get transport from the list if external transport is used (9d4d5d2d)
  • Fix locking issues of esp_websocket_client_send_with_exact_opcode API (6393fcd7)

xutao and others added 2 commits October 31, 2024 11:33
When WiFi disconnects, `esp_websocket_client_task` continues polling
`esp_transport_poll_read()` with a default 1-second timeout.
If a timeout triggers `esp_websocket_client_abort_connection`,
certain resources are released.
However, if `esp_websocket_client_send_with_exact_opcode`
is still blocked at this point, it will cause a crash
when it times out and accesses the released handle.
This fix prevents potential crashes by ensuring proper
synchronization between abort and send functions.

Merges: espressif#629
1.3.0
Features
- add events for begin/end thread (d7fa24b)
- Make example to use certificate bundle (aecf6f8)
- propagate esp_tls stack error and cert verify flags (234f579)
- Add option to set and use cert_common_name in Websocket client (3a6720d)
- adding support for `if_name` when using WSS transport (333a689)
- allow updating reconnect timeout for retry backoffs (bd9f062)
- allow using external tcp transport handle (83ea287)
- adding support for `keep_alive_enable` when using WSS transport (c728eae)
Bug Fixes
- Prevent crash on network disconnect during send (a453ca1)
- use proper interface to delete semaphore (991ac40)
- Move client to different state when disconnecting (0d8f2a6)
- fix of websocket host example (5ccc018)
- don't get transport from the list if external transport is used (9d4d5d2)
- Fix locking issues of `esp_websocket_client_send_with_exact_opcode` API (6393fcd)
@david-cermak david-cermak force-pushed the fix/ws_disconnect_deadlock branch from 14d50d1 to 2bcfa45 Compare October 31, 2024 10:34
@david-cermak david-cermak merged commit 542547d into espressif:master Oct 31, 2024
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants