mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-10 04:20:27 +08:00
改进退出程序时关闭数据库写入
This commit is contained in:
@@ -45,6 +45,9 @@ func (this *Batch) OnFail(callback func(err error)) {
|
||||
}
|
||||
|
||||
func (this *Batch) Add(query string, args ...any) {
|
||||
if this.isClosed {
|
||||
return
|
||||
}
|
||||
this.queue <- &batchItem{
|
||||
query: query,
|
||||
args: args,
|
||||
@@ -139,6 +142,10 @@ func (this *Batch) beginTx() *sql.Tx {
|
||||
}
|
||||
|
||||
func (this *Batch) execItem(tx *sql.Tx, item *batchItem) error {
|
||||
if this.isClosed {
|
||||
return nil
|
||||
}
|
||||
|
||||
if this.enableStat {
|
||||
defer SharedQueryStatManager.AddQuery(item.query).End()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user