Removed debugging stdout prints
This commit is contained in:
@@ -32,13 +32,11 @@ func (conn *SafeConn) acquireGlobalLock() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
atomic.StoreInt32(&conn.globalLockStatus, 1)
|
atomic.StoreInt32(&conn.globalLockStatus, 1)
|
||||||
fmt.Println("=====================GLOBAL LOCK ACQUIRED==================")
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *SafeConn) releaseGlobalLock() {
|
func (conn *SafeConn) releaseGlobalLock() {
|
||||||
atomic.StoreInt32(&conn.globalLockStatus, 0)
|
atomic.StoreInt32(&conn.globalLockStatus, 0)
|
||||||
fmt.Println("=====================GLOBAL LOCK RELEASED==================")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *SafeConn) acquireReadLock() bool {
|
func (conn *SafeConn) acquireReadLock() bool {
|
||||||
@@ -46,13 +44,11 @@ func (conn *SafeConn) acquireReadLock() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
atomic.AddInt32(&conn.readLockCount, 1)
|
atomic.AddInt32(&conn.readLockCount, 1)
|
||||||
fmt.Println("=====================READ LOCK ACQUIRED==================")
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *SafeConn) releaseReadLock() {
|
func (conn *SafeConn) releaseReadLock() {
|
||||||
atomic.AddInt32(&conn.readLockCount, -1)
|
atomic.AddInt32(&conn.readLockCount, -1)
|
||||||
fmt.Println("=====================READ LOCK RELEASED==================")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Starts a new transaction based on the current context. Will cancel if
|
// Starts a new transaction based on the current context. Will cancel if
|
||||||
@@ -65,7 +61,6 @@ func (conn *SafeConn) Begin(ctx context.Context) (*SafeTX, error) {
|
|||||||
go func() {
|
go func() {
|
||||||
select {
|
select {
|
||||||
case <-lockCtx.Done():
|
case <-lockCtx.Done():
|
||||||
fmt.Println("=====================READ LOCK ABANDONED==================")
|
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
if conn.acquireReadLock() {
|
if conn.acquireReadLock() {
|
||||||
@@ -151,10 +146,8 @@ func (conn *SafeConn) Resume() {
|
|||||||
|
|
||||||
// Close the database connection
|
// Close the database connection
|
||||||
func (conn *SafeConn) Close() error {
|
func (conn *SafeConn) Close() error {
|
||||||
fmt.Println("=====================DB LOCKING FOR SHUTDOWN==================")
|
|
||||||
conn.acquireGlobalLock()
|
conn.acquireGlobalLock()
|
||||||
defer conn.releaseGlobalLock()
|
defer conn.releaseGlobalLock()
|
||||||
fmt.Println("=====================DB LOCKED FOR SHUTDOWN==================")
|
|
||||||
return conn.db.Close()
|
return conn.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user