Fix mutex embedding lint issue

This commit is contained in:
Joona Hoikkala 2022-08-10 14:42:05 +03:00
parent ce329a1181
commit cdfdb2ea75
No known key found for this signature in database
GPG Key ID: 1708DAE66E87A524
2 changed files with 11 additions and 13 deletions

20
db.go
View File

@ -55,8 +55,8 @@ func getSQLiteStmt(s string) string {
}
func (d *acmedb) Init(engine string, connection string) error {
d.Lock()
defer d.Unlock()
d.Mutex.Lock()
defer d.Mutex.Unlock()
db, err := sql.Open(engine, connection)
if err != nil {
return err
@ -171,8 +171,8 @@ func (d *acmedb) NewTXTValuesInTransaction(tx *sql.Tx, subdomain string) error {
}
func (d *acmedb) Register(afrom cidrslice) (ACMETxt, error) {
d.Lock()
defer d.Unlock()
d.Mutex.Lock()
defer d.Mutex.Unlock()
var err error
tx, err := d.DB.Begin()
// Rollback if errored, commit if not
@ -210,8 +210,8 @@ func (d *acmedb) Register(afrom cidrslice) (ACMETxt, error) {
}
func (d *acmedb) GetByUsername(u uuid.UUID) (ACMETxt, error) {
d.Lock()
defer d.Unlock()
d.Mutex.Lock()
defer d.Mutex.Unlock()
var results []ACMETxt
getSQL := `
SELECT Username, Password, Subdomain, AllowFrom
@ -248,8 +248,8 @@ func (d *acmedb) GetByUsername(u uuid.UUID) (ACMETxt, error) {
}
func (d *acmedb) GetTXTForDomain(domain string) ([]string, error) {
d.Lock()
defer d.Unlock()
d.Mutex.Lock()
defer d.Mutex.Unlock()
domain = sanitizeString(domain)
var txts []string
getSQL := `
@ -282,8 +282,8 @@ func (d *acmedb) GetTXTForDomain(domain string) ([]string, error) {
}
func (d *acmedb) Update(a ACMETxtPost) error {
d.Lock()
defer d.Unlock()
d.Mutex.Lock()
defer d.Mutex.Unlock()
var err error
// Data in a is already sanitized
timenow := time.Now().Unix()

View File

@ -63,7 +63,7 @@ type logconfig struct {
}
type acmedb struct {
sync.Mutex
Mutex sync.Mutex
DB *sql.DB
}
@ -76,6 +76,4 @@ type database interface {
GetBackend() *sql.DB
SetBackend(*sql.DB)
Close()
Lock()
Unlock()
}