Add write lock for sqlite3
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
14b253b9ce
commit
ef3402bf17
10 changed files with 105 additions and 0 deletions
|
|
@ -63,6 +63,9 @@ func (s *sqlDatabase) ControllerInfo() (params.ControllerInfo, error) {
|
|||
}
|
||||
|
||||
func (s *sqlDatabase) InitController() (params.ControllerInfo, error) {
|
||||
s.writeMux.Lock()
|
||||
defer s.writeMux.Unlock()
|
||||
|
||||
if _, err := s.ControllerInfo(); err == nil {
|
||||
return params.ControllerInfo{}, runnerErrors.NewConflictError("controller already initialized")
|
||||
}
|
||||
|
|
@ -88,6 +91,9 @@ func (s *sqlDatabase) InitController() (params.ControllerInfo, error) {
|
|||
}
|
||||
|
||||
func (s *sqlDatabase) UpdateController(info params.UpdateControllerParams) (paramInfo params.ControllerInfo, err error) {
|
||||
s.writeMux.Lock()
|
||||
defer s.writeMux.Unlock()
|
||||
|
||||
defer func() {
|
||||
if err == nil {
|
||||
s.sendNotify(common.ControllerEntityType, common.UpdateOperation, paramInfo)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue