[Messaging] Prevent crash on getMessageServices call 95/196595/5
authorPawel Wasowski <p.wasowski2@partner.samsung.com>
Wed, 19 Dec 2018 18:05:20 +0000 (19:05 +0100)
committerPiotr Kosko/Native/Web API (SWP) /SRPOL/Professional/삼성전자 <p.kosko@samsung.com>
Wed, 9 Jan 2019 08:08:08 +0000 (09:08 +0100)
commit25ae263f8cabeed0f6dd4b061e601ef356c447e6
tree7c9d4417bf67c92670c10a7d04fc843d2cfef123
parentbb52aa78d47349922042482ac55a89746ecf4b51
[Messaging] Prevent crash on getMessageServices call

Calling tizen.messaging.getMessageServices() multiple times at
short intervals used to cause a crash, due to race condition, occurring
between different threads, modifying the same MessagingManager
instance's fields.
The fix moves execution of the underlying implementation to the main
thread - it is not called concurrently. The function execution time
is typically below 2 ms, so moving it to the main thread should
not worsen user experience.

[Verification] tct-tizen-messaging-email-tests pass rate: 100%
               tct-tizen-messaging-sms-tests pass rate: 100%
               tct-tizen-messaging-mms-tests pass rate: 100%
               A code snippet, that used to cause a crash, does not
               cause crash now:
               for (var i = 0; i < 1000; ++i) {
                   tizen.messaging.getMessageServices('messaging.email',
                                                      s=>{console.log(s);},
                                                      e=>{console.error(e);});
               }

Change-Id: I2f140281e64aeffea1ad9ca15f99ee38378693d3
Signed-off-by: Pawel Wasowski <p.wasowski2@partner.samsung.com>
src/messaging/messaging_manager.cc
src/messaging/messaging_manager.h