MCPcopy Create free account
hub / github.com/apache/brpc / WaitEpollOut

Method WaitEpollOut

src/brpc/socket.cpp:1221–1244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1219}
1220
1221int Socket::WaitEpollOut(int fd, bool pollin, const timespec* abstime) {
1222 if (!ValidFileDescriptor(fd)) {
1223 return 0;
1224 }
1225 // Do not need to check addressable since it will be called by
1226 // health checker which called `SetFailed' before
1227 const int expected_val = _epollout_butex->load(butil::memory_order_relaxed);
1228 if (_io_event.RegisterEvent(fd, pollin) != 0) {
1229 return -1;
1230 }
1231
1232 int rc = bthread::butex_wait(_epollout_butex, expected_val, abstime);
1233 const int saved_errno = errno;
1234 if (rc < 0 && errno == EWOULDBLOCK) {
1235 // Could be writable or spurious wakeup
1236 rc = 0;
1237 }
1238 // Ignore return value since `fd' might have been removed
1239 // by `RemoveConsumer' in `SetFailed'
1240 butil::ignore_result(_io_event.UnregisterEvent(fd, pollin));
1241 errno = saved_errno;
1242 // Could be writable or spurious wakeup (by former epollout)
1243 return rc;
1244}
1245
1246int Socket::Connect(const timespec* abstime,
1247 int (*on_connect)(int, int, void*), void* data) {

Callers 2

KeepWriteMethod · 0.45
WriteToFdMethod · 0.45

Calls 5

butex_waitFunction · 0.85
ignore_resultFunction · 0.85
loadMethod · 0.45
RegisterEventMethod · 0.45
UnregisterEventMethod · 0.45

Tested by

no test coverage detected