From 717e9616ae51e87afbffb3d947a0cf81919c70d3 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 27 Jun 2024 11:10:28 +0800 Subject: [PATCH] 1 --- dbpool.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/dbpool.go b/dbpool.go index 2a00823..b1a6518 100644 --- a/dbpool.go +++ b/dbpool.go @@ -405,7 +405,7 @@ func (this *dbPool) borrowConn(name string) *dataSource { if head, ok := this.dataSourceHash[name]; ok { if !head.Empty() { ds := head.FirstEntry().(*dataSource) - ds.entry.DelInit() + //ds.entry.DelInit() this.lock.Unlock() return ds } @@ -416,17 +416,37 @@ func (this *dbPool) borrowConn(name string) *dataSource { tryCount++ } return nil + /* + tryCount := 0 + for tryCount < 5 { + { + this.lock.Lock() + if head, ok := this.dataSourceHash[name]; ok { + if !head.Empty() { + ds := head.FirstEntry().(*dataSource) + ds.entry.DelInit() + this.lock.Unlock() + return ds + } + } + this.lock.Unlock() + } + time.Sleep(time.Second * 1) + tryCount++ + } + return nil*/ } func (this *dbPool) returnConn(ds *dataSource) { this.lock.Lock() defer this.lock.Unlock() + /* if head, ok := this.dataSourceHash[ds.name]; ok { head.AddTail(&ds.entry) } else { panic(fmt.Sprintf("returnConn error %s", ds.name)) - } + }*/ } func (this *dbPool) joinSelectFields(fields []string) string {