Trying to fix SIGPIPE issue on server (linux).
This commit is contained in:
@@ -65,6 +65,8 @@ ReceiverHelper::Recv(SOCKET sock, ReceiveBuffer &buf)
|
|||||||
|
|
||||||
if (!IS_VALID_RECV(bytesRecvd))
|
if (!IS_VALID_RECV(bytesRecvd))
|
||||||
{
|
{
|
||||||
|
int errCode = SOCKET_ERRNO();
|
||||||
|
if (errCode != SOCKET_ERR_WOULDBLOCK)
|
||||||
throw NetException(__FILE__, __LINE__, ERR_SOCK_RECV_FAILED, SOCKET_ERRNO());
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_RECV_FAILED, SOCKET_ERRNO());
|
||||||
}
|
}
|
||||||
else if (bytesRecvd == 0)
|
else if (bytesRecvd == 0)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define SEND_ERROR_TIMEOUT_MSEC 2000
|
#define SEND_ERROR_TIMEOUT_MSEC 20000
|
||||||
|
|
||||||
SenderThread::SenderThread(SenderCallback &cb)
|
SenderThread::SenderThread(SenderCallback &cb)
|
||||||
: m_tmpOutBufSize(0), m_callback(cb)
|
: m_tmpOutBufSize(0), m_callback(cb)
|
||||||
|
|||||||
@@ -183,6 +183,11 @@ ServerAcceptThread::AcceptLoop()
|
|||||||
{
|
{
|
||||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_ACCEPT_FAILED, SOCKET_ERRNO());
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_ACCEPT_FAILED, SOCKET_ERRNO());
|
||||||
}
|
}
|
||||||
|
unsigned long mode = 1;
|
||||||
|
if (IOCTLSOCKET(tmpData->GetSocket(), FIONBIO, &mode) == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
throw ServerException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
||||||
|
}
|
||||||
// Optional call - don't check return value.
|
// Optional call - don't check return value.
|
||||||
// Enable keepalive - won't be of much use but better than nothing.
|
// Enable keepalive - won't be of much use but better than nothing.
|
||||||
int keepalive = 1;
|
int keepalive = 1;
|
||||||
|
|||||||
@@ -26,10 +26,14 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
socket_startup()
|
socket_startup()
|
||||||
{
|
{
|
||||||
|
signal(SIGPIPE, SIG_IGN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user