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 6
6
"fmt"
7
7
"net"
8
8
"sync"
9
+ "sync/atomic"
9
10
"testing"
10
11
"time"
11
12
@@ -919,7 +920,7 @@ func TestConnectionHook(t *testing.T) {
919
920
}
920
921
921
922
// Set a dialer that will check the context timeout
922
- timeoutVerified := false
923
+ var timeoutVerified int32 // Use atomic for thread safety
923
924
conn .SetInitConnFunc (func (ctx context.Context , cn * pool.Conn ) error {
924
925
// Check that the context has the expected timeout
925
926
deadline , ok := ctx .Deadline ()
@@ -935,7 +936,7 @@ func TestConnectionHook(t *testing.T) {
935
936
t .Errorf ("Context deadline not as expected. Expected around %v, got %v (diff: %v)" ,
936
937
expectedDeadline , deadline , timeDiff )
937
938
} else {
938
- timeoutVerified = true
939
+ atomic . StoreInt32 ( & timeoutVerified , 1 )
939
940
}
940
941
941
942
return nil // Successful handoff
@@ -955,7 +956,7 @@ func TestConnectionHook(t *testing.T) {
955
956
// Wait for handoff to complete
956
957
time .Sleep (500 * time .Millisecond )
957
958
958
- if ! timeoutVerified {
959
+ if atomic . LoadInt32 ( & timeoutVerified ) == 0 {
959
960
t .Error ("HandoffTimeout was not properly applied to context" )
960
961
}
961
962
You can’t perform that action at this time.
0 commit comments