From 63ce9fe6bc5cf6e2cdaa8e3ff56a61119ff8edcb Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Tue, 16 Feb 2016 11:04:49 +0200 Subject: [PATCH] Fixed formatting and added more error checks Added log messages when ftruncate fails and cleaned up formatting. --- server/modules/routing/binlog/blr_file.c | 10 ++++++++-- server/modules/routing/binlog/blr_master.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/server/modules/routing/binlog/blr_file.c b/server/modules/routing/binlog/blr_file.c index 35da090c2..637a2054a 100644 --- a/server/modules/routing/binlog/blr_file.c +++ b/server/modules/routing/binlog/blr_file.c @@ -338,8 +338,14 @@ int n; router->service->name, router->last_written, router->binlog_name, strerror_r(errno, err_msg, sizeof(err_msg))); - /* Remove any partual event that was written */ - ftruncate(router->binlog_fd, router->last_written); + /* Remove any partial event that was written */ + if (ftruncate(router->binlog_fd, router->last_written)) + { + MXS_ERROR("%s: Failed to truncate binlog record at %lu of %s, %s. ", + router->service->name, router->last_written, + router->binlog_name, + strerror_r(errno, err_msg, sizeof(err_msg))); + } return 0; } spinlock_acquire(&router->binlog_lock); diff --git a/server/modules/routing/binlog/blr_master.c b/server/modules/routing/binlog/blr_master.c index 8787bcb36..1fbefd587 100644 --- a/server/modules/routing/binlog/blr_master.c +++ b/server/modules/routing/binlog/blr_master.c @@ -2388,7 +2388,7 @@ int n; strerror_r(errno, err_msg, sizeof(err_msg))); /* Remove any partial event that was written */ - if(ftruncate(router->binlog_fd, router->last_written)) + if (ftruncate(router->binlog_fd, router->last_written)) { MXS_ERROR("%s: Failed to truncate binlog record at %lu of %s, %s. ", router->service->name, router->last_written,