From c0854c3e1746f81abcba27505c7f8adc09ff2c45 Mon Sep 17 00:00:00 2001 From: Mikael Ronstrom Date: Thu, 28 Oct 2010 18:27:25 +0200 Subject: Added reporting of fsync to THD wait interface --- mysys/my_sync.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'mysys/my_sync.c') diff --git a/mysys/my_sync.c b/mysys/my_sync.c index bc050922ffc..6a4e26a6542 100644 --- a/mysys/my_sync.c +++ b/mysys/my_sync.c @@ -17,6 +17,16 @@ #include "mysys_err.h" #include +static void (*before_sync_wait)(void)= 0; +static void (*after_sync_wait)(void)= 0; + +void thr_set_sync_wait_callback(void (*before_wait)(void), + void (*after_wait)(void)) +{ + before_sync_wait= before_wait; + after_sync_wait= after_wait; +} + /* Sync data in file to disk @@ -48,6 +58,8 @@ int my_sync(File fd, myf my_flags) do { + if (before_sync_wait) + (*before_sync_wait)(); #if defined(F_FULLFSYNC) /* In Mac OS X >= 10.3 this call is safer than fsync() (it forces the @@ -75,6 +87,8 @@ int my_sync(File fd, myf my_flags) int er= errno; if (!(my_errno= er)) my_errno= -1; /* Unknown error */ + if (after_sync_wait) + (*after_sync_wait)(); if ((my_flags & MY_IGNORE_BADFD) && (er == EBADF || er == EINVAL || er == EROFS)) { @@ -84,6 +98,11 @@ int my_sync(File fd, myf my_flags) else if (my_flags & MY_WME) my_error(EE_SYNC, MYF(ME_BELL+ME_WAITTANG), my_filename(fd), my_errno); } + else + { + if (after_sync_wait) + (*after_sync_wait)(); + } DBUG_RETURN(res); } /* my_sync */ -- cgit v1.2.1