WorldServer/RA: Implement MSG_NOSIGNAL in RASocket send.

Used to prevent raising SIGPIPE when the host are no longer recv()ing
This commit is contained in:
kaelima committed 2013-01-15 16:10:59 +01:00
1 parent 7cb9bf1c2c
commit c7ce94ee3d
1 file changed
+9 -4
@@ -65,7 +65,13 @@ int RASocket::handle_close(ACE_HANDLE, ACE_Reactor_Mask)
int RASocket::send(const std::string& line)
{
return size_t(peer().send(line.c_str(), line.length())) == line.length() ? 0 : -1;
#ifdef MSG_NOSIGNAL
ssize_t n = peer().send(line.c_str(), line.length(), MSG_NOSIGNAL);
#else
ssize_t n = peer().send(line.c_str(), line.length());
#endif // MSG_NOSIGNAL
return n == line.length() ? 0 : -1;
}
int RASocket::recv_line(ACE_Message_Block& buffer)
@@ -160,7 +166,7 @@ int RASocket::process_command(const std::string& command)
break;
}
if (size_t(peer().send(mb->rd_ptr(), mb->length())) != mb->length())
if (send(std::string(mb->rd_ptr(), mb->length())) == -1)
{
mb->release();
return -1;
@@ -356,8 +362,7 @@ int RASocket::svc(void)
for (;;)
{
// show prompt
const char* tc_prompt = "TC> ";
if (size_t(peer().send(tc_prompt, strlen(tc_prompt))) != strlen(tc_prompt))
if (send("TC> ") == -1)
return -1;
std::string line;