Suppress sigpipe in sender thread.

This commit is contained in:
lotodore
2007-10-30 16:59:47 +00:00
parent 9cf398d3e0
commit 7000722d75
4 changed files with 8 additions and 8 deletions
+6 -2
View File
@@ -20,6 +20,7 @@
#include <net/senderthread.h> #include <net/senderthread.h>
#include <net/sendercallback.h> #include <net/sendercallback.h>
#include <net/socket_msg.h> #include <net/socket_msg.h>
#include <net/socket_helper.h>
#include <cstring> #include <cstring>
#include <core/boost/timers.hpp> #include <core/boost/timers.hpp>
@@ -27,7 +28,10 @@
using namespace std; using namespace std;
#define SEND_ERROR_TIMEOUT_MSEC 20000 #define SEND_ERROR_TIMEOUT_MSEC 20000
#define SEND_TIMEOUT_MSEC 10
#define SEND_QUEUE_SIZE 1000
#define SEND_LOW_PRIO_QUEUE_SIZE 50000
SenderThread::SenderThread(SenderCallback &cb) SenderThread::SenderThread(SenderCallback &cb)
: m_tmpOutBufSize(0), m_callback(cb) : m_tmpOutBufSize(0), m_callback(cb)
@@ -193,7 +197,7 @@ SenderThread::Main()
if (selectResult > 0) // send is possible if (selectResult > 0) // send is possible
{ {
// send next chunk of data // send next chunk of data
int bytesSent = send(tmpSocket, m_tmpOutBuf, m_tmpOutBufSize, 0); int bytesSent = send(tmpSocket, m_tmpOutBuf, m_tmpOutBufSize, SOCKET_SEND_FLAGS);
if (!IS_VALID_SEND(bytesSent)) if (!IS_VALID_SEND(bytesSent))
{ {
-2
View File
@@ -26,14 +26,12 @@
#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; using namespace std;
bool bool
socket_startup() socket_startup()
{ {
signal(SIGPIPE, SIG_IGN);
return true; return true;
} }
-4
View File
@@ -22,7 +22,6 @@
#define _SENDERTHREAD_H_ #define _SENDERTHREAD_H_
#include <core/thread.h> #include <core/thread.h>
#include <net/socket_helper.h>
#include <net/sessiondata.h> #include <net/sessiondata.h>
#include <net/netpacket.h> #include <net/netpacket.h>
#include <net/sendercallback.h> #include <net/sendercallback.h>
@@ -31,9 +30,6 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#define SENDER_THREAD_TERMINATE_TIMEOUT THREAD_WAIT_INFINITE #define SENDER_THREAD_TERMINATE_TIMEOUT THREAD_WAIT_INFINITE
#define SEND_TIMEOUT_MSEC 10
#define SEND_QUEUE_SIZE 1000
#define SEND_LOW_PRIO_QUEUE_SIZE 50000
class SenderThread : public Thread class SenderThread : public Thread
{ {
+2
View File
@@ -34,6 +34,7 @@
#define SOCKET_ERR_WOULDBLOCK WSAEWOULDBLOCK #define SOCKET_ERR_WOULDBLOCK WSAEWOULDBLOCK
#define SOCKET_ERR_NOTCONN WSAENOTCONN #define SOCKET_ERR_NOTCONN WSAENOTCONN
#define SOCKET_ERR_NOTSOCK WSAENOTSOCK #define SOCKET_ERR_NOTSOCK WSAENOTSOCK
#define SOCKET_SEND_FLAGS 0
#ifndef IPV6_V6ONLY #ifndef IPV6_V6ONLY
#define IPV6_V6ONLY 27 #define IPV6_V6ONLY 27
@@ -62,6 +63,7 @@ typedef unsigned char u_char;
#define SOCKET_ERR_WOULDBLOCK EINPROGRESS #define SOCKET_ERR_WOULDBLOCK EINPROGRESS
#define SOCKET_ERR_NOTCONN ENOTCONN #define SOCKET_ERR_NOTCONN ENOTCONN
#define SOCKET_ERR_NOTSOCK ENOTSOCK #define SOCKET_ERR_NOTSOCK ENOTSOCK
#define SOCKET_SEND_FLAGS MSG_NOSIGNAL
#endif #endif