I've been looking at libbinder.so
, specifically IPCThreadState.cpp, line 781
In libbinder.so
, writes are serialized using this line: TextOutput::Bundle _b(alog);
which locks a mutex.
The "call tree" for the writes is:
alog << "Sending commands to driver: " << indent;
template<typename T>
TextOutput& operator<<(TextOutput& to, const T& val)
{
std::stringstream strbuf;
strbuf << val;
std::string str = strbuf.str();
to.print(str.c_str(), str.size());
return to;
}
status_t BufferedTextOutput::print(const char* txt, size_t len)
virtual status_t writeLines(const struct iovec& vec, size_t N)
{
//android_writevLog(&vec, N); <-- this is now a no-op
if (N != 1) ALOGI("WARNING: writeLines N=%zu\n", N);
ALOGI("%.*s", (int)vec.iov_len, (const char*) vec.iov_base);
return NO_ERROR;
}
#define ALOGI(x...) fprintf(stderr, "svcmgr: " x)
I understand how writes to log are serialized within libbinder.so
but how are writes serialized between multiple .so
libraries?
libbinder.so
writes to stderr
but surely there are other libs that also write to stderr
.