pthread_mutex_lock(&vstream->overwrite_lock);
if (vstream->abort_flag) {
/* The file is being overwritten by the writer, we cannot use it. */
pthread_mutex_unlock(&vstream->overwrite_lock);
ret = viewer_stream_rotate(vstream, rstream);
pthread_mutex_lock(&vstream->overwrite_lock);
if (vstream->abort_flag) {
/* The file is being overwritten by the writer, we cannot use it. */
pthread_mutex_unlock(&vstream->overwrite_lock);
ret = viewer_stream_rotate(vstream, rstream);