Conversation
| << " body: " << request.body; | ||
| if (request.method == "GET" && request.destination.find(kPrefix) == 0) { | ||
| std::string id = request.destination.substr(kPrefix.size()); | ||
| std::lock_guard<std::mutex> lock(agent_.mu_); |
There was a problem hiding this comment.
Just curious -- are there more than 1 read threads?
There was a problem hiding this comment.
Yes, the number of server threads is specified in the config (MetadataApiNumThreads). But it's enough to have 1 read thread and 1 write thread to trigger the race condition.
There was a problem hiding this comment.
SGTM. I only ask because read threads should not have to block other read threads. Its only when writes happen or attempts to read when a write is in progress that the mutex actually comes in. Probably a micro-optimization to be deferred for later.
There was a problem hiding this comment.
Very true. Will fix this later (I'm not too happy with the direct access to the agent's fields, including the mutex, from a friend class anyway).
No description provided.