File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 66 "fmt"
77 "net"
88 "sync"
9+ "sync/atomic"
910 "testing"
1011 "time"
1112
@@ -919,7 +920,7 @@ func TestConnectionHook(t *testing.T) {
919920 }
920921
921922 // Set a dialer that will check the context timeout
922- timeoutVerified := false
923+ var timeoutVerified int32 // Use atomic for thread safety
923924 conn .SetInitConnFunc (func (ctx context.Context , cn * pool.Conn ) error {
924925 // Check that the context has the expected timeout
925926 deadline , ok := ctx .Deadline ()
@@ -935,7 +936,7 @@ func TestConnectionHook(t *testing.T) {
935936 t .Errorf ("Context deadline not as expected. Expected around %v, got %v (diff: %v)" ,
936937 expectedDeadline , deadline , timeDiff )
937938 } else {
938- timeoutVerified = true
939+ atomic . StoreInt32 ( & timeoutVerified , 1 )
939940 }
940941
941942 return nil // Successful handoff
@@ -955,7 +956,7 @@ func TestConnectionHook(t *testing.T) {
955956 // Wait for handoff to complete
956957 time .Sleep (500 * time .Millisecond )
957958
958- if ! timeoutVerified {
959+ if atomic . LoadInt32 ( & timeoutVerified ) == 0 {
959960 t .Error ("HandoffTimeout was not properly applied to context" )
960961 }
961962
You can’t perform that action at this time.
0 commit comments