summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWushin <pasekei@gmail.com>2015-08-16 14:02:35 -0500
committerWushin <pasekei@gmail.com>2015-08-16 14:02:35 -0500
commit1ecb7f8ed0091ecf5d63815006ca3e80ef6cfd97 (patch)
treebe7db70b632cefd3a639ce3afe8d3f6f22bdbd6d
parent98e908eec29e9b5b02fb7d7bf29886dfeb98c7dd (diff)
parentf5764cf03f7ba94249a0e517f12d7918bb1ecd42 (diff)
downloadtmwa-1ecb7f8ed0091ecf5d63815006ca3e80ef6cfd97.tar.gz
tmwa-1ecb7f8ed0091ecf5d63815006ca3e80ef6cfd97.tar.bz2
tmwa-1ecb7f8ed0091ecf5d63815006ca3e80ef6cfd97.tar.xz
tmwa-1ecb7f8ed0091ecf5d63815006ca3e80ef6cfd97.zip
Merge pull request #132 from mekolat/pipe-closed
replace socket write with send with MSG_NOSIGNAL
-rw-r--r--src/io/fd.cpp30
-rw-r--r--src/io/fd.hpp10
-rw-r--r--src/net/socket.cpp2
3 files changed, 41 insertions, 1 deletions
diff --git a/src/io/fd.cpp b/src/io/fd.cpp
index bb0bbd5..918fd5e 100644
--- a/src/io/fd.cpp
+++ b/src/io/fd.cpp
@@ -75,6 +75,36 @@ namespace io
{
return ::write(fd, buf, count);
}
+ ssize_t FD::send(const void *buf, size_t count, int flags)
+ {
+ return ::send(fd, buf, count, flags);
+ }
+ ssize_t FD::sendmsg(const struct msghdr *msg, int flags)
+ {
+ return ::sendmsg(fd, msg, flags);
+ }
+ int FD::sendmmsg(struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags)
+ {
+ return ::sendmmsg(fd, msgvec, vlen, flags);
+ }
+ ssize_t FD::sendto(const void *buf, size_t count, int flags,
+ const struct sockaddr *dest_addr, socklen_t addrlen)
+ {
+ return ::sendto(fd, buf, count, flags, dest_addr, addrlen);
+ }
+ ssize_t FD::recv(void *buf, size_t count, int flags)
+ {
+ return ::recv(fd, buf, count, flags);
+ }
+ ssize_t FD::recvfrom(void *buf, size_t count, int flags,
+ struct sockaddr *src_addr, socklen_t *addrlen)
+ {
+ return ::recvfrom(fd, buf, count, flags, src_addr, addrlen);
+ }
+ ssize_t FD::recvmsg(struct msghdr *msg, int flags)
+ {
+ return ::recvmsg(fd, msg, flags);
+ }
ssize_t FD::pread(void *buf, size_t count, off_t offset)
{
return ::pread(fd, buf, count, offset);
diff --git a/src/io/fd.hpp b/src/io/fd.hpp
index 03a8b44..517c7af 100644
--- a/src/io/fd.hpp
+++ b/src/io/fd.hpp
@@ -77,6 +77,16 @@ namespace io
ssize_t read(void *buf, size_t count);
ssize_t write(const void *buf, size_t count);
+ ssize_t send(const void *buf, size_t count, int flags);
+ ssize_t sendto(const void *buf, size_t count, int flags,
+ const struct sockaddr *dest_addr, socklen_t addrlen);
+ ssize_t sendmsg(const struct msghdr *msg, int flags);
+ int sendmmsg(struct mmsghdr *msgvec, unsigned int vlen,
+ unsigned int flags);
+ ssize_t recv(void *buf, size_t len, int flags);
+ ssize_t recvfrom(void *buf, size_t len, int flags,
+ struct sockaddr *src_addr, socklen_t *addrlen);
+ ssize_t recvmsg(struct msghdr *msg, int flags);
ssize_t pread(void *buf, size_t count, off_t offset);
ssize_t pwrite(const void *buf, size_t count, off_t offset);
ssize_t readv(const struct iovec *iov, int iovcnt);
diff --git a/src/net/socket.cpp b/src/net/socket.cpp
index fce45fb..7f71310 100644
--- a/src/net/socket.cpp
+++ b/src/net/socket.cpp
@@ -153,7 +153,7 @@ void recv_to_fifo(Session *s)
static
void send_from_fifo(Session *s)
{
- ssize_t len = s->fd.write(&s->wdata[0], s->wdata_size);
+ ssize_t len = s->fd.send(&s->wdata[0], s->wdata_size, MSG_NOSIGNAL);
if (len > 0)
{