diff --git a/server/modules/routing/binlog/blr_file.c b/server/modules/routing/binlog/blr_file.c index 36b0996ae..907c9397e 100644 --- a/server/modules/routing/binlog/blr_file.c +++ b/server/modules/routing/binlog/blr_file.c @@ -596,9 +596,14 @@ blr_close_binlog(ROUTER_INSTANCE *router, BLFILE *file) close(file->fd); file->fd = -1; } - spinlock_release(&file->lock); - if (file->refcnt == 0) + + if (file->refcnt == 0) { + spinlock_release(&file->lock); + free(file); + } else { + spinlock_release(&file->lock); + } } /**