Don't check that Stdin/Stdout/Stderr are unlocked on exit.

This commit is contained in:
levlam 2020-12-24 17:12:50 +03:00
parent 0787c642ce
commit c1a16acd53
2 changed files with 7 additions and 3 deletions

View File

@ -24,7 +24,8 @@ namespace td {
template <int id> template <int id>
static FileFd &get_file_fd() { static FileFd &get_file_fd() {
static FileFd result = FileFd::from_native_fd(NativeFd(id, true)); static FileFd result = FileFd::from_native_fd(NativeFd(id, true));
static auto guard = ScopeExit() + [&] { static ExitGuard exit_guard;
static auto guard = SCOPE_EXIT {
result.move_as_native_fd().release(); result.move_as_native_fd().release();
}; };
return result; return result;

View File

@ -7,6 +7,7 @@
#pragma once #pragma once
#include "td/utils/common.h" #include "td/utils/common.h"
#include "td/utils/ExitGuard.h"
#include "td/utils/format.h" #include "td/utils/format.h"
#include "td/utils/List.h" #include "td/utils/List.h"
#include "td/utils/logging.h" #include "td/utils/logging.h"
@ -124,8 +125,10 @@ class PollableFdInfo : private ListNode {
~PollableFdInfo() { ~PollableFdInfo() {
VLOG(fd) << native_fd() << " destroy PollableFdInfo"; VLOG(fd) << native_fd() << " destroy PollableFdInfo";
bool was_locked = lock_.test_and_set(std::memory_order_acquire); if (!ExitGuard::is_exited()) {
CHECK(!was_locked); bool was_locked = lock_.test_and_set(std::memory_order_acquire);
CHECK(!was_locked);
}
} }
void add_flags_from_poll(PollFlags flags) { void add_flags_from_poll(PollFlags flags) {