Skip to content

GUACAMOLE-2221: fix RDP busy-loop on transport failure#635

Merged
mike-jumper merged 1 commit intoapache:staging/1.6.1from
pwgcz:GUACAMOLE-2118-fix-RDP-busy-loop-on-transport-failure
Mar 31, 2026
Merged

GUACAMOLE-2221: fix RDP busy-loop on transport failure#635
mike-jumper merged 1 commit intoapache:staging/1.6.1from
pwgcz:GUACAMOLE-2118-fix-RDP-busy-loop-on-transport-failure

Conversation

@pwgcz
Copy link
Copy Markdown
Contributor

@pwgcz pwgcz commented Feb 16, 2026

When an RDP connection hits a transport-level
failure (for example, a certificate error), the
inner event loop in rdp.c can spin at 100% CPU.

This happens because the error state in
wait_result gets overwritten. When the issue
occurs, guac_rdp_handle_events() sets wait_result
to -1, but the loop doesn’t exit immediately. In
the next iteration, the while condition assigns
wait_result from rdp_guac_client_wait_for_events()
effectively clearing the error flag. As a result,
the loop never observes the transport failure and
continues polling, spinning the CPU.

Fix: break out of the loop immediately after
guac_rdp_handle_events() fails, so we stop
processing when FreeRDP reports a connection
error.

@pwgcz pwgcz changed the title GUACAMOLE-2118: fix RDP busy-loop on transport failure GUACAMOLE-2221: fix RDP busy-loop on transport failure Feb 17, 2026
Copy link
Copy Markdown
Contributor

@necouchman necouchman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pwgcz As discussed in the Jira ticket, I don't think we want to simply revert the previous patch, as that just reintroduces the issue that the commit resolves. You had suggested an alternate approach in the Jira issue - you're welcome to update this PR with that approach and we can see if that addresses the issue without (re)introducing other issues.

@pwgcz pwgcz force-pushed the GUACAMOLE-2118-fix-RDP-busy-loop-on-transport-failure branch from 7366925 to 4444218 Compare March 26, 2026 15:19
@pwgcz
Copy link
Copy Markdown
Contributor Author

pwgcz commented Mar 26, 2026

@necouchman Sorry for not responding sooner. I've updated the code now.

Copy link
Copy Markdown
Contributor

@mike-jumper mike-jumper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this, @pwgcz! Please also:

  • Base this off staging/1.6.1 (so it can be included as part of 1.6.1)

  • Rebase to get rid of the merge commit that snuck in here:

    Screenshot of the current commits on guacamole-server PR #625, with a red arrow pointing at the merge commit that should be rebased away.

Comment thread src/protocols/rdp/rdp.c Outdated
Comment thread src/protocols/rdp/rdp.c Outdated
@pwgcz pwgcz force-pushed the GUACAMOLE-2118-fix-RDP-busy-loop-on-transport-failure branch 4 times, most recently from 812428f to 913560d Compare March 30, 2026 12:50
@pwgcz pwgcz changed the base branch from main to staging/1.6.1 March 30, 2026 12:54
@pwgcz pwgcz force-pushed the GUACAMOLE-2118-fix-RDP-busy-loop-on-transport-failure branch 3 times, most recently from b3f0524 to 646f867 Compare March 30, 2026 15:47
Comment thread src/protocols/rdp/rdp.c Outdated
When an RDP connection hits a transport-level failure (for example, a
certificate error), the inner event loop in rdp.c can spin at 100% CPU.

This happens because rdp_guac_client_wait_for_events() does not check
FreeRDP's error state, so it keeps returning success even after a
transport failure has been recorded. As a result, the loop never
observes the error and continues polling indefinitely.

Fix: check freerdp_get_last_error() in rdp_guac_client_wait_for_events()
and return -1 when an error is recorded. This satisfies the function's
contract to report errors and ensures the loop exits promptly.
@pwgcz pwgcz force-pushed the GUACAMOLE-2118-fix-RDP-busy-loop-on-transport-failure branch from 646f867 to bf1b62d Compare March 31, 2026 16:32
@necouchman necouchman requested a review from mike-jumper March 31, 2026 19:25
Copy link
Copy Markdown
Contributor

@necouchman necouchman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mike-jumper Any other concerns?

Copy link
Copy Markdown
Contributor

@mike-jumper mike-jumper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mike-jumper mike-jumper merged commit 0dfa375 into apache:staging/1.6.1 Mar 31, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

3 participants