fix(SocketImpl): available() #3834

This commit is contained in:
Alex Fabijanic 2022-10-23 12:30:59 +02:00
parent 2effb38396
commit 1319d3f7ef
2 changed files with 14 additions and 1 deletions

View File

@ -0,0 +1,13 @@
#!/bin/bash
bin/Linux/x86_64/HTTPFormServer &
sleep 1
curl --noproxy '*' -s http://127.0.0.1:9980 >/dev/null
curl --noproxy '*' -s http://127.0.0.1:9980 >/dev/null
terminated_at="$(date +%s)"
echo "Terminating HTTPFormServer"
pkill HTTPFormServer
wait
terminated_in="$(($(date +%s) - terminated_at))"
echo "HTTPFormServer took ${terminated_in} seconds to terminate"

View File

@ -619,7 +619,7 @@ int SocketImpl::available()
int result = 0;
ioctl(FIONREAD, result);
#if (POCO_OS != POCO_OS_LINUX)
if (type() == SOCKET_TYPE_DATAGRAM)
if (result && (type() == SOCKET_TYPE_DATAGRAM))
{
std::vector<char> buf(result);
result = recvfrom(sockfd(), &buf[0], result, MSG_PEEK, NULL, NULL);