Core/Sockets: Always try to send MSG_NOSIGNAL in peer().send()

Fixes RASocket::authenticate crash

"MSG_NOSIGNAL:
If you send() to a remote host which is no longer recv()ing, you'll typically get the signal SIGPIPE. Adding this flag prevents that signal from being raised."

Closes #5040
Thanks to @derex for the hint
This commit is contained in:
Nay
2013-02-11 02:59:07 +00:00
parent 2cf8cdaa80
commit 42e660e2a2
3 changed files with 11 additions and 2 deletions

View File

@@ -138,7 +138,11 @@ ssize_t RealmSocket::noblk_send(ACE_Message_Block &message_block)
return -1;
// Try to send the message directly.
#ifdef MSG_NOSIGNAL
ssize_t n = peer().send(message_block.rd_ptr(), len, MSG_NOSIGNAL);
#else
ssize_t n = peer().send(message_block.rd_ptr(), len);
#endif // MSG_NOSIGNAL
if (n < 0)
{

View File

@@ -372,9 +372,9 @@ int WorldSocket::handle_output_queue (GuardType& g)
const size_t send_len = mblk->length();
#ifdef MSG_NOSIGNAL
ssize_t n = peer().send (mblk->rd_ptr(), send_len, MSG_NOSIGNAL);
ssize_t n = peer().send(mblk->rd_ptr(), send_len, MSG_NOSIGNAL);
#else
ssize_t n = peer().send (mblk->rd_ptr(), send_len);
ssize_t n = peer().send(mblk->rd_ptr(), send_len);
#endif // MSG_NOSIGNAL
if (n == 0)

View File

@@ -336,7 +336,12 @@ int RASocket::subnegotiate()
//! Just send back end of subnegotiation packet
uint8 const reply[2] = {0xFF, 0xF0};
#ifdef MSG_NOSIGNAL
return int(peer().send(reply, 2, MSG_NOSIGNAL));
#else
return int(peer().send(reply, 2));
#endif // MSG_NOSIGNAL
}
int RASocket::svc(void)