LEFT | RIGHT |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Package sql provides a generic interface around SQL (or SQL-like) | 5 // Package sql provides a generic interface around SQL (or SQL-like) |
6 // databases. | 6 // databases. |
7 // | 7 // |
8 // The sql package must be used in conjunction with a database driver. | 8 // The sql package must be used in conjunction with a database driver. |
9 // See http://golang.org/s/sqldrivers for a list of drivers. | 9 // See http://golang.org/s/sqldrivers for a list of drivers. |
10 // | 10 // |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 numOpen int | 202 numOpen int |
203 pendingOpens int | 203 pendingOpens int |
204 // Used to signal the need for new connections | 204 // Used to signal the need for new connections |
205 // a goroutine running connectionOpener() reads on this chan and | 205 // a goroutine running connectionOpener() reads on this chan and |
206 // maybeOpenNewConnections sends on the chan (one send per needed connec
tion) | 206 // maybeOpenNewConnections sends on the chan (one send per needed connec
tion) |
207 // It is closed during db.Close(). The close tells the connectionOpener | 207 // It is closed during db.Close(). The close tells the connectionOpener |
208 // goroutine to exit. | 208 // goroutine to exit. |
209 openerCh chan struct{} | 209 openerCh chan struct{} |
210 closed bool | 210 closed bool |
211 dep map[finalCloser]depSet | 211 dep map[finalCloser]depSet |
212 » lastPut map[*driverConn]string // stack trace of last conn's put; debug
only | 212 » lastPut map[*driverConn]string // stacktrace of last conn's put; debug
only |
213 maxIdle int // zero means defaultMaxIdleConns; negat
ive means 0 | 213 maxIdle int // zero means defaultMaxIdleConns; negat
ive means 0 |
214 maxOpen int // <= 0 means unlimited | 214 maxOpen int // <= 0 means unlimited |
215 } | 215 } |
216 | 216 |
217 // driverConn wraps a driver.Conn with a mutex, to | 217 // driverConn wraps a driver.Conn with a mutex, to |
218 // be held during all calls into the Conn. (including any calls onto | 218 // be held during all calls into the Conn. (including any calls onto |
219 // interfaces returned via that Conn, such as calls on Tx, Stmt, | 219 // interfaces returned via that Conn, such as calls on Tx, Stmt, |
220 // Result, Rows) | 220 // Result, Rows) |
221 type driverConn struct { | 221 type driverConn struct { |
222 db *DB | 222 db *DB |
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1699 var buf [2 << 10]byte | 1699 var buf [2 << 10]byte |
1700 return string(buf[:runtime.Stack(buf[:], false)]) | 1700 return string(buf[:runtime.Stack(buf[:], false)]) |
1701 } | 1701 } |
1702 | 1702 |
1703 // withLock runs while holding lk. | 1703 // withLock runs while holding lk. |
1704 func withLock(lk sync.Locker, fn func()) { | 1704 func withLock(lk sync.Locker, fn func()) { |
1705 lk.Lock() | 1705 lk.Lock() |
1706 fn() | 1706 fn() |
1707 lk.Unlock() | 1707 lk.Unlock() |
1708 } | 1708 } |
LEFT | RIGHT |