TAPE: Fix potential race (Coverity)

This commit is contained in:
Mark Pizzolato 2017-06-03 08:56:51 -07:00
parent fae6a18835
commit 8baac06f7f

View file

@ -322,10 +322,19 @@ sim_debug (ctx->dbit, ctx->dptr, "_tape_completion_dispatch(unit=%d, top=%d, cal
if (ctx->io_top != TOP_DONE)
abort(); /* horribly wrong, stop */
if (ctx->callback && ctx->io_top == TOP_DONE) {
if (ctx->asynch_io)
pthread_mutex_lock (&ctx->io_lock);
if (ctx->callback) {
ctx->callback = NULL;
if (ctx->asynch_io)
pthread_mutex_unlock (&ctx->io_lock);
callback (uptr, ctx->io_status);
}
else {
if (ctx->asynch_io)
pthread_mutex_unlock (&ctx->io_lock);
}
}
static t_bool _tape_is_active (UNIT *uptr)