Fix TD_FD_DEBUG
GitOrigin-RevId: fd4ace2ccc618d1e43aff9226aa1d2777aa6874d
This commit is contained in:
parent
4531950aaf
commit
b0ad2ad190
@ -31,7 +31,7 @@ class FdSet {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::unique_lock<std::mutex> guard(mutex_);
|
std::unique_lock<std::mutex> guard(mutex_);
|
||||||
if (fds_.count(fd) > 1) {
|
if (fds_.count(fd) >= 1) {
|
||||||
LOG(FATAL) << "Create duplicated fd: " << fd;
|
LOG(FATAL) << "Create duplicated fd: " << fd;
|
||||||
}
|
}
|
||||||
fds_.insert(fd);
|
fds_.insert(fd);
|
||||||
@ -42,7 +42,10 @@ class FdSet {
|
|||||||
if (is_stdio(fd)) {
|
if (is_stdio(fd)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG(FATAL) << "Unexpected release of non stdio NativeFd: " << fd;
|
if (fds_.count(fd) != 1) {
|
||||||
|
LOG(FATAL) << "Release unknown fd: " << fd;
|
||||||
|
}
|
||||||
|
fds_.erase(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status validate(NativeFd::Fd fd) {
|
Status validate(NativeFd::Fd fd) {
|
||||||
@ -241,6 +244,9 @@ NativeFd::Fd NativeFd::release() {
|
|||||||
VLOG(fd) << *this << " release";
|
VLOG(fd) << *this << " release";
|
||||||
auto res = fd_.get();
|
auto res = fd_.get();
|
||||||
fd_ = {};
|
fd_ = {};
|
||||||
|
#if TD_FD_DEBUG
|
||||||
|
get_fd_set().on_release_fd(res);
|
||||||
|
#endif
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user