Skip to content

Commit

Permalink
Merge pull request #95233 from Faless/ws/fix_set_no_delay_win
Browse files Browse the repository at this point in the history
[WS] Fix `set_no_delay` on Windows
  • Loading branch information
akien-mga committed Aug 7, 2024
2 parents 5e7592a + 7f610a2 commit 17f3d35
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/websocket/wsl_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ void WSLPeer::Resolver::try_next_candidate(Ref<StreamPeerTCP> &p_tcp) {
p_tcp->poll();
StreamPeerTCP::Status status = p_tcp->get_status();
if (status == StreamPeerTCP::STATUS_CONNECTED) {
// On Windows, setting TCP_NODELAY may fail if the socket is still connecting.
p_tcp->set_no_delay(true);
ip_candidates.clear();
return;
} else if (status == StreamPeerTCP::STATUS_CONNECTING) {
Expand All @@ -112,7 +114,6 @@ void WSLPeer::Resolver::try_next_candidate(Ref<StreamPeerTCP> &p_tcp) {
while (ip_candidates.size()) {
Error err = p_tcp->connect_to_host(ip_candidates.pop_front(), port);
if (err == OK) {
p_tcp->set_no_delay(true);
return;
} else {
p_tcp->disconnect_from_host();
Expand Down Expand Up @@ -311,7 +312,7 @@ void WSLPeer::_do_client_handshake() {
ERR_FAIL_COND(tcp.is_null());

// Try to connect to candidates.
if (resolver.has_more_candidates()) {
if (resolver.has_more_candidates() || tcp->get_status() == StreamPeerTCP::STATUS_CONNECTING) {
resolver.try_next_candidate(tcp);
if (resolver.has_more_candidates()) {
return; // Still pending.
Expand Down

0 comments on commit 17f3d35

Please sign in to comment.