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,9 +125,11 @@ class PollableFdInfo : private ListNode {
~PollableFdInfo() { ~PollableFdInfo() {
VLOG(fd) << native_fd() << " destroy PollableFdInfo"; VLOG(fd) << native_fd() << " destroy PollableFdInfo";
if (!ExitGuard::is_exited()) {
bool was_locked = lock_.test_and_set(std::memory_order_acquire); bool was_locked = lock_.test_and_set(std::memory_order_acquire);
CHECK(!was_locked); CHECK(!was_locked);
} }
}
void add_flags_from_poll(PollFlags flags) { void add_flags_from_poll(PollFlags flags) {
VLOG(fd) << native_fd() << " add flags from poll " << flags; VLOG(fd) << native_fd() << " add flags from poll " << flags;