From: Brian Walker Date: Mon, 18 Apr 2016 17:59:14 +0000 (-0700) Subject: NotificationQueue Logging for Android bug X-Git-Tag: 2016.07.26~345 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9ef64521a65b60d4fea8e1b56ea0b283680921e5;p=folly.git NotificationQueue Logging for Android bug Summary: Add some logging to figure out the state of the Qeueu when the write error happens. Differential Revision: D3190882 fb-gh-sync-id: 6515d77df8aa3086922cb4053f2e437f3e527a36 fbshipit-source-id: 6515d77df8aa3086922cb4053f2e437f3e527a36 --- diff --git a/folly/io/async/NotificationQueue.h b/folly/io/async/NotificationQueue.h index 58a3a821..7c8b2ee9 100644 --- a/folly/io/async/NotificationQueue.h +++ b/folly/io/async/NotificationQueue.h @@ -420,7 +420,7 @@ class NotificationQueue { return true; } - size_t size() { + size_t size() const { folly::SpinLockGuard g(spinlock_); return queue_.size(); } @@ -464,6 +464,12 @@ class NotificationQueue { return draining_; } +#ifdef __ANDROID__ + // TODO 10860938 Remove after figuring out crash + mutable std::atomic eventBytes_{0}; + mutable std::atomic maxEventBytes_{0}; +#endif + inline void signalEvent(size_t numAdded = 1) const { static const uint8_t kPipeMessage[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 @@ -491,7 +497,17 @@ class NotificationQueue { bytes_written += rc; } while (numAdded > 0); } +#ifdef __ANDROID__ + eventBytes_ += bytes_written; + maxEventBytes_ = std::max((int)maxEventBytes_, (int)eventBytes_); +#endif + if (bytes_written != bytes_expected) { +#ifdef __ANDROID__ + LOG(ERROR) << "NotificationQueue Write Error=" << errno + << " bytesInPipe=" << eventBytes_ + << " maxInPipe=" << maxEventBytes_ << " queue=" << size(); +#endif folly::throwSystemError("failed to signal NotificationQueue after " "write", errno); } @@ -506,6 +522,9 @@ class NotificationQueue { uint8_t value8; rc = readNoInt(pipeFds_[0], &value8, sizeof(value8)); value = value8; +#ifdef __ANDROID__ + eventBytes_ -= 1; +#endif } if (rc < 0) { // EAGAIN should pretty much be the only error we can ever get.