[ 
https://issues.apache.org/jira/browse/TS-4522?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15326431#comment-15326431
 ] 

ASF GitHub Bot commented on TS-4522:
------------------------------------

GitHub user oknet opened a pull request:

    https://github.com/apache/trafficserver/pull/701

    TS-4522: check EPIPE instead r==0

    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.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/oknet/trafficserver patch-14

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/trafficserver/pull/701.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #701
    
----
commit d381a2d4ea5511696484f278b9aa80e4bdea545f
Author: Oknet <[email protected]>
Date:   2016-06-12T13:08:47Z

    TS-4522: check EPIPE instead r==0
    
    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.

----


> did not check EPIPE on write_to_net_io
> --------------------------------------
>
>                 Key: TS-4522
>                 URL: https://issues.apache.org/jira/browse/TS-4522
>             Project: Traffic Server
>          Issue Type: Bug
>          Components: Core, Network
>            Reporter: Oknet Xu
>
> On a closed socket fd:
> read(socketfd) return 0
> write(socketfd) return EPIPE
> In the write_to_net_io, we check the return value of write() with the same 
> way to read().
> {code}
>     if (!r || r == -ECONNRESET) {
> {code}
> The bug makes no VC_EVENT_EOS callbacked while write_to_net_io, but 
> VC_EVENT_ERROR instead. 
> full code here:
> {code}
>   int64_t r = vc->load_buffer_and_write(towrite, buf, total_written, needs);
>   if (total_written > 0) {
>     NET_SUM_DYN_STAT(net_write_bytes_stat, total_written);
>     s->vio.ndone += total_written;
>   }
>   // check for errors
>   if (r <= 0) { // if the socket was not ready,add to WaitList
>     if (r == -EAGAIN || r == -ENOTCONN) {
>       NET_INCREMENT_DYN_STAT(net_calls_to_write_nodata_stat);
>       if ((needs & EVENTIO_WRITE) == EVENTIO_WRITE) {
>         vc->write.triggered = 0;
>         nh->write_ready_list.remove(vc);
>         write_reschedule(nh, vc);
>       }
>       if ((needs & EVENTIO_READ) == EVENTIO_READ) {
>         vc->read.triggered = 0;
>         nh->read_ready_list.remove(vc);
>         read_reschedule(nh, vc);
>       }
>       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;
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to