-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
engine:enhanced byte order handling for timestamps #9196
engine:enhanced byte order handling for timestamps #9196
Conversation
7c2ffce
to
38264c0
Compare
Hey @leonardo-albertovich @edsiper, this pr introduces a new fuction My knowledge of the fluent-bit codebase is limited, therefore, I am uncertain about the function name and the location where I added the function, in this case, the |
include/fluent-bit/flb_byteswap.h
Outdated
@@ -102,4 +103,13 @@ static inline uint64_t FLB_BSWAP_64(uint64_t value) | |||
|
|||
#endif | |||
|
|||
static inline uint32_t FLB_TO_NATIVE_UINT32(uint32_t value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use FLB_BYTE_ORDER
and FLB_BIG_ENDIAN
instead of these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename this to FLB_UINT32_TO_HOST_BYTE_ORDER
so its intention is clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
38264c0
to
698f607
Compare
698f607
to
87be8b9
Compare
This change ensures correct byte order conversions for timestamp fields within log event decoder and encoder. Added FLB_TO_NATIVE_UINT32 in flb_endian.h. This function checks the host machine's byte order and applies the necessary conversion for 32-bit unsigned integers. Co-authored-by: Bernhard Schmid <[email protected]> Signed-off-by: Mirko Lazarevic <[email protected]>
87be8b9
to
efdf65b
Compare
Hi, @edsiper @leonardo-albertovich @cosmo0920 @pwhelan, |
Hi, @edsiper @leonardo-albertovich @cosmo0920 @pwhelan @fujimotos, these cases failed because the timestamps are dealt with in big endian system style because of an issue in the flb_endian.h file
|
Good catch, do you want to open a PR to fix it or would you rather have me do it? |
@leonardo-albertovich, I have a local patch but not sure if it can work for *BSD, windows, and macOS
|
Yeah, that's the thing, since my initial approach was clearly flawed I think we should do a more thorough check for the second one. Another option would be using a cmake test like this :
The only upside of this would be simplicity and the pressumption that it should work accross systems (unless the compiler is seriously dodgy about optimizations). Which approach do you think would be better? Side note : the volatile qualifier is more or less abused to prevent overly eager compilers from erroneously optimizing the code. |
@leonardo-albertovich I'm good with your solution, it's more generic across all the platforms, please go ahead and open the PR! Thanks in advance! Also I remembered that the cmake file of msgpack-c implemented something very similar to your solution. |
Well, given that it's already implemented I don't see a need to add a different version so I'll just copy and adapt that snippet in a PR. I'll send an update as soon as it's up. |
PR #9256 up, would you mind taking a look at it @rightblank? |
Hi, @cosmo0920, would you please help to trigger the CI for this PR again? |
Hi, @edsiper, the CI looks good now, would you please help to merge this PR? |
…r timestamps (fluent#9196) This change ensures correct byte order conversions for timestamp fields within log event decoder and encoder. Added FLB_TO_NATIVE_UINT32 in flb_endian.h. This function checks the host machine's byte order and applies the necessary conversion for 32-bit unsigned integers. Signed-off-by: Mirko Lazarevic <[email protected]> Co-authored-by: Bernhard Schmid <[email protected]>
This change ensures correct byte order conversions for timestamp fields within log event decoder and encoder.
Added FLB_TO_NATIVE_UINT32 in flb_endian.h. This function checks the host machine's byte order and applies the necessary conversion for 32-bit unsigned integers.
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:
Testing is performed on BigEndian machine using IBM Linux One
Using
nc
command we captured the output.Using
vim
and%!xxd
command we transform a file in Vim to hex representation.Capture before fix:
We observe that the timestamp converts to a date in the past:
Capture after the fix:
We observe that the timestamp converts to the current date (the date when the test was performed):
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
Backporting
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.