xrdpapi: fix MacOS compilation - use SO_NOSIGPIPE instead of MSG_NOSIGNAL

This commit is contained in:
Pavel Roskin 2016-01-30 12:42:40 -08:00
parent 00e70a5c54
commit 5d9dae24c5
1 changed files with 13 additions and 0 deletions

View File

@ -162,6 +162,14 @@ WTSVirtualChannelOpenEx(unsigned int SessionId, const char *pVirtualName,
return wts;
}
/*
* Prevent receiving SIGPIPE on disconnect using either MSG_NOSIGNAL (Linux)
* or SO_NOSIGPIPE (Mac OS X)
*/
#if !defined(MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0
#endif
/*****************************************************************************/
static int
mysend(int sck, const void* adata, int bytes)
@ -170,6 +178,11 @@ mysend(int sck, const void* adata, int bytes)
int error;
const char* data;
#if defined(SO_NOSIGPIPE)
const int on = 1;
setsockopt(sck, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
#endif
data = (const char*)adata;
sent = 0;
while (sent < bytes)