@@ -104,7 +104,7 @@ func (mc *mysqlConn) Begin() (driver.Tx, error) {
104104}
105105
106106func (mc * mysqlConn ) begin (readOnly bool ) (driver.Tx , error ) {
107- if mc .closed .IsSet () {
107+ if mc .closed .Load () {
108108 errLog .Print (ErrInvalidConn )
109109 return nil , driver .ErrBadConn
110110 }
@@ -123,7 +123,7 @@ func (mc *mysqlConn) begin(readOnly bool) (driver.Tx, error) {
123123
124124func (mc * mysqlConn ) Close () (err error ) {
125125 // Makes Close idempotent
126- if ! mc .closed .IsSet () {
126+ if ! mc .closed .Load () {
127127 err = mc .writeCommandPacket (comQuit )
128128 }
129129
@@ -137,7 +137,7 @@ func (mc *mysqlConn) Close() (err error) {
137137// is called before auth or on auth failure because MySQL will have already
138138// closed the network connection.
139139func (mc * mysqlConn ) cleanup () {
140- if ! mc .closed .TrySet (true ) {
140+ if mc .closed .Swap (true ) {
141141 return
142142 }
143143
@@ -152,7 +152,7 @@ func (mc *mysqlConn) cleanup() {
152152}
153153
154154func (mc * mysqlConn ) error () error {
155- if mc .closed .IsSet () {
155+ if mc .closed .Load () {
156156 if err := mc .canceled .Value (); err != nil {
157157 return err
158158 }
@@ -162,7 +162,7 @@ func (mc *mysqlConn) error() error {
162162}
163163
164164func (mc * mysqlConn ) Prepare (query string ) (driver.Stmt , error ) {
165- if mc .closed .IsSet () {
165+ if mc .closed .Load () {
166166 errLog .Print (ErrInvalidConn )
167167 return nil , driver .ErrBadConn
168168 }
@@ -295,7 +295,7 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
295295}
296296
297297func (mc * mysqlConn ) Exec (query string , args []driver.Value ) (driver.Result , error ) {
298- if mc .closed .IsSet () {
298+ if mc .closed .Load () {
299299 errLog .Print (ErrInvalidConn )
300300 return nil , driver .ErrBadConn
301301 }
@@ -356,7 +356,7 @@ func (mc *mysqlConn) Query(query string, args []driver.Value) (driver.Rows, erro
356356}
357357
358358func (mc * mysqlConn ) query (query string , args []driver.Value ) (* textRows , error ) {
359- if mc .closed .IsSet () {
359+ if mc .closed .Load () {
360360 errLog .Print (ErrInvalidConn )
361361 return nil , driver .ErrBadConn
362362 }
@@ -450,7 +450,7 @@ func (mc *mysqlConn) finish() {
450450
451451// Ping implements driver.Pinger interface
452452func (mc * mysqlConn ) Ping (ctx context.Context ) (err error ) {
453- if mc .closed .IsSet () {
453+ if mc .closed .Load () {
454454 errLog .Print (ErrInvalidConn )
455455 return driver .ErrBadConn
456456 }
@@ -469,7 +469,7 @@ func (mc *mysqlConn) Ping(ctx context.Context) (err error) {
469469
470470// BeginTx implements driver.ConnBeginTx interface
471471func (mc * mysqlConn ) BeginTx (ctx context.Context , opts driver.TxOptions ) (driver.Tx , error ) {
472- if mc .closed .IsSet () {
472+ if mc .closed .Load () {
473473 return nil , driver .ErrBadConn
474474 }
475475
@@ -636,7 +636,7 @@ func (mc *mysqlConn) CheckNamedValue(nv *driver.NamedValue) (err error) {
636636// ResetSession implements driver.SessionResetter.
637637// (From Go 1.10)
638638func (mc * mysqlConn ) ResetSession (ctx context.Context ) error {
639- if mc .closed .IsSet () {
639+ if mc .closed .Load () {
640640 return driver .ErrBadConn
641641 }
642642 mc .reset = true
@@ -646,5 +646,5 @@ func (mc *mysqlConn) ResetSession(ctx context.Context) error {
646646// IsValid implements driver.Validator interface
647647// (From Go 1.15)
648648func (mc * mysqlConn ) IsValid () bool {
649- return ! mc .closed .IsSet ()
649+ return ! mc .closed .Load ()
650650}
0 commit comments