[haiku-commits] haiku: hrev49265 - src/add-ons/kernel/network/protocols/tcp headers/posix/sys

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 10 Jun 2015 17:40:31 +0200 (CEST)

hrev49265 adds 1 changeset to branch 'master'
old head: de4adb68a73d588f28319be62a279bf02ca864ee
new head: 4b2d018be4c848b0cfb8d401185fa998ab6cfd90
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=4b2d018be4c8+%5Ede4adb68a73d

----------------------------------------------------------------------------

4b2d018be4c8: Implement MSG_NOSIGNAL

* Part of latest POSIX specification, this prevents send() on a closed
socket to raise a SIGPIPE signal (but EPIPE is returned).

[ Adrien Destugues <pulkomandy@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision: hrev49265
Commit: 4b2d018be4c848b0cfb8d401185fa998ab6cfd90
URL: http://cgit.haiku-os.org/haiku/commit/?id=4b2d018be4c8
Author: Adrien Destugues <pulkomandy@xxxxxxxxx>
Date: Wed Jun 10 15:37:47 2015 UTC

----------------------------------------------------------------------------

2 files changed, 6 insertions(+), 4 deletions(-)
headers/posix/sys/socket.h | 1 +
src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp | 9 +++++----

----------------------------------------------------------------------------

diff --git a/headers/posix/sys/socket.h b/headers/posix/sys/socket.h
index 16547a8..ec67563 100644
--- a/headers/posix/sys/socket.h
+++ b/headers/posix/sys/socket.h
@@ -121,6 +121,7 @@ struct msghdr {
#define MSG_BCAST 0x0100 /* this message rec'd as broadcast */
#define MSG_MCAST 0x0200 /* this message rec'd as multicast */
#define MSG_EOF 0x0400 /* data completes connection */
+#define MSG_NOSIGNAL 0x0800 /* don't raise SIGPIPE if socket is closed */

struct cmsghdr {
socklen_t cmsg_len;
diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp
b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp
index ce4769b..20261ca 100644
--- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp
+++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp
@@ -785,8 +785,10 @@ TCPEndpoint::SendData(net_buffer *buffer)
MutexLocker lock(fLock);

TRACE("SendData(buffer %p, size %lu, flags %lx) [total %lu bytes, has
%lu]",
- buffer, buffer->size, buffer->flags, fSendQueue.Size(),
- fSendQueue.Free());
+ buffer, buffer->size, buffer->flags, fSendQueue.Size(),
+ fSendQueue.Free());
+
+ uint32 flags = buffer->flags;

if (fState == CLOSED)
return ENOTCONN;
@@ -794,12 +796,11 @@ TCPEndpoint::SendData(net_buffer *buffer)
return EDESTADDRREQ;
if (!is_writable(fState) && !is_establishing(fState)) {
// we only send signals when called from userland
- if (gStackModule->is_syscall())
+ if (gStackModule->is_syscall() && (flags & MSG_NOSIGNAL != 0))
send_signal(find_thread(NULL), SIGPIPE);
return EPIPE;
}

- uint32 flags = buffer->flags;
size_t left = buffer->size;

bigtime_t timeout = absolute_timeout(socket->send.timeout);


Other related posts: