[PR #211] [MERGED] Properly deal with a socket that is readable and writable at the same time #1577

Closed
opened 2026-05-05 07:56:44 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/debauchee/barrier/pull/211
Author: @jwestfall69
Created: 12/28/2018
Status: Merged
Merged: 12/30/2018
Merged by: @AdrianKoshka

Base: masterHead: socket-fix


📝 Commits (1)

  • 94f8336 Properly deal with a socket that is readable and writable at the same time

📊 Changes

1 file changed (+15 additions, -8 deletions)

View changed files

📝 src/lib/net/TCPSocket.cpp (+15 -8)

📄 Description

Its possible poll() will return that a socket is both readable and
writable. When this happens TCPSocket::serviceConnected() is
overwriting the result from doWrite() with the result from doRead()

This can cause a situation where doWrite() tried to notify that we
should stop polling if the socket is writable, but the doRead() result
causes that to be ignored. This results in a tight loop and 100% cpu
usage in SocketMultiplexer::serviceThread() as the poll() call
instantly returns that the socket is writable, but no one cares that
it is. The issue eventually corrects itself with enough mouse
movement/clicks.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/debauchee/barrier/pull/211 **Author:** [@jwestfall69](https://github.com/jwestfall69) **Created:** 12/28/2018 **Status:** ✅ Merged **Merged:** 12/30/2018 **Merged by:** [@AdrianKoshka](https://github.com/AdrianKoshka) **Base:** `master` ← **Head:** `socket-fix` --- ### 📝 Commits (1) - [`94f8336`](https://github.com/debauchee/barrier/commit/94f8336af546c724f4be21f41df766284899247a) Properly deal with a socket that is readable and writable at the same time ### 📊 Changes **1 file changed** (+15 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/net/TCPSocket.cpp` (+15 -8) </details> ### 📄 Description Its possible poll() will return that a socket is both readable and writable. When this happens TCPSocket::serviceConnected() is overwriting the result from doWrite() with the result from doRead() This can cause a situation where doWrite() tried to notify that we should stop polling if the socket is writable, but the doRead() result causes that to be ignored. This results in a tight loop and 100% cpu usage in SocketMultiplexer::serviceThread() as the poll() call instantly returns that the socket is writable, but no one cares that it is. The issue eventually corrects itself with enough mouse movement/clicks. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 07:56:44 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/barrier#1577
No description provided.