~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to storage/myisam/mi_close.c

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
  int error=0,flag;
28
28
  MYISAM_SHARE *share=info->s;
29
29
  DBUG_ENTER("mi_close");
30
 
  DBUG_PRINT("enter",("base: 0x%lx  reopen: %u  locks: %u",
31
 
                      (long) info, (uint) share->reopen,
 
30
  DBUG_PRINT("enter",("base: %p  reopen: %u  locks: %u",
 
31
                      info, (uint) share->reopen,
32
32
                      (uint) share->tot_locks));
33
33
 
34
34
  pthread_mutex_lock(&THR_LOCK_myisam);
52
52
  }
53
53
  if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
54
54
  {
 
55
    /* Logically there should not be a WRITE_CACHE at this stage */
 
56
    DBUG_ASSERT(!(info->opt_flag & WRITE_CACHE_USED));
55
57
    if (end_io_cache(&info->rec_cache))
56
58
      error=my_errno;
57
59
    info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
67
69
        flush_key_blocks(share->key_cache, share->kfile,
68
70
                         share->temporary ? FLUSH_IGNORE_CHANGED :
69
71
                         FLUSH_RELEASE))
 
72
    {
70
73
      error=my_errno;
 
74
      mi_print_error(share, HA_ERR_CRASHED);
 
75
      mi_mark_crashed(info);            /* Mark that table must be checked */
 
76
    }
71
77
    if (share->kfile >= 0)
72
78
    {
73
79
      /*
75
81
        not change the crashed state.
76
82
        We can NOT write the state in other cases as other threads
77
83
        may be using the file at this point
 
84
        IF using --external-locking.
78
85
      */
79
86
      if (share->mode != O_RDONLY && mi_is_crashed(info))
80
 
        mi_state_info_write(share->kfile, &share->state, 1);
 
87
        mi_state_info_write(share, share->kfile, &share->state, 1);
 
88
      if (share->MI_LOG_OPEN_stored_in_physical_log)
 
89
        _myisam_log_command(&myisam_physical_log, MI_LOG_CLOSE, share,
 
90
                            NULL, 0, error);
81
91
      if (my_close(share->kfile,MYF(0)))
82
92
        error = my_errno;
83
93
    }
92
102
    }
93
103
#ifdef THREAD
94
104
    thr_lock_delete(&share->lock);
95
 
    VOID(pthread_mutex_destroy(&share->intern_lock));
 
105
    pthread_mutex_destroy(&share->intern_lock);
 
106
    my_atomic_rwlock_destroy(&share->physical_logging_rwlock);
96
107
    {
97
108
      int i,keys;
98
109
      keys = share->state.header.keys;
99
 
      VOID(rwlock_destroy(&share->mmap_lock));
 
110
      (void) rwlock_destroy(&share->mmap_lock);
100
111
      for(i=0; i<keys; i++) {
101
 
        VOID(rwlock_destroy(&share->key_root_lock[i]));
 
112
        (void) rwlock_destroy(&share->key_root_lock[i]);
102
113
      }
103
114
    }
104
115
#endif
113
124
  if (info->dfile >= 0 && my_close(info->dfile,MYF(0)))
114
125
    error = my_errno;
115
126
 
116
 
  myisam_log_command(MI_LOG_CLOSE,info,NULL,0,error);
 
127
  myisam_log_command_logical(MI_LOG_CLOSE, info, NULL, 0, error);
117
128
  my_free((uchar*) info,MYF(0));
118
129
 
119
130
  if (error)