Fix data race in AutoCommit()

Detected via https://circleci.com/gh/rqlite/rqlite/2223.
This commit is contained in:
Philip O'Toole 2018-08-30 05:44:58 -07:00
parent 3198c7714d
commit abfacf5684
1 changed files with 2 additions and 0 deletions

View File

@ -648,6 +648,8 @@ func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool
// AutoCommit return which currently auto commit or not.
func (c *SQLiteConn) AutoCommit() bool {
c.mu.Lock()
defer c.mu.Unlock()
return int(C.sqlite3_get_autocommit(c.db)) != 0
}