Skip to content

Commit

Permalink
Fix mutex embedding lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
joohoi committed Aug 10, 2022
1 parent ce329a1 commit cdfdb2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
20 changes: 10 additions & 10 deletions db.go
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 := `
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions types.go
Expand Up @@ -63,7 +63,7 @@ type logconfig struct {
}

type acmedb struct {
sync.Mutex
Mutex sync.Mutex
DB *sql.DB
}

Expand All @@ -76,6 +76,4 @@ type database interface {
GetBackend() *sql.DB
SetBackend(*sql.DB)
Close()
Lock()
Unlock()
}

0 comments on commit cdfdb2e

Please sign in to comment.