/* Try not to decrement the counter if it's not positive. Still racy,
* but it makes it harder to wrap the counter from INT_MIN to INT_MAX. */
tres->max_forced_staging_uploads > 0 &&
+ tc->use_forced_staging_uploads &&
p_atomic_dec_return(&tres->max_forced_staging_uploads) >= 0) {
usage &= ~(PIPE_MAP_DISCARD_WHOLE_RESOURCE |
PIPE_MAP_UNSYNCHRONIZED);
* written range(s).
*/
usage &= ~PIPE_MAP_UNSYNCHRONIZED & ~TC_TRANSFER_MAP_THREADED_UNSYNC;
+ tc->use_forced_staging_uploads = false;
}
}
if (!tc->base.stream_uploader || !tc->base.const_uploader)
goto fail;
+ tc->use_forced_staging_uploads = true;
+
/* The queue size is the number of batches "waiting". Batches are removed
* from the queue before being executed, so keep one tc_batch slot for that
* execution. Also, keep one unused slot for an unflushed batch.