Fix missing MSG_NOSIGNAL and TCP_KEEPIDLE on macos
This commit is contained in:
parent
143d7d391a
commit
255812c80e
|
|
@ -17,6 +17,10 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <Nazara/Network/Debug.hpp>
|
#include <Nazara/Network/Debug.hpp>
|
||||||
|
|
||||||
|
#if !defined(TCP_KEEPIDLE) && defined(TCP_KEEPALIVE)
|
||||||
|
#define TCP_KEEPIDLE TCP_KEEPALIVE // see -> https://gitlab.freedesktop.org/spice/usbredir/-/issues/9
|
||||||
|
#endi
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
constexpr int SOCKET_ERROR = -1;
|
constexpr int SOCKET_ERROR = -1;
|
||||||
|
|
@ -597,8 +601,11 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
IpAddress senderIp;
|
IpAddress senderIp;
|
||||||
|
#if not defined(MSG_NOSIGNAL)
|
||||||
int byteRead = recvmsg(handle, &msgHdr, MSG_NOSIGNAL);
|
int byteRead = recvmsg(handle, &msgHdr, MSG_NOSIGNAL);
|
||||||
|
#else
|
||||||
|
int byteRead = recvmsg(handle, &msgHdr, 0);
|
||||||
|
#endif
|
||||||
if (byteRead == -1)
|
if (byteRead == -1)
|
||||||
{
|
{
|
||||||
int errorCode = GetLastErrorCode();
|
int errorCode = GetLastErrorCode();
|
||||||
|
|
@ -714,7 +721,12 @@ namespace Nz
|
||||||
msgHdr.msg_iov = sysBuffers.data();
|
msgHdr.msg_iov = sysBuffers.data();
|
||||||
msgHdr.msg_iovlen = static_cast<int>(bufferCount);
|
msgHdr.msg_iovlen = static_cast<int>(bufferCount);
|
||||||
|
|
||||||
|
#if not defined(MSG_NOSIGNAL)
|
||||||
int byteSent = sendmsg(handle, &msgHdr, MSG_NOSIGNAL);
|
int byteSent = sendmsg(handle, &msgHdr, MSG_NOSIGNAL);
|
||||||
|
#else
|
||||||
|
int byteSent = sendmsg(handle, &msgHdr, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (byteSent == SOCKET_ERROR)
|
if (byteSent == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
int errorCode = GetLastErrorCode();
|
int errorCode = GetLastErrorCode();
|
||||||
|
|
@ -896,6 +908,18 @@ namespace Nz
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = SocketError_NoError;
|
*error = SocketError_NoError;
|
||||||
|
|
||||||
|
#if not defined(MSG_NOSIGNAL) // -> https://github.com/intel/parameter-framework/pull/133/files
|
||||||
|
//There is no MSG_NOSIGNAL on macos
|
||||||
|
const int set = 1;
|
||||||
|
if (setsockopt(handle, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(set)) == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
if (error)
|
||||||
|
*error = TranslateErrnoToSocketError(GetLastErrorCode());
|
||||||
|
|
||||||
|
return false; //< Error
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue