Skip to content

Conversation

qpmr
Copy link

@qpmr qpmr commented Apr 24, 2024

We don't need to specify PID in the public log(...) function because logd obtains it from the credentials ([0]), which we don't fill explicitly (no stable api in Rust for that now). However, in our case (logdw socket has enabled passcred option) the kernel does it automatically ([1]).
We also shouldn't pass TID (in public log(...)) because we always use our thread id for that purpose.

[0] https://chromium.googlesource.com/aosp/platform/system/logging/+/refs/heads/factory-ambassador-14265.B/logd/LogListener.cpp#119
[1] https://elixir.bootlin.com/linux/v6.5/source/net/unix/af_unix.c#L1857

We don't need to specify PID in the public log(...) function
because logd obtains it from the credentials ([0]), which
we don't fill explicitly (no stable api in Rust for that now).
However, in our case (logdw socket has enabled passcred option)
the kernel does it automatically ([1]).
We also shouldn't pass TID (in public log(...)) because
we always use our thread id for that purpose.

 [0] https://chromium.googlesource.com/aosp/platform/system/logging/+/refs/heads/factory-ambassador-14265.B/logd/LogListener.cpp#119
 [1] https://elixir.bootlin.com/linux/v6.5/source/net/unix/af_unix.c#L1857
Copy link
Owner

@flxo flxo left a comment

Choose a reason for hiding this comment

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

Passing pid and tid is necessary if the logs are fed from a logging subsystem above logd-logger that operates single threaded and the "source" thread/pid is different from the caller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants