in gloo/transport/ibverbs/device.cc [178:212]
void Device::loop() {
int rv;
auto flags = fcntl(comp_channel_->fd, F_GETFL);
GLOO_ENFORCE_NE(flags, -1);
rv = fcntl(comp_channel_->fd, F_SETFL, flags | O_NONBLOCK);
GLOO_ENFORCE_NE(rv, -1);
struct pollfd pfd;
pfd.fd = comp_channel_->fd;
pfd.events = POLLIN;
pfd.revents = 0;
while (!done_) {
do {
rv = poll(&pfd, 1, 10);
} while ((rv == 0 && !done_) || (rv == -1 && errno == EINTR));
GLOO_ENFORCE_NE(rv, -1);
if (done_ && rv == 0) {
break;
}
struct ibv_cq* cq;
void* cqContext;
rv = ibv_get_cq_event(comp_channel_, &cq, &cqContext);
GLOO_ENFORCE_EQ(rv, 0, "ibv_get_cq_event");
// Completion queue context is a Pair*.
// Delegate handling of this event to the pair itself.
Pair* pair = static_cast<Pair*>(cqContext);
pair->handleCompletionEvent();
}
}