Yueh-Hsuan Chiang 00d6edf6a0 Ensure the destruction order of PosixEnv and ThreadLocalPtr
Summary:
By default, RocksDB initializes the singletons of ThreadLocalPtr first, then initializes PosixEnv
via static initializer.  Destructor terminates objects in reverse order, so terminating PosixEnv
(calling pthread_mutex_lock), then ThreadLocal (calling pthread_mutex_destroy).

However, in certain case, application might initialize PosixEnv first, then ThreadLocalPtr.
This will cause core dump at the end of the program (eg. https://github.com/facebook/mysql-5.6/issues/122)

This patch fix this issue by ensuring the destruction order by moving the global static singletons
to function static singletons.  Since function static singletons are initialized when the function is first
called, this property allows us invoke to enforce the construction of the static PosixEnv and the
singletons of ThreadLocalPtr by calling the function where the ThreadLocalPtr singletons belongs
right before we initialize the static PosixEnv.

Test Plan: Verified in the MyRocks.

Reviewers: yoshinorim, IslamAbdelRahman, rven, kradhakrishnan, anthony, sdong, MarkCallaghan

Reviewed By: anthony

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D51789
2015-12-11 00:21:58 -08:00
..
2015-09-14 11:54:47 -07:00
2015-09-25 13:55:11 -07:00
2015-09-28 11:51:32 -07:00
2015-04-25 18:14:27 +09:00
2014-11-07 15:04:30 -08:00
2015-03-17 14:08:00 -07:00
2014-08-19 06:48:21 -07:00
2015-11-24 16:33:09 +03:00
2015-12-09 14:06:23 -08:00
2015-03-17 14:08:00 -07:00
2015-10-01 08:29:31 +13:00
2015-11-16 12:56:21 -08:00
2015-03-17 14:08:00 -07:00
2015-10-19 13:40:44 -07:00
2015-03-17 14:08:00 -07:00
2014-11-20 10:49:32 -08:00
2015-07-16 11:22:21 +02:00
2015-04-25 18:14:27 +09:00
2015-07-01 16:13:56 -07:00
2015-07-20 17:20:40 -07:00
2015-07-20 17:20:40 -07:00
2015-08-12 10:18:59 -07:00
2015-11-24 16:33:09 +03:00
2015-11-04 21:02:20 -08:00
2015-07-01 16:13:56 -07:00
2015-07-01 16:13:56 -07:00
2015-07-01 16:13:56 -07:00
2015-08-31 16:13:29 -07:00
2014-11-21 11:05:28 -05:00
2015-07-01 16:13:56 -07:00
2015-12-11 01:54:48 +09:00
2015-03-17 14:08:00 -07:00
2015-10-01 08:29:31 +13:00