Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 6800a8a0 authored by chao.bi's avatar chao.bi Committed by Abhisek Devkota
Browse files

Race in WapPushManager under multi-thread environment



When multiple threads call WapPushManager functions simultaneously,
it might hit race that one thread is closing a SqliteDatabase object
while another thread is using it.

Following is an example:

    Thread A                                    Thread B

call getDatabaseLocked()                          ---
       |                                           |
mDatabase is NULL,so A create Database            ---
       |                                           |
getDatabaseLocked() return the new                ---
created Database                                  ---
       |                                           |
      ---                                 call getDatabaseLocked() and return
      ---                                 the Database created by A
       |                                           |
Call SQLiteDatabase.close()                       ---
close() -> releaseReference()                     ---
the reference count is decreased to 0             ---
       |                                           |
      ---                                  Attempt to call any operation of Database
      ---                                  Object, but hit exception because this
      ---                                  Database Object's reference count is 0

For WapPushManager, seems it always close the database object right after
it open&query it, this is not necessary and would hit above race under multi-thread
environment.

Ticket: CYNGNOS-2973
Change-Id: I68fac046f806c8d9328fbe0d9c8a08e6bfddbef1
Signed-off-by: default avatarwangbo3 <bo.c.wang@intel.com>
Signed-off-by: default avatarchao.bi <chao.bi@intel.com>
Signed-off-by: default avatarZhiquan Liu <zhiquan.liu@intel.com>
parent 0ee547bc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment