Unflake Unclean-Shutdown-Alert on Windows.

On Windows, if we write to our socket and then close it, the peer sometimes
doesn't get all the data. This was working for our shimShutsDown tests because
we send close_notify in parallel with the peer and sendAlert(alertCloseNotify)
did not internally return an error.

For convenience, sendAlert returns a local error for non-close_notify alerts.
Suppress that error to avoid the race condition. This makes it behave like the
other shimShutsDown tests.

Change-Id: Iad256e3ea5223285793991e2eba9c7d61f2e3ddf
Reviewed-on: https://boringssl-review.googlesource.com/7980
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2016-05-18 14:31:51 -04:00 committed by Adam Langley
parent f4ce8e5324
commit 4d559617cd

View File

@ -1297,6 +1297,11 @@ func (c *Conn) Close() error {
alert = c.config.Bugs.SendAlertOnShutdown alert = c.config.Bugs.SendAlertOnShutdown
} }
alertErr = c.sendAlert(alert) alertErr = c.sendAlert(alert)
// Clear local alerts when sending alerts so we continue to wait
// for the peer rather than closing the socket early.
if opErr, ok := alertErr.(*net.OpError); ok && opErr.Op == "local error" {
alertErr = nil
}
} }
// Consume a close_notify from the peer if one hasn't been received // Consume a close_notify from the peer if one hasn't been received