22 #include <glog/logging.h> 33 nullFile_(
"/dev/null", O_RDWR) {}
42 auto& sref =
data_[size_t(fd)];
44 CHECK(sref.compare_exchange_strong(
45 prevState,
IN_USE, std::memory_order_relaxed))
46 <<
"Invalid prev state for fd " << fd <<
": " <<
int(prevState);
55 auto& sref =
data_[size_t(fd)];
58 prevState = sref.load(std::memory_order_relaxed);
62 std::this_thread::sleep_for(std::chrono::milliseconds(1));
63 prevState = sref.load(std::memory_order_relaxed);
66 LOG(
FATAL) <<
"Invalid prev state for fd " << fd <<
": " 70 !sref.compare_exchange_weak(prevState,
FREE, std::memory_order_relaxed));
79 auto& sref =
data_[size_t(fd)];
80 uint8_t prevState = sref.load(std::memory_order_relaxed);
93 LOG(
FATAL) <<
"Invalid prev state for fd " << fd <<
": " 96 }
while (!sref.compare_exchange_weak(
97 prevState, newState, std::memory_order_relaxed));
109 auto& sref =
data_[size_t(fd)];
111 if (!sref.compare_exchange_strong(
112 prevState,
IN_SHUTDOWN, std::memory_order_relaxed)) {
119 if (sref.compare_exchange_strong(
120 prevState,
SHUT_DOWN, std::memory_order_relaxed)) {
125 <<
"Invalid prev state for fd " << fd <<
": " << int(prevState);
130 sref.compare_exchange_strong(prevState,
FREE, std::memory_order_relaxed))
131 <<
"Invalid prev state for fd " << fd <<
": " <<
int(prevState);
136 auto& sref =
data_[size_t(
i)];
137 if (sref.load(std::memory_order_relaxed) ==
IN_USE) {
154 struct linger l = {1, 0};
155 if (
setsockopt(fd, SOL_SOCKET, SO_LINGER, &l,
sizeof(l)) != 0) {
int shutdownNoInt(NetworkSocket fd, int how)
int setsockopt(NetworkSocket s, int level, int optname, const void *optval, socklen_t optlen)
void shutdown(int fd, bool abortive=false)
—— Concurrent Priority Queue Implementation ——
void doShutdown(int fd, bool abortive)
folly::std enable_if::typetoAppendDelimStrImpl const Delimiter, const Tv, Tgtresult sizeof(Ts) >
void shutdownAll(bool abortive=false)
void * checkedCalloc(size_t n, size_t size)
ShutdownSocketSet(int maxFd=1<< 18)
int dup2NoInt(int oldfd, int newfd)
std::unique_ptr< std::atomic< uint8_t >[], Free > data_