There is race condition if azuretls session is used by multiple goroutines to access http (not https) URLs, as long as multiple URLs have the same host.
To Reproduce
Just use the test/connection_test.go file, modify func concurrency(session *azuretls.Session, wg *sync.WaitGroup, ok *int64) bool function, change the test url from https://example.com/ to http://example.com/, then run the TestHighConcurrency test.
2024/06/25 14:26:56 goroutine 1: 1 requests sent
2024/06/25 14:26:56 goroutine 0: 1 requests sent
2024/06/25 14:26:56 goroutine 2: 1 requests sent
2024/06/25 14:26:57 fail: read tcp 127.0.0.1:58686->93.184.215.14:80: use of closed network connection
exit status 1
`
The race condition is easy to produce, even with only 2 or 3 goroutines and interval of 1s.
Describe the bug
There is race condition if azuretls session is used by multiple goroutines to access http (not https) URLs, as long as multiple URLs have the same host.
To Reproduce
Just use the
test/connection_test.go
file, modifyfunc concurrency(session *azuretls.Session, wg *sync.WaitGroup, ok *int64) bool
function, change the test url fromhttps://example.com/
tohttp://example.com/
, then run theTestHighConcurrency
test.Alternatively, use the following test snippet:
Output: