ncw / swift

Go language interface to Swift / Openstack Object Storage / Rackspace cloud files (golang)
MIT License
310 stars 107 forks source link

Fix races related to the way how authLock is implemented and used #170

Closed yuri-per closed 2 years ago

yuri-per commented 3 years ago

1. Allocate authLock as part of Connection

Previously when Authenticate() or Authenticated() was called simultaneously from several goroutines authLock was initialized in racy manner. Such code is not allowed by Go Memory Model and sometimes crashes.

2. Introduce GetStorageUrl() method

Access to StorageUrl without taking authLock is racy. New method GetStorageUrl() is added for getting StorageLock in race-free manner. Methods where StorageUrl was accessed without lock (QueryInfo() and ObjectTempUrl()) are updated.