Bug 1240985 - Fix bug where mAwaitingSyncReply can be overwritten in Send after Cancel (r=dvander)

This commit is contained in:
Bill McCloskey 2016-01-19 17:32:24 -08:00
parent 2de94a9236
commit cea71a6b75

View File

@ -525,16 +525,22 @@ class MessageChannel : HasResultCodes
class AutoSetValue {
public:
explicit AutoSetValue(T &var, const T &newValue)
: mVar(var), mPrev(var)
: mVar(var), mPrev(var), mNew(newValue)
{
mVar = newValue;
}
~AutoSetValue() {
mVar = mPrev;
// The value may have been zeroed if the transaction was
// canceled. In that case we shouldn't return it to its previous
// value.
if (mVar == mNew) {
mVar = mPrev;
}
}
private:
T& mVar;
T mPrev;
T mNew;
};
// Worker thread only.