debuggerd_fallback: fix fd leak.
Previously, when we received simultaneous dump requests, we were CASing a file descriptor value into a variable, and then failing to close it if the CAS failed. Bug: http://b/118412443 Test: debuggerd_test Change-Id: I075c35a239426002eb9416da3d268c3d1a18e9d2
This commit is contained in:
parent
b59a38d343
commit
08163cb032
1 changed files with 3 additions and 2 deletions
|
@ -250,11 +250,12 @@ static void trace_handler(siginfo_t* info, ucontext_t* ucontext) {
|
|||
}
|
||||
|
||||
uint64_t expected = pack_thread_fd(-1, -1);
|
||||
if (!trace_output.compare_exchange_strong(expected,
|
||||
pack_thread_fd(tid, pipe_write.release()))) {
|
||||
int sent_fd = pipe_write.release();
|
||||
if (!trace_output.compare_exchange_strong(expected, pack_thread_fd(tid, sent_fd))) {
|
||||
auto [tid, fd] = unpack_thread_fd(expected);
|
||||
async_safe_format_log(ANDROID_LOG_ERROR, "libc",
|
||||
"thread %d is already outputting to fd %d?", tid, fd);
|
||||
close(sent_fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue