linux: silence logs on client disconnect

When all Crashpad clients have closed their crash handling sockets,
the handler's recvmsg() returns 0 and doesn't include any credentials.
Silence error logs for this normally occurring case.

Change-Id: I56acf3b38c8e95a9bbaa9bff04e0a6859a194e66
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1816286
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Joshua Peraza 2019-09-20 11:19:38 -07:00 committed by Commit Bot
parent c405d0ea2c
commit eff0680c13
2 changed files with 11 additions and 7 deletions

View File

@ -168,17 +168,17 @@ bool UnixCredentialSocket::RecvMsg(int fd,
return false;
}
// Credentials are missing from the message either when the recv socket wasn't
// configured with SO_PASSCRED or when all sending sockets have been closed.
// In the latter case, res == 0. This case is also indistinguishable from an
// empty message sent to a recv socket which hasn't set SO_PASSCRED.
if (!local_creds) {
LOG(ERROR) << "missing credentials";
LOG_IF(ERROR, res != 0) << "missing credentials";
return false;
}
// res == 0 may also indicate that the sending socket disconnected, but in
// that case, the message will also have missing or invalid credentials.
if (static_cast<size_t>(res) != buf_size) {
if (res != 0 || (local_creds && local_creds->pid != 0)) {
LOG(ERROR) << "incorrect payload size " << res;
}
return false;
}

View File

@ -76,7 +76,11 @@ class UnixCredentialSocket {
//! \param[out] creds The credentials of the sender.
//! \param[out] fds The recieved file descriptors. Optional. If `nullptr`, all
//! received file descriptors will be closed.
//! \return `true` on success. Otherwise, `false`, with a message logged.
//! \return `true` on success. Otherwise, `false`, with a message logged. No
//! message will be logged if the message was detected to be an EOF
//! condition triggered by all clients disconnecting. This case is
//! indistinguishable from misuses of this interface that haven't set
//! `SO_PASSCRED` on \a fd.
static bool RecvMsg(int fd,
void* buf,
size_t buf_size,