diff options
author | Yang Ni <yangni@google.com> | 2017-04-18 12:19:01 -0700 |
---|---|---|
committer | Yang Ni <yangni@google.com> | 2017-04-20 21:53:45 +0000 |
commit | 9ed983b04aa6262a186f17c247115bc8e0b4ecbb (patch) | |
tree | 5b43fb4ca5ccd72a3eacd0821616e6c638447d6e | |
parent | ec03868d2e39a70b4a989149342fb98823307b32 (diff) | |
download | rs-9ed983b04aa6262a186f17c247115bc8e0b4ecbb.tar.gz |
Handle socket creation error in context init
Bug: 27870945
Fail context creation, if the IO Fifo fails to create due to socket
creation error, which was never checked.
Test: CTS on Angler and x86_64 emulator
Change-Id: I61aa973ccd0ef4bd846f891c47c2df28899bfd07
(cherry picked from commit 436444f18d75827d1040ccfdaad1acae075ee630)
-rw-r--r-- | rsContext.cpp | 5 | ||||
-rw-r--r-- | rsFifoSocket.cpp | 1 | ||||
-rw-r--r-- | rsThreadIO.cpp | 5 | ||||
-rw-r--r-- | rsThreadIO.h | 2 |
4 files changed, 7 insertions, 6 deletions
diff --git a/rsContext.cpp b/rsContext.cpp index 99eb2592..aab065c7 100644 --- a/rsContext.cpp +++ b/rsContext.cpp @@ -489,7 +489,10 @@ Context * Context::createContextLite() { bool Context::initContext(Device *dev, const RsSurfaceConfig *sc) { pthread_mutex_lock(&gInitMutex); - mIO.init(); + if (!mIO.init()) { + ALOGE("Failed initializing IO Fifo"); + return false; + } mIO.setTimeoutCallback(printWatchdogInfo, this, 2e9); if (sc) { diff --git a/rsFifoSocket.cpp b/rsFifoSocket.cpp index 5475f92a..af613806 100644 --- a/rsFifoSocket.cpp +++ b/rsFifoSocket.cpp @@ -36,7 +36,6 @@ FifoSocket::~FifoSocket() { } bool FifoSocket::init(bool supportNonBlocking, bool supportReturnValues, size_t maxDataSize) { - // TODO: (b/27870945) Handle socketpair errors. int ret = socketpair(AF_UNIX, SOCK_STREAM, 0, sv); return (ret == 0); } diff --git a/rsThreadIO.cpp b/rsThreadIO.cpp index ceec54ad..e0418779 100644 --- a/rsThreadIO.cpp +++ b/rsThreadIO.cpp @@ -37,9 +37,8 @@ ThreadIO::ThreadIO() { ThreadIO::~ThreadIO() { } -void ThreadIO::init() { - mToClient.init(); - mToCore.init(); +bool ThreadIO::init() { + return mToClient.init() && mToCore.init(); } void ThreadIO::shutdown() { diff --git a/rsThreadIO.h b/rsThreadIO.h index 23c5d42c..cfae09db 100644 --- a/rsThreadIO.h +++ b/rsThreadIO.h @@ -31,7 +31,7 @@ public: ThreadIO(); ~ThreadIO(); - void init(); + bool init(); void shutdown(); size_t getMaxInlineSize() { |