summaryrefslogtreecommitdiff
path: root/myisam/mi_close.c
diff options
context:
space:
mode:
Diffstat (limited to 'myisam/mi_close.c')
-rw-r--r--myisam/mi_close.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/myisam/mi_close.c b/myisam/mi_close.c
index 47308a5e9eb..2712f0ca283 100644
--- a/myisam/mi_close.c
+++ b/myisam/mi_close.c
@@ -70,8 +70,13 @@ int mi_close(register MI_INFO *info)
error=my_errno;
if (share->kfile >= 0)
{
- /* We must always flush the state with the current open_count. */
- if (share->mode != O_RDONLY)
+ /*
+ If we are crashed, we can safely flush the current state as it will
+ not change the crashed state.
+ We can NOT write the state in other cases as other threads
+ may be using the file at this point
+ */
+ if (share->mode != O_RDONLY && mi_is_crashed(info))
mi_state_info_write(share->kfile, &share->state, 1);
if (my_close(share->kfile,MYF(0)))
error = my_errno;