@ -2965,26 +2965,31 @@ func TestMaybeRebindOnError(t *testing.T) {
tstest . PanicOnLog ( )
tstest . PanicOnLog ( )
tstest . ResourceCheck ( t )
tstest . ResourceCheck ( t )
conn := newTestConn ( t )
err := fmt . Errorf ( "outer err: %w" , syscall . EPERM )
defer conn . Close ( )
t . Run ( "darwin-rebind" , func ( t * testing . T ) {
t . Run ( "darwin-rebind" , func ( t * testing . T ) {
rebound := conn . maybeRebindOnError ( "darwin" , syscall . EPERM )
conn := newTestConn ( t )
defer conn . Close ( )
rebound := conn . maybeRebindOnError ( "darwin" , err )
if ! rebound {
if ! rebound {
t . Errorf ( "darwin should rebind on syscall.EPERM" )
t . Errorf ( "darwin should rebind on syscall.EPERM" )
}
}
} )
} )
t . Run ( "linux-not-rebind" , func ( t * testing . T ) {
t . Run ( "linux-not-rebind" , func ( t * testing . T ) {
rebound := conn . maybeRebindOnError ( "linux" , syscall . EPERM )
conn := newTestConn ( t )
defer conn . Close ( )
rebound := conn . maybeRebindOnError ( "linux" , err )
if rebound {
if rebound {
t . Errorf ( "linux should not rebind on syscall.EPERM" )
t . Errorf ( "linux should not rebind on syscall.EPERM" )
}
}
} )
} )
t . Run ( "no-frequent-rebind" , func ( t * testing . T ) {
t . Run ( "no-frequent-rebind" , func ( t * testing . T ) {
conn := newTestConn ( t )
defer conn . Close ( )
conn . lastEPERMRebind . Store ( time . Now ( ) . Add ( - 1 * time . Second ) )
conn . lastEPERMRebind . Store ( time . Now ( ) . Add ( - 1 * time . Second ) )
rebound := conn . maybeRebindOnError ( "darwin" , syscall . EPERM )
rebound := conn . maybeRebindOnError ( "darwin" , err )
if rebound {
if rebound {
t . Errorf ( "darwin should not rebind on syscall.EPERM within 5 seconds of last" )
t . Errorf ( "darwin should not rebind on syscall.EPERM within 5 seconds of last" )
}
}