if (!err || !al)
return;
- LogTagsErrors lte;
- if (err->xerrno == ETIMEDOUT || err->type == ERR_READ_TIMEOUT)
- lte.timedout = true;
- else if (err->type != ERR_NONE)
- lte.aborted = true;
+ const auto lte = LogTagsErrors::FromErrno(err->type == ERR_READ_TIMEOUT ? ETIMEDOUT : err->xerrno);
al->cache.code.err.update(lte);
if (!err->detail) {
static const auto d = MakeNamedErrorDetail("WITH_SERVER");
aborted = aborted || other.aborted;
}
+LogTagsErrors
+LogTagsErrors::FromErrno(const int errNo)
+{
+ LogTagsErrors lte;
+ lte.timedout = (errNo == ETIMEDOUT);
+ lte.aborted = !lte.timedout; // intentionally true for zero errNo
+ return lte;
+}
+
/* LogTags */
// old deprecated tag strings
class LogTagsErrors
{
public:
+ /// constructs an object matching errno(3) of a failed I/O call
+ static LogTagsErrors FromErrno(int errNo);
+
/// Update each of this object flags to "set" if the corresponding
/// flag of the given object is set
void update(const LogTagsErrors &other);
// case Comm::COMM_ERROR:
default: // no other flags should ever occur
debugs(33, 2, io.conn << ": got flag " << rd.flag << "; " << xstrerr(rd.xerrno));
- LogTagsErrors lte;
- lte.timedout = rd.xerrno == ETIMEDOUT;
- lte.aborted = !lte.timedout; // intentionally true for zero rd.xerrno
- terminateAll(Error(ERR_READ_ERROR, SysErrorDetail::NewIfAny(rd.xerrno)), lte);
+ terminateAll(Error(ERR_READ_ERROR, SysErrorDetail::NewIfAny(rd.xerrno)), LogTagsErrors::FromErrno(rd.xerrno));
return;
}
if (io.flag) {
debugs(33, 2, "bailing after a write failure: " << xstrerr(io.xerrno));
- LogTagsErrors lte;
- lte.timedout = io.xerrno == ETIMEDOUT;
- lte.aborted = !lte.timedout; // intentionally true for zero io.xerrno
- terminateAll(Error(ERR_WRITE_ERROR, SysErrorDetail::NewIfAny(io.xerrno)), lte);
+ terminateAll(Error(ERR_WRITE_ERROR, SysErrorDetail::NewIfAny(io.xerrno)), LogTagsErrors::FromErrno(io.xerrno));
return;
}