Skip to content

Access to ConnectionPool.count should be thread safe #318

Closed
@ya-pulser

Description

@ya-pulser

ConnectionPool has a collection of providers registered with the pool and access to the collection is guarded by ConnectionPool.lock.

Size of the collection is exposed through count accessor without guarding by the lock.
https://github.com/swift-server/async-http-client/blob/1.2.2/Sources/AsyncHTTPClient/ConnectionPool.swift#L112

That leads to warnings in thread safety analyser.

To reproduce run with thread safety analyzer:

docker run --rm -v $(pwd):/src -w /src swift:5.3.1 swift test -c release --sanitize=thread --enable-test-discovery

Analysis of output shows that this count accessor is main source of thread safety warnings.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions