27 int mi_panic(
enum ha_panic_function flag)
30 LIST *list_element,*next_open;
32 DBUG_ENTER(
"mi_panic");
35 for (list_element=myisam_open_list ; list_element ; list_element=next_open)
37 next_open=list_element->next;
38 info=(
MI_INFO*) list_element->data;
47 #ifdef CANT_OPEN_FILES_TWICE
48 if (info->s->options & HA_OPTION_READ_ONLY_DATA)
51 if (flush_key_blocks(info->s->key_cache, info->s->kfile, FLUSH_RELEASE))
53 if (info->opt_flag & WRITE_CACHE_USED)
54 if (flush_io_cache(&info->rec_cache))
56 if (info->opt_flag & READ_CACHE_USED)
58 if (flush_io_cache(&info->rec_cache))
60 reinit_io_cache(&info->rec_cache,READ_CACHE,0,
61 (pbool) (info->lock_type != F_UNLCK),1);
63 if (info->lock_type != F_UNLCK && ! info->was_locked)
65 info->was_locked=info->lock_type;
66 if (mi_lock_database(info,F_UNLCK))
69 #ifdef CANT_OPEN_FILES_TWICE
74 info->s->kfile=info->dfile= -1;
78 #ifdef CANT_OPEN_FILES_TWICE
80 char name_buff[FN_REFLEN];
81 if (info->s->kfile < 0)
86 info->mode, MYF(MY_WME))) < 0)
94 info->mode, MYF(MY_WME))) < 0)
96 info->rec_cache.file=info->dfile;
100 if (info->was_locked)
102 if (mi_lock_database(info, info->was_locked))
109 if (flag == HA_PANIC_CLOSE)
117 DBUG_RETURN(my_errno=error);