1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

pow-testgiver support

This commit is contained in:
ton 2020-07-06 17:07:20 +03:00
parent dbde9c1c40
commit f064b1047a
257 changed files with 6665 additions and 2608 deletions

View file

@ -38,7 +38,9 @@ namespace td {
class FdSet {
public:
void on_create_fd(NativeFd::Fd fd) {
CHECK(is_valid(fd));
if (!is_valid(fd)) {
return;
}
if (is_stdio(fd)) {
return;
}
@ -64,7 +66,9 @@ class FdSet {
}
void on_close_fd(NativeFd::Fd fd) {
CHECK(is_valid(fd));
if (!is_valid(fd)) {
return;
}
if (is_stdio(fd)) {
return;
}
@ -112,7 +116,7 @@ FdSet &get_fd_set() {
Status NativeFd::validate() const {
#if TD_FD_DEBUG
return get_fd_set().validate(fd_.get());
return get_fd_set().validate(fd_);
#else
return Status::OK();
#endif
@ -121,13 +125,13 @@ Status NativeFd::validate() const {
NativeFd::NativeFd(Fd fd) : fd_(fd) {
VLOG(fd) << *this << " create";
#if TD_FD_DEBUG
get_fd_set().on_create_fd(fd_.get());
get_fd_set().on_create_fd(fd_);
#endif
}
NativeFd::NativeFd(Fd fd, bool nolog) : fd_(fd) {
#if TD_FD_DEBUG
get_fd_set().on_create_fd(fd_.get());
get_fd_set().on_create_fd(fd_);
#endif
}
@ -135,18 +139,26 @@ NativeFd::NativeFd(Fd fd, bool nolog) : fd_(fd) {
NativeFd::NativeFd(Socket socket) : fd_(reinterpret_cast<Fd>(socket)), is_socket_(true) {
VLOG(fd) << *this << " create";
#if TD_FD_DEBUG
get_fd_set().on_create_fd(fd_.get());
get_fd_set().on_create_fd(fd_);
#endif
}
#endif
NativeFd &NativeFd::operator=(NativeFd &&from) {
CHECK(this != &from);
close();
fd_ = std::move(from.fd_);
NativeFd::NativeFd(NativeFd &&other) : fd_(other.fd_) {
#if TD_PORT_WINDOWS
is_socket_ = from.is_socket_;
is_socket_ = other.is_socket_;
#endif
other.fd_ = empty_fd();
}
NativeFd &NativeFd::operator=(NativeFd &&other) {
CHECK(this != &other);
close();
fd_ = other.fd_;
#if TD_PORT_WINDOWS
is_socket_ = other.is_socket_;
#endif
other.fd_ = empty_fd();
return *this;
}
@ -155,7 +167,7 @@ NativeFd::~NativeFd() {
}
NativeFd::operator bool() const {
return fd_.get() != empty_fd();
return fd_ != empty_fd();
}
NativeFd::Fd NativeFd::empty_fd() {
@ -167,7 +179,7 @@ NativeFd::Fd NativeFd::empty_fd() {
}
NativeFd::Fd NativeFd::fd() const {
return fd_.get();
return fd_;
}
NativeFd::Socket NativeFd::socket() const {
@ -175,7 +187,7 @@ NativeFd::Socket NativeFd::socket() const {
return fd();
#elif TD_PORT_WINDOWS
CHECK(is_socket_);
return reinterpret_cast<Socket>(fd_.get());
return reinterpret_cast<Socket>(fd_);
#endif
}
@ -239,13 +251,13 @@ void NativeFd::close() {
auto error = OS_ERROR("Close fd");
LOG(ERROR) << error;
}
fd_ = {};
fd_ = empty_fd();
}
NativeFd::Fd NativeFd::release() {
VLOG(fd) << *this << " release";
auto res = fd_.get();
fd_ = {};
auto res = fd_;
fd_ = empty_fd();
#if TD_FD_DEBUG
get_fd_set().on_close_fd(res);
#endif