mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Reorder error logging before Terminate()
Calling `Terminate()` issues additional syscalls that may clobber the `errno` value. Reordering the log statements ensures we actually log the initial error in `read()`/`write()`. PiperOrigin-RevId: 387576942 Change-Id: I0f9c8c6001e6dc4ca098abe02cd251029f92a737
This commit is contained in:
parent
f14aeee0ad
commit
fd20eb0b4d
|
@ -499,7 +499,7 @@ bool Comms::Send(const void* data, size_t len) {
|
|||
};
|
||||
while (total_sent < len) {
|
||||
ssize_t s;
|
||||
s = op(connection_fd_);
|
||||
s = op(connection_fd_);
|
||||
if (s == -1 && errno == EPIPE) {
|
||||
Terminate();
|
||||
// We do not expect the other end to disappear.
|
||||
|
@ -507,10 +507,10 @@ bool Comms::Send(const void* data, size_t len) {
|
|||
return false;
|
||||
}
|
||||
if (s == -1) {
|
||||
SAPI_RAW_PLOG(ERROR, "write");
|
||||
if (IsFatalError(errno)) {
|
||||
Terminate();
|
||||
}
|
||||
SAPI_RAW_PLOG(ERROR, "write");
|
||||
return false;
|
||||
}
|
||||
if (s == 0) {
|
||||
|
@ -533,12 +533,12 @@ bool Comms::Recv(void* data, size_t len) {
|
|||
};
|
||||
while (total_recv < len) {
|
||||
ssize_t s;
|
||||
s = op(connection_fd_);
|
||||
s = op(connection_fd_);
|
||||
if (s == -1) {
|
||||
SAPI_RAW_PLOG(ERROR, "read");
|
||||
if (IsFatalError(errno)) {
|
||||
Terminate();
|
||||
}
|
||||
SAPI_RAW_PLOG(ERROR, "read");
|
||||
return false;
|
||||
}
|
||||
if (s == 0) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user