mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-09-19 09:40:12 +00:00
27 lines
679 B
Go
27 lines
679 B
Go
//go:build agentcompat && linux
|
|
|
|
package singleton
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
func (connection *sqliteAttributionConnection) Close() error {
|
|
connection.lifecycleMu.Lock()
|
|
state := connection.transaction
|
|
connection.lifecycleMu.Unlock()
|
|
if state == nil {
|
|
return connection.closeRaw()
|
|
}
|
|
// database/sql may close Conn before Tx reaches Rollback; converge the attribution state here.
|
|
rollbackErr := state.rollback(connection)
|
|
return errors.Join(rollbackErr, connection.closeRaw())
|
|
}
|
|
|
|
func (connection *sqliteAttributionConnection) closeRaw() error {
|
|
if connection.closeRawConnection != nil {
|
|
return connection.closeRawConnection()
|
|
}
|
|
return connection.connection.Close()
|
|
}
|