You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2017/01/05 21:18:13 UTC
[trafficserver] branch master updated: TS-4522: Correct handle zero
is returned from write().
This is an automated email from the ASF dual-hosted git repository.
shinrich pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 40f07b5 TS-4522: Correct handle zero is returned from write().
40f07b5 is described below
commit 40f07b5090493c811f56a3ab4a96d030b8ccb4d8
Author: Oknet <xu...@gmail.com>
AuthorDate: Sun Jun 12 21:08:47 2016 +0800
TS-4522: Correct handle zero is returned from write().
Upon the comment of VConnection class that the cont of
"do_io_write(cont, nbytes, buffer)" should not receive EVENT_EOS event.
Upon man 2 write, zero is returned from write() that indicate 0 bytes
written is not an error.
This closes #701.
---
iocore/net/UnixNetVConnection.cc | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc
index 31d4b9c..f96dadc 100644
--- a/iocore/net/UnixNetVConnection.cc
+++ b/iocore/net/UnixNetVConnection.cc
@@ -550,9 +550,11 @@ write_to_net_io(NetHandler *nh, UnixNetVConnection *vc, EThread *thread)
s->vio.ndone += total_written;
}
+ // A write of 0 makes no sense since we tried to write more than 0.
+ ink_assert(r != 0);
+ // Either we wrote something or got an error.
// check for errors
- if (r <= 0) {
- // If the socket was not ready, add it to the wait list.
+ if (r < 0) { // if the socket was not ready, add to WaitList
if (r == -EAGAIN || r == -ENOTCONN || -r == EINPROGRESS) {
NET_INCREMENT_DYN_STAT(net_calls_to_write_nodata_stat);
if ((needs & EVENTIO_WRITE) == EVENTIO_WRITE) {
@@ -570,12 +572,6 @@ write_to_net_io(NetHandler *nh, UnixNetVConnection *vc, EThread *thread)
return;
}
- if (!r || r == -ECONNRESET) {
- vc->write.triggered = 0;
- write_signal_done(VC_EVENT_EOS, nh, vc);
- return;
- }
-
vc->write.triggered = 0;
write_signal_error(nh, vc, (int)-total_written);
return;
@@ -1071,8 +1067,7 @@ UnixNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &bu
origin_trace_port, (int)r, (int)r, (char *)tiovec[0].iov_base);
} else if (r == 0) {
- TraceOut(origin_trace, get_remote_addr(), get_remote_port(), "CLIENT %s:%d closed connection", origin_trace_ip,
- origin_trace_port);
+ TraceOut(origin_trace, get_remote_addr(), get_remote_port(), "CLIENT %s:%d\tbytes=0", origin_trace_ip, origin_trace_port);
} else {
TraceOut(origin_trace, get_remote_addr(), get_remote_port(), "CLIENT %s:%d error=%s", origin_trace_ip, origin_trace_port,
strerror(errno));
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].