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>
static FileFd &get_file_fd() {
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();
};
return result;

View File

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