Address data race with blockcache's freelist_count
Address data race with blockcache's freelist_count

11:02:03 WARNING: ThreadSanitizer: data race (pid=108225)
11:02:03   Write of size 8 at 0x000001571768 by thread T14 (mutexes: write M57456, write M57552, write M14):
11:02:03     #0 _bcache_alloc_freeblock() /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:293 (fdb_functional_test+0x0000004e5a89)
11:02:03     #1 filemgr_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1989 (fdb_functional_test+0x000000501a8b)
11:02:03     #2 _docio_read_through_buffer(docio_handle*, unsigned long, err_log_callback*, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:691 (fdb_functional_test+0x0000004faa70)
11:02:03     #3 docio_read_doc /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:1212 (fdb_functional_test+0x0000004fbb6f)
11:02:03     #4 fdb_kvs_header_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1123 (fdb_functional_test+0x00000053261c)
11:02:03     #5 _fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:1954 (fdb_functional_test+0x00000050ac08)
11:02:03     #6 fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:782 (fdb_functional_test+0x0000005090ba)
11:02:03     #7 _worker_thread(void*) crtstuff.c (fdb_functional_test+0x0000004d184b)
11:02:03
11:02:03   Previous read of size 8 at 0x000001571768 by thread T19:
11:02:03     #0 bcache_get_num_free_blocks /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:1410 (fdb_functional_test+0x0000004e7d64)
11:02:03     #1 _filemgr_prefetch_thread(void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:612 (fdb_functional_test+0x0000004fe4da)

Change-Id: Id7344ae6a13f97fb3bc6f8ed9140d1788e78fe72
Reviewed-on: http://review.couchbase.org/62377
Reviewed-by: Chiyoung Seo <fcffc23db27b19ee4ebba46695ee6b50e09216a2@couchbase.com>
Tested-by: buildbot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>

wurikiji/forestdb,hisundar/forestdb,couchbase/forestdb,hisundar/forestdb,couchbase/forestdb,wurikiji/forestdb