coryrwest / B2.NET

.NET library for Backblaze's B2 Cloud Storage
MIT License
62 stars 33 forks source link

Is B2Client thread-safe? #45

Open danports opened 4 years ago

danports commented 4 years ago

I'm guessing it is not because of things like this:

https://github.com/coryrwest/B2.NET/blob/07d3f749c16655bbfb7c6a5dd40cd534d3b97576/src/Files.cs#L124

It would be nice if it were since the underlying HttpClient is, but if that requires too much effort, perhaps a line in the documentation clarifying the library's thread safety would be helpful.

coryrwest commented 4 years ago

I am admittedly not as well experienced/read in thread-safety as I could be. I am not sure of the changes require and their extensiveness to be completely thread-safe. I will have to do some research.

danports commented 4 years ago

From my brief review of the library's internals, I didn't notice many thread safety issues - the only glaring one I noticed is the way that the B2Options class is used to pass state around in several places, and that can probably be easily avoided by passing context on the stack instead (e.g. passing the upload authorization token directly to FileUploadRequestGenerators.Upload as an argument).

Of course, the simplest approach to start would just to be document that the library is not thread-safe. 😂