QNativeSocketEngine: Simplify nativeHasPendingDatagrams()
We don't need the sockaddr structure. Change-Id: I6e9274c1e7444ad48c81fffd14da826387d72f83 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
a9ff368ac7
commit
306a6b9dec
@ -829,18 +829,10 @@ qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const
|
|||||||
|
|
||||||
bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
|
bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
|
||||||
{
|
{
|
||||||
// Create a sockaddr struct and reset its port number.
|
// Peek 1 bytes into the next message.
|
||||||
qt_sockaddr storage;
|
|
||||||
QT_SOCKLEN_T storageSize = sizeof(storage);
|
|
||||||
memset(&storage, 0, storageSize);
|
|
||||||
|
|
||||||
// Peek 1 bytes into the next message. The size of the message may
|
|
||||||
// well be 0, so we can't check recvfrom's return value.
|
|
||||||
ssize_t readBytes;
|
ssize_t readBytes;
|
||||||
do {
|
char c;
|
||||||
char c;
|
EINTR_LOOP(readBytes, ::recv(socketDescriptor, &c, 1, MSG_PEEK));
|
||||||
readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
|
|
||||||
} while (readBytes == -1 && errno == EINTR);
|
|
||||||
|
|
||||||
// If there's no error, or if our buffer was too small, there must be a
|
// If there's no error, or if our buffer was too small, there must be a
|
||||||
// pending datagram.
|
// pending datagram.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user