~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to storage/myisam/mi_locking.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2006 MySQL AB
 
1
/*
 
2
   Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
/*
17
19
  locking of isam-tables.
29
31
  int error;
30
32
  uint count;
31
33
  MYISAM_SHARE *share=info->s;
32
 
  uint flag;
33
34
  DBUG_ENTER("mi_lock_database");
34
35
  DBUG_PRINT("enter",("lock_type: %d  old lock %d  r_locks: %u  w_locks: %u "
35
36
                      "global_changed:  %d  open_count: %u  name: '%s'",
48
49
    DBUG_RETURN(0);
49
50
  }
50
51
 
51
 
  flag=error=0;
 
52
  error= 0;
52
53
  pthread_mutex_lock(&share->intern_lock);
53
54
  if (share->kfile >= 0)                /* May only be false on windows */
54
55
  {
120
121
        {
121
122
          if (share->r_locks)
122
123
          {                                     /* Only read locks left */
123
 
            flag=1;
124
124
            if (my_lock(share->kfile,F_RDLCK,0L,F_TO_EOF,
125
125
                        MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error)
126
126
              error=my_errno;
127
127
          }
128
128
          else if (!share->w_locks)
129
129
          {                                     /* No more locks */
130
 
            flag=1;
131
130
            if (my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF,
132
131
                        MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error)
133
132
              error=my_errno;
148
147
        */
149
148
        if (share->w_locks == 1)
150
149
        {
151
 
          flag=1;
152
150
          if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
153
151
                      MYF(MY_SEEK_NOT_DONE)))
154
152
          {
163
161
      }
164
162
      if (!share->r_locks && !share->w_locks)
165
163
      {
166
 
        flag=1;
167
164
        if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
168
165
                    info->lock_wait | MY_SEEK_NOT_DONE))
169
166
        {
188
185
      {                                         /* Change READONLY to RW */
189
186
        if (share->r_locks == 1)
190
187
        {
191
 
          flag=1;
192
188
          if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
193
189
                      MYF(info->lock_wait | MY_SEEK_NOT_DONE)))
194
190
          {
205
201
      {
206
202
        if (!share->w_locks)
207
203
        {
208
 
          flag=1;
209
204
          if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
210
205
                      info->lock_wait | MY_SEEK_NOT_DONE))
211
206
          {
252
247
  }
253
248
#endif
254
249
  pthread_mutex_unlock(&share->intern_lock);
255
 
#if defined(FULL_LOG) || defined(_lint)
256
 
  lock_type|=(int) (flag << 8);         /* Set bit to set if real lock */
257
 
  myisam_log_command(MI_LOG_LOCK,info,(uchar*) &lock_type,sizeof(lock_type),
258
 
                     error);
259
 
#endif
260
250
  DBUG_RETURN(error);
261
251
} /* mi_lock_database */
262
252