summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qnativesocketengine_unix.cpp
diff options
context:
space:
mode:
authorJacek Poplawski <jacek.poplawski@qt.io>2025-06-26 17:54:09 +0200
committerJacek Poplawski <jacek.poplawski@qt.io>2025-07-07 21:20:37 +0200
commit152b566cecbce323dd387550b3bd68c9c338342a (patch)
treed082dcc7b997d4ef19ad6ddd487439ed0b0d47f7 /src/network/socket/qnativesocketengine_unix.cpp
parentcea62956255389083a719ed010c4c42d4b3c1cac (diff)
VxWorks-specific implementation of nativePendingDatagramSize()
Previously, VxWorks was using the generic fallback code path, which attempts to peek UDP datagrams using recvmsg() and checks for MSG_TRUNC to infer size. However, on VxWorks, MSG_TRUNC is not reliably reported, causing incorrect or truncated datagram size detection, and in some cases infinite buffer growth or bad_alloc crashes. Task-number: QTBUG-130078 Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I1ee3704a64c3579142b74198bbc55575355617bb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/network/socket/qnativesocketengine_unix.cpp')
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 6949eec9560..b78d2829704 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -822,6 +822,12 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
recvResult = getsockopt(socketDescriptor, SOL_SOCKET, SO_NREAD, &value, &valuelen);
if (recvResult != -1)
recvResult = value;
+#elif defined(Q_OS_VXWORKS)
+ // VxWorks: use ioctl(FIONREAD) to query the number of bytes available
+ int available = 0;
+ int ioctlResult = ::ioctl(socketDescriptor, FIONREAD, &available);
+ if (ioctlResult != -1)
+ recvResult = available;
#else
// We need to grow the buffer to fit the entire datagram.
// We start at 1500 bytes (the MTU for Ethernet V2), which should catch