diff --git a/server/modules/routing/binlog/blr_file.c b/server/modules/routing/binlog/blr_file.c index ab212b671..54749aec5 100644 --- a/server/modules/routing/binlog/blr_file.c +++ b/server/modules/routing/binlog/blr_file.c @@ -640,10 +640,14 @@ blr_close_binlog(ROUTER_INSTANCE *router, BLFILE *file) close(file->fd); file->fd = -1; } - if (file->refcnt == 0) - free(file); - spinlock_release(&file->lock); + if (file->refcnt == 0) { + spinlock_release(&file->lock); + + free(file); + } else { + spinlock_release(&file->lock); + } } /**