TS-4522: Should signal SM with EVENT_ERROR on error in write_to_net_io()#701
TS-4522: Should signal SM with EVENT_ERROR on error in write_to_net_io()#701oknet wants to merge 1 commit intoapache:masterfrom
Conversation
|
Jenkins workspaces in disarray due to previous failures (sigh), trying again. [approve ci]. |
|
FreeBSD build successful! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/224/ for details. |
|
Linux build successful! See https://ci.trafficserver.apache.org/job/Github-Linux/121/ for details. |
|
This begs the question of why |
|
@jpeach VC_EVENT_EOS indicates socket fd is closed. VC_EVENT_ERROR means meet a error and can not going on. Looking around the comment on I_VConnection.h about do_io_read and do_io_write. VC_EVENT_EOS is not introduced in do_io_write, only VC_EVENT_ERROR. Is VC_EVENT_EOS callbacked only do_io_read first ? |
|
@jpeach ECONNRESET is only found in man 2 send/sendto/sendmsg. obviously EPIPE for write() the same as ECONNRESET for send()/sendto()/sendmsg(). And write() is called in load_buffer_and_write(). |
|
AFAICT we would get By the same logic, I agree that handling So consider: diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc
index b52985c..bc9764d 100644
--- a/iocore/net/UnixNetVConnection.cc
+++ b/iocore/net/UnixNetVConnection.cc
@@ -535,11 +535,9 @@ 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;
- }
+ // A write of 0 makes no sense since we tried to write more than 0. Either
+ // we wrote something or we got an error.
+ ink_assert(r < 0);
vc->write.triggered = 0;
write_signal_error(nh, vc, (int)-total_written);
return; |
|
I'm try do some test and get result below: SSLNetVConnection::load_buffer_and_write() would return 0 on SSL_ERROR_NONE, but I believe SSL_ERROR_NONE never occur on SSLBufferWrite(). |
|
@shinrich I remember that SSL_write would return “SSL_WANT_READ” error code. from: https://www.openssl.org/docs/manmaster/ssl/SSL_write.html Is the code added for handle SSL_ERROR_WANT_READ or related ? |
|
@oknet the SSL_write logic is handled in SSLUtils/SSLNetVConnection. The openssl library does its own read/write for the most part, and that logic handles the SSL_ERROR_WANT_READ case. In the SSL handshake we rely on UnixNetVConnection. |
|
I think that I agree with @jpeach's comments and code suggestion. Returning _EOS really only makes sense for read. I think by the time you get to that point in the code it is a failure. |
|
@oknet How do you want to proceed with this? Are you making an update to the PR to address some of the review suggestions? |
|
@oknet ping ? |
|
agree with @jpeach 's comments and code suggestion. With minor modify that only assert on ( r == 0 ) because of (r < 0) means error on write(). |
|
change the assert condition from (r==0) to (r!=0) |
|
Copy&Paste bug in load_buffer_and_write() if 0 returned from write() or writev(). |
|
Status on this? |
|
@jpeach Could you please review this PR? I think this is final version. |
|
Linux build successful! See https://ci.trafficserver.apache.org/job/Github-Linux/758/ for details. |
|
FreeBSD build successful! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/862/ for details. |
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.
|
FreeBSD build successful! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/863/ for details. |
|
Linux build successful! See https://ci.trafficserver.apache.org/job/Github-Linux/759/ for details. |
|
FreeBSD build successful! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/864/ for details. |
|
Linux build successful! See https://ci.trafficserver.apache.org/job/Github-Linux/760/ for details. |
- Add default configuration file. - Re-order the documentation related to the configuration of the JSONRPC node, this now follows the existing documentation style. (cherry picked from commit d68ff96) Conflicts: configs/jsonrpc.yaml.default
man 2 write, Return value, On Success, the number of bytes written is returned (zero indicates nothing was written). On error, -1 is returned, and errno is set appropriately.