Commit c8ce6f0
committed
Removes use of static mutex in sqlcipher_extra_shutdown()
The sqlcipher_extra_shutdown() function is called by sqlite3_shutdown()
to cleanup internal SQLCipher resources. However, many applications do not
call sqlite3_shutdown(). In order to ensure that SQLCipher resources are
cleaned up even if sqlite3_shutdown() is omitted, sqlcipher_extra_shutdown()
is also called from atexit and from a library finalizer (fini/DllMain).
Previously, sqlcipher_extra_shutdown() internally locked a global
static mutex prior to clean up. However, this introduced an edge case
where, if the library was compiled with SQLITE_OMIT_AUTOINIT, and
sqlite_shutdown() was called explicitly, a subsequent call to
sqlcipher_extra_shutdown() from atexit or the finalizer could reallocate a
new mutex that would never be freed.
This change removes the use of the mutex from sqlcipher_extra_shutdown()
entirely. The SQLite documentation makes it clear that sqlite3_shutdown()
is NOT threadsafe (https://www.sqlite.org/c3ref/initialize.html) so an application
must already guarantee that is called from a single thread. Other invocations
of sqlcipher_extra_shutdown will also be called in a single-threaded context.
As a result sqlcipher_extra_shutdown() should not need to make use of a mutext
internally, and its removal solves the previous edge case problem.1 parent 7e14e79 commit c8ce6f0
1 file changed
Lines changed: 0 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | 592 | | |
597 | 593 | | |
598 | 594 | | |
| |||
663 | 659 | | |
664 | 660 | | |
665 | 661 | | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | 662 | | |
670 | 663 | | |
671 | 664 | | |
| |||
0 commit comments