Skip to content

tls: yield downstream read retries to the event loop [Backport to 5.0]#12141

Draft
cosmo0920 wants to merge 8 commits into
5.0from
agent/tls-event-retry-11551-5.0
Draft

tls: yield downstream read retries to the event loop [Backport to 5.0]#12141
cosmo0920 wants to merge 8 commits into
5.0from
agent/tls-event-retry-11551-5.0

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Partially backporting of #12140 due to lack of integration testing infrastructure.


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.

edsiper added 8 commits July 23, 2026 12:42
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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 Plus

Run ID: dd8bda9d-1d7b-4e50-8e5d-f5963fced898

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 agent/tls-event-retry-11551-5.0

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e2a2a441e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +160 to +161
ret = flb_io_net_read(conn->connection,
conn->buf + conn->buf_len, avail);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bound secure-forward reads to the allocated buffer

When secure-forward is enabled and buffer_chunk_size is configured below 1023, conn->buf is only that configured size, but check_ping() calls this helper with size == 1023, so flb_io_net_read() can write past the end of conn->buf before msgpack validation runs. Please cap avail by conn->buf_size - conn->buf_len or grow the connection buffer before reading the PING.

Useful? React with 👍 / 👎.

Comment thread src/tls/flb_tls.c
}
else if (ret == FLB_TLS_WANT_WRITE) {
if (event_driven) {
if (io_tls_event_switch(session, MK_EVENT_READ | MK_EVENT_WRITE) == -1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve custom event dispatch for TLS write retries

When a downstream TLS read returns FLB_TLS_WANT_WRITE, this new path calls io_tls_event_switch(), whose mk_event_add(..., FLB_ENGINE_EV_THREAD, ...) re-registers the already-registered input/http-server connection as a thread event instead of the FLB_ENGINE_EV_CUSTOM handler it was using. In the normal downstream input registrations there is no coroutine waiting for that follow-up writable notification, so the engine consumes the event without invoking the connection handler and the TLS connection can remain stuck in the retry state; preserve the existing event type/handler when switching the mask.

Useful? React with 👍 / 👎.

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.

2 participants