Skip to content

Commit

Permalink
Do not callback one SM EVENT_ERROR twice.
Browse files Browse the repository at this point in the history
After #947 (c1ac5f) and #1522 (a128d5) , the EVENT_ERROR leads by
EPOLLERR will be sent to read.vio._cont first and then write.vio._cont.

The reader SM could close or shutdown(WRITE) the VC, but we do not check
these operations before we callback write.vio._cont. The SM would
received EVENT_ERROR twice if write.vio._cont == read.vio._cont.
  • Loading branch information
oknet committed Mar 9, 2017
1 parent c392a35 commit f0c816f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion iocore/net/UnixNetVConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,22 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread)

// if it is a non-temporary error, we should die appropriately
if (err && err != EAGAIN && err != EINTR) {
read_signal_error(nh, vc, err);
Continuation *reader_cont = vc->read.vio._cont;

if (read_signal_error(nh, vc, err) == EVENT_DONE) {
return;
}
// If vc is closed or shutdown(WRITE) in last read_signal_error callback,
// or reader_cont is same as write.vio._cont.
// Then we must clear the write.error to avoid callback EVENT_ERROR to SM.
if (vc->closed || (vc->f.shutdown & NET_VC_SHUTDOWN_WRITE) || reader_cont == vc->write.vio._cont) {
vc->write.error = 0;
}
return;
}

// clear read.error if it is non-fatal error
vc->read.error = 0;
}

// if it is not enabled.
Expand Down Expand Up @@ -450,9 +463,14 @@ write_to_net_io(NetHandler *nh, UnixNetVConnection *vc, EThread *thread)
}

if (err && err != EAGAIN && err != EINTR) {
// Here is differ to net_read_io since read_signal_error always callback first.
// NetHandler::mainNetEvent() is always handle read_ready_list first and then write_ready_list.
write_signal_error(nh, vc, err);
return;
}

// clear write.error if it is non-fatal error.
vc->write.error = 0;
}

// This function will always return true unless
Expand Down

0 comments on commit f0c816f

Please sign in to comment.