MCPcopy Create free account
hub / github.com/apache/thrift / hasPendingDataToRead

Method hasPendingDataToRead

lib/cpp/src/thrift/transport/TSocket.cpp:190–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190bool TSocket::hasPendingDataToRead() {
191 if (!isOpen()) {
192 return false;
193 }
194
195 int32_t retries = 0;
196 THRIFT_IOCTL_SOCKET_NUM_BYTES_TYPE numBytesAvailable;
197try_again:
198 int r = THRIFT_IOCTL_SOCKET(socket_, FIONREAD, &numBytesAvailable);
199 if (r == -1) {
200 int errno_copy = THRIFT_GET_SOCKET_ERROR;
201 if (errno_copy == THRIFT_EINTR && (retries++ < maxRecvRetries_)) {
202 goto try_again;
203 }
204 TOutput::instance().perror("TSocket::hasPendingDataToRead() THRIFT_IOCTL_SOCKET() " + getSocketInfo(), errno_copy);
205 throw TTransportException(TTransportException::UNKNOWN, "Unknown", errno_copy);
206 }
207 return numBytesAvailable > 0;
208}
209
210bool TSocket::isOpen() const {
211 return (socket_ != THRIFT_INVALID_SOCKET);

Callers 1

workSocketMethod · 0.45

Calls 2

TTransportExceptionClass · 0.70
perrorMethod · 0.45

Tested by

no test coverage detected