~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_panic.cc

  • Committer: lbieber
  • Date: 2010-01-21 18:21:39 UTC
  • mto: This revision was merged to the branch mainline in revision 1277.
  • Revision ID: lbieber@orisndriz08-20100121182139-h549us3gsysyyl0e
clean up japanese tests, remove tests that no longer apply.  In test-run.pl change mysql_version_id to drizzle_version_id

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
#include "myisam_priv.h"
17
17
 
18
18
using namespace std;
19
 
using namespace drizzled;
20
19
 
21
20
        /* if flag == HA_PANIC_CLOSE then all misam files are closed */
22
21
        /* if flag == HA_PANIC_WRITE then all misam files are unlocked and
31
30
  int error=0;
32
31
  MI_INFO *info;
33
32
 
34
 
  THR_LOCK_myisam.lock();
 
33
  pthread_mutex_lock(&THR_LOCK_myisam);
35
34
  list<MI_INFO *>::iterator it= myisam_open_list.begin();
36
35
  while (it != myisam_open_list.end())
37
36
  {
38
37
    info= *it;
39
38
    switch (flag) {
40
39
    case HA_PANIC_CLOSE:
41
 
      THR_LOCK_myisam.unlock(); /* Not exactly right... */
 
40
      pthread_mutex_unlock(&THR_LOCK_myisam);   /* Not exactly right... */
42
41
      if (mi_close(info))
43
42
        error=errno;
44
 
      THR_LOCK_myisam.lock();
 
43
      pthread_mutex_lock(&THR_LOCK_myisam);
45
44
      break;
46
45
    case HA_PANIC_WRITE:                /* Do this to free databases */
47
46
#ifdef CANT_OPEN_FILES_TWICE
48
47
      if (info->s->options & HA_OPTION_READ_ONLY_DATA)
49
48
        break;
50
49
#endif
51
 
      if (flush_key_blocks(info->s->getKeyCache(), info->s->kfile, FLUSH_RELEASE))
 
50
      if (flush_key_blocks(info->s->key_cache, info->s->kfile, FLUSH_RELEASE))
52
51
        error=errno;
53
52
      if (info->opt_flag & WRITE_CACHE_USED)
54
53
        if (flush_io_cache(&info->rec_cache))
57
56
      {
58
57
        if (flush_io_cache(&info->rec_cache))
59
58
          error=errno;
60
 
        info->rec_cache.reinit_io_cache(internal::READ_CACHE,0, (bool) (info->lock_type != F_UNLCK),1);
 
59
        reinit_io_cache(&info->rec_cache,READ_CACHE,0,
 
60
                       (bool) (info->lock_type != F_UNLCK),1);
61
61
      }
62
62
      if (info->lock_type != F_UNLCK && ! info->was_locked)
63
63
      {
66
66
          error=errno;
67
67
      }
68
68
#ifdef CANT_OPEN_FILES_TWICE
69
 
      if (info->s->kfile >= 0 && internal::my_close(info->s->kfile,MYF(0)))
 
69
      if (info->s->kfile >= 0 && my_close(info->s->kfile,MYF(0)))
70
70
        error = errno;
71
 
      if (info->dfile >= 0 && internal::my_close(info->dfile,MYF(0)))
 
71
      if (info->dfile >= 0 && my_close(info->dfile,MYF(0)))
72
72
        error = errno;
73
73
      info->s->kfile=info->dfile= -1;   /* Files aren't open anymore */
74
74
      break;
78
78
      {                                 /* Open closed files */
79
79
        char name_buff[FN_REFLEN];
80
80
        if (info->s->kfile < 0)
81
 
          if ((info->s->kfile= internal::my_open(internal::fn_format(name_buff,info->filename,"",
 
81
          if ((info->s->kfile= my_open(fn_format(name_buff,info->filename,"",
82
82
                                              N_NAME_IEXT,4),info->mode,
83
83
                                    MYF(MY_WME))) < 0)
84
84
            error = errno;
85
85
        if (info->dfile < 0)
86
86
        {
87
 
          if ((info->dfile= internal::my_open(internal::fn_format(name_buff,info->filename,"",
 
87
          if ((info->dfile= my_open(fn_format(name_buff,info->filename,"",
88
88
                                              N_NAME_DEXT,4),info->mode,
89
89
                                    MYF(MY_WME))) < 0)
90
90
            error = errno;
102
102
    }
103
103
    ++it;
104
104
  }
105
 
  THR_LOCK_myisam.unlock();
 
105
  pthread_mutex_unlock(&THR_LOCK_myisam);
106
106
  if (!error)
107
107
    return(0);
108
108
  return(errno=error);