diff options
author | Stefan Laner <laner@itestra.de> | 2013-10-02 18:14:33 +0200 |
---|---|---|
committer | Stefan Laner <laner@itestra.de> | 2013-10-02 18:14:33 +0200 |
commit | 013296d873a4256e2967faa5487b7135bb4afee7 (patch) | |
tree | 1a958061468ea35a0297574339e5b0bed55cdd8b /src | |
parent | 45a4983f583aac98ab9bc4a4b21c57bdbc3b0b44 (diff) | |
download | genivi-common-api-dbus-runtime-013296d873a4256e2967faa5487b7135bb4afee7.tar.gz |
Fixed Bug in DemoMainLoop implementation and a corresponding test.
Poll on wakeFd now really blocks if wakeup was not called yet.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/DBusMainLoopIntegrationTest.cpp | 1 | ||||
-rw-r--r-- | src/test/DemoMainLoop.h | 10 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/test/DBusMainLoopIntegrationTest.cpp b/src/test/DBusMainLoopIntegrationTest.cpp index f3b2720..71295ae 100644 --- a/src/test/DBusMainLoopIntegrationTest.cpp +++ b/src/test/DBusMainLoopIntegrationTest.cpp @@ -138,6 +138,7 @@ TEST_F(DBusBasicMainLoopTest, PrioritiesAreHandledCorrectlyInDemoMainloop) { context->registerDispatchSource(testSource1Low, CommonAPI::DispatchPriority::LOW); context->registerDispatchSource(testSource1VeryHigh, CommonAPI::DispatchPriority::VERY_HIGH); + mainLoop->wakeup(); mainLoop->doSingleIteration(CommonAPI::TIMEOUT_INFINITE); std::string reference1("ECABD"); diff --git a/src/test/DemoMainLoop.h b/src/test/DemoMainLoop.h index d043cda..8b013e1 100644 --- a/src/test/DemoMainLoop.h +++ b/src/test/DemoMainLoop.h @@ -37,7 +37,7 @@ class MainLoop { explicit MainLoop(std::shared_ptr<MainLoopContext> context) : context_(context), currentMinimalTimeoutInterval_(TIMEOUT_INFINITE), running_(false), breakLoop_(false) { wakeFd_.fd = eventfd(0, EFD_SEMAPHORE | EFD_NONBLOCK); - wakeFd_.events = POLLIN | POLLOUT; + wakeFd_.events = POLLIN; assert(wakeFd_.fd != -1); registerFileDescriptor(wakeFd_); @@ -227,8 +227,8 @@ class MainLoop { } void wakeup() { - uint32_t wake = 1; - ::write(wakeFd_.fd, &wake, sizeof(uint32_t)); + int64_t wake = 1; + ::write(wakeFd_.fd, &wake, sizeof(int64_t)); } private: @@ -298,8 +298,8 @@ class MainLoop { } void acknowledgeWakeup() { - uint32_t buffer; - while (::read(wakeFd_.fd, &buffer, sizeof(uint32_t)) == sizeof(buffer)); + int64_t buffer; + while (::read(wakeFd_.fd, &buffer, sizeof(int64_t)) == sizeof(buffer)); } std::shared_ptr<MainLoopContext> context_; |