Skip to content

[Canary] monkey: pipe: socket: monkey afunix socketpair confirmation on windows#11822

Draft
cosmo0920 wants to merge 2 commits into
masterfrom
cosmo0920-canary-monkey-afunix-socketpair-confirmation-on-windows
Draft

[Canary] monkey: pipe: socket: monkey afunix socketpair confirmation on windows#11822
cosmo0920 wants to merge 2 commits into
masterfrom
cosmo0920-canary-monkey-afunix-socketpair-confirmation-on-windows

Conversation

@cosmo0920
Copy link
Copy Markdown
Contributor

@cosmo0920 cosmo0920 commented May 19, 2026

THIS IS CANARY PR. DO NOT MERGE.

Notes: This change does not eliminate every loopback TCP socketpair because vendored libevent still creates internal notification/signal socketpairs through its Windows evutil_make_internal_pipe() path. However, it significantly reduces Fluent Bit/Monkey-created loopback TCP socketpairs by routing the shared socketpair abstraction through Windows AF_UNIX when available.

In the current Monkey implementation, Windows socketpair-like behavior heavily
depends on libevent's loopback TCP emulation layer.

On monkey/monkey#438, I diagnosed and investigated how AF_UNIX with stream works on Windows 10 1803 or later.

Then, I saw the following results:

In the original architecture of Fluent Bit and dependent monkey HTTP server's core, we always use lots of loopback connections to emulate Unix sockets like:

PS> Get-NetTCPConnection -OwningProcess <pid of fluent-bit.exe>

LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting
------------                        --------- -------------                       ---------- -----       --------------
0.0.0.0                             58806     0.0.0.0                             0          Bound
0.0.0.0                             58804     0.0.0.0                             0          Bound
0.0.0.0                             58802     0.0.0.0                             0          Bound
0.0.0.0                             58800     0.0.0.0                             0          Bound
0.0.0.0                             58798     0.0.0.0                             0          Bound
0.0.0.0                             58796     0.0.0.0                             0          Bound
0.0.0.0                             58795     0.0.0.0                             0          Bound
0.0.0.0                             58792     0.0.0.0                             0          Bound
0.0.0.0                             58790     0.0.0.0                             0          Bound
0.0.0.0                             58788     0.0.0.0                             0          Bound
0.0.0.0                             58786     0.0.0.0                             0          Bound
0.0.0.0                             58784     0.0.0.0                             0          Bound
0.0.0.0                             58782     0.0.0.0                             0          Bound
0.0.0.0                             58780     0.0.0.0                             0          Bound
0.0.0.0                             58778     0.0.0.0                             0          Bound
0.0.0.0                             58776     0.0.0.0                             0          Bound
0.0.0.0                             58774     0.0.0.0                             0          Bound
0.0.0.0                             58772     0.0.0.0                             0          Bound
0.0.0.0                             58770     0.0.0.0                             0          Bound
0.0.0.0                             58768     0.0.0.0                             0          Bound
0.0.0.0                             58766     0.0.0.0                             0          Bound
0.0.0.0                             58764     0.0.0.0                             0          Bound
0.0.0.0                             58762     0.0.0.0                             0          Bound
0.0.0.0                             58760     0.0.0.0                             0          Bound
0.0.0.0                             58758     0.0.0.0                             0          Bound
0.0.0.0                             58756     0.0.0.0                             0          Bound
127.0.0.1                           58806     127.0.0.1                           58805      Established Internet
127.0.0.1                           58805     127.0.0.1                           58806      Established Internet
127.0.0.1                           58804     127.0.0.1                           58803      Established Internet
127.0.0.1                           58803     127.0.0.1                           58804      Established Internet
127.0.0.1                           58802     127.0.0.1                           58801      Established Internet
127.0.0.1                           58801     127.0.0.1                           58802      Established Internet
127.0.0.1                           58800     127.0.0.1                           58799      Established Internet
127.0.0.1                           58799     127.0.0.1                           58800      Established Internet
127.0.0.1                           58798     127.0.0.1                           58797      Established Internet
127.0.0.1                           58797     127.0.0.1                           58798      Established Internet
127.0.0.1                           58796     127.0.0.1                           58794      Established Internet
127.0.0.1                           58795     127.0.0.1                           58793      Established Internet
127.0.0.1                           58794     127.0.0.1                           58796      Established Internet
127.0.0.1                           58793     127.0.0.1                           58795      Established Internet
127.0.0.1                           58792     127.0.0.1                           58791      Established Internet
127.0.0.1                           58791     127.0.0.1                           58792      Established Internet
127.0.0.1                           58790     127.0.0.1                           58789      Established Internet
127.0.0.1                           58789     127.0.0.1                           58790      Established Internet
127.0.0.1                           58788     127.0.0.1                           58787      Established Internet
127.0.0.1                           58787     127.0.0.1                           58788      Established Internet
127.0.0.1                           58786     127.0.0.1                           58785      Established Internet
127.0.0.1                           58785     127.0.0.1                           58786      Established Internet
127.0.0.1                           58784     127.0.0.1                           58783      Established Internet
127.0.0.1                           58783     127.0.0.1                           58784      Established Internet
127.0.0.1                           58782     127.0.0.1                           58781      Established Internet
127.0.0.1                           58781     127.0.0.1                           58782      Established Internet
127.0.0.1                           58780     127.0.0.1                           58779      Established Internet
127.0.0.1                           58779     127.0.0.1                           58780      Established Internet
127.0.0.1                           58778     127.0.0.1                           58777      Established Internet
127.0.0.1                           58777     127.0.0.1                           58778      Established Internet
127.0.0.1                           58776     127.0.0.1                           58775      Established Internet
127.0.0.1                           58775     127.0.0.1                           58776      Established Internet
127.0.0.1                           58774     127.0.0.1                           58773      Established Internet
127.0.0.1                           58773     127.0.0.1                           58774      Established Internet
127.0.0.1                           58772     127.0.0.1                           58771      Established Internet
127.0.0.1                           58771     127.0.0.1                           58772      Established Internet
127.0.0.1                           58770     127.0.0.1                           58769      Established Internet
127.0.0.1                           58769     127.0.0.1                           58770      Established Internet
127.0.0.1                           58768     127.0.0.1                           58767      Established Internet
127.0.0.1                           58767     127.0.0.1                           58768      Established Internet
127.0.0.1                           58766     127.0.0.1                           58765      Established Internet
127.0.0.1                           58765     127.0.0.1                           58766      Established Internet
127.0.0.1                           58764     127.0.0.1                           58763      Established Internet
127.0.0.1                           58763     127.0.0.1                           58764      Established Internet
127.0.0.1                           58762     127.0.0.1                           58761      Established Internet
127.0.0.1                           58761     127.0.0.1                           58762      Established Internet
127.0.0.1                           58760     127.0.0.1                           58759      Established Internet
127.0.0.1                           58759     127.0.0.1                           58760      Established Internet
127.0.0.1                           58758     127.0.0.1                           58757      Established Internet
127.0.0.1                           58757     127.0.0.1                           58758      Established Internet
127.0.0.1                           58756     127.0.0.1                           58755      Established Internet
127.0.0.1                           58755     127.0.0.1                           58756      Established Internet

After applying monkey/monkey#438 and modification of using AF_UNIX when available patch in this PR, we got:

PS> Get-NetTCPConnection -OwningProcess <the modified pid of fluent-bit.exe>

LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting
------------                        --------- -------------                       ---------- -----       --------------
0.0.0.0                             51260     0.0.0.0                             0          Bound
0.0.0.0                             51258     0.0.0.0                             0          Bound
0.0.0.0                             51256     0.0.0.0                             0          Bound
0.0.0.0                             51254     0.0.0.0                             0          Bound
127.0.0.1                           51260     127.0.0.1                           51259      Established Internet
127.0.0.1                           51259     127.0.0.1                           51260      Established Internet
127.0.0.1                           51258     127.0.0.1                           51257      Established Internet
127.0.0.1                           51257     127.0.0.1                           51258      Established Internet
127.0.0.1                           51256     127.0.0.1                           51255      Established Internet
127.0.0.1                           51255     127.0.0.1                           51256      Established Internet
127.0.0.1                           51254     127.0.0.1                           51253      Established Internet
127.0.0.1                           51253     127.0.0.1                           51254      Established Internet

Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

cosmo0920 added 2 commits May 19, 2026 19:31
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5a2f5169-941c-41c5-bff7-7061af624bc6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-canary-monkey-afunix-socketpair-confirmation-on-windows

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant