Skip to content

Conversation

@voltflake
Copy link
Contributor

Quite a while ago i noticed an issue that makes windows D++ builds delay sending messages, responses, and other REST requests with 1000ms delay. This PR fixes that.

Basically i added a dummy socket into poll implementation so that when poll() is running and waiting for timeout it can be interrupted by event of that dummy socket and refresh its file descriptors on demand.

To properly test this, increase poll timeout to 5000 ms and try simple ping-pong example bot. Before this change bot would hang for 5s and only then reply. Or slightly faster if heartbeat event occurs, which triggers poll activation. Issue persisted on all platforms when using default poll socket engine, both Linux and Windows.

Feel free to pinpoint in flaws that i may missed or request changes.

  • I have ensured that all methods and functions are fully documented using doxygen style comments.
    (they are as documented as they were before me)
  • My code follows the coding style guide.
  • I tested that my change works before raising the PR.
  • I have ensured that I did not break any existing API calls.
  • I have not built my pull request using AI, a static analysis tool or similar without any human oversight.

@netlify
Copy link

netlify bot commented Sep 14, 2025

Deploy Preview for dpp-dev ready!

Name Link
🔨 Latest commit ae95e14
🔍 Latest deploy log https://app.netlify.com/projects/dpp-dev/deploys/68cd618239564400072e881b
😎 Deploy Preview https://deploy-preview-1485--dpp-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@CLAassistant
Copy link

CLAassistant commented Sep 14, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added documentation Improvements or additions to documentation code Improvements or additions to code. labels Sep 14, 2025
Copy link
Contributor

@braindigitalis braindigitalis left a comment

Choose a reason for hiding this comment

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

what exactly is this doing? it looks like it continually inserts writeable udp fd's into the poll set?

@voltflake
Copy link
Contributor Author

voltflake commented Sep 15, 2025

It inserts that wakeup udp socket into poll fds only once in constructor. Purpose of that socket is to allow poll() to exit before reaching timeout if needed. If other thread updates or registers new socket while poll() is already running and waiting for new socket events, it can't exit that state until timeout reaches or one of previously registered sockets receives event.

In other socket engine implementations, like epoll(), early exits are possible and are used by lib. This additional wakeup socket basically adds this interrupt functionality to default poll(), allowing it to exit early on demand.

refresh_pool() writes a byte to wakeup socket and drain_wakeup() discards that byte basically.

@Jaskowicz1
Copy link
Contributor

I'm personally happy with this PR, but since I didn't work on the original implementation and I'm still a bit clueless on how the socket engine works, I'd rather @braindigitalis approve of this

@Jaskowicz1 Jaskowicz1 changed the title Fix D++ from stalling for a second before sending REST requests on Windows OS Fix D++ from stalling for a second before sending REST requests using poll. Sep 15, 2025
@Jaskowicz1
Copy link
Contributor

I've approved runners and updated the name, as this is reproduceable on Linux.

@braindigitalis braindigitalis merged commit 32aff57 into brainboxdotcc:dev Sep 19, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code Improvements or additions to code. documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants