~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_locking.c

  • Committer: Brian Aker
  • Date: 2008-07-14 22:18:37 UTC
  • mfrom: (77.1.96 codestyle)
  • Revision ID: brian@tangent.org-20080714221837-oceoshx7fjkla9u3
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
          if (share->r_locks)
126
126
          {                                     /* Only read locks left */
127
127
            flag=1;
128
 
            if (my_lock(share->kfile,F_RDLCK,0L,F_TO_EOF,
129
 
                        MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error)
130
 
              error=my_errno;
131
128
          }
132
129
          else if (!share->w_locks)
133
130
          {                                     /* No more locks */
134
131
            flag=1;
135
 
            if (my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF,
136
 
                        MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error)
137
 
              error=my_errno;
138
132
          }
139
133
        }
140
134
      }
154
148
        if (share->w_locks == 1)
155
149
        {
156
150
          flag=1;
157
 
          if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
158
 
                      MYF(MY_SEEK_NOT_DONE)))
159
 
          {
160
 
            error=my_errno;
161
 
            break;
162
 
          }
163
151
        }
164
152
        share->w_locks--;
165
153
        share->r_locks++;
169
157
      if (!share->r_locks && !share->w_locks)
170
158
      {
171
159
        flag=1;
172
 
        if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
173
 
                    info->lock_wait | MY_SEEK_NOT_DONE))
174
 
        {
175
 
          error=my_errno;
176
 
          break;
177
 
        }
178
160
        if (mi_state_info_read_dsk(share->kfile, &share->state, 1))
179
161
        {
180
162
          error=my_errno;
181
 
          VOID(my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)));
182
163
          my_errno=error;
183
164
          break;
184
165
        }
195
176
        if (share->r_locks == 1)
196
177
        {
197
178
          flag=1;
198
 
          if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
199
 
                      MYF(info->lock_wait | MY_SEEK_NOT_DONE)))
200
 
          {
201
 
            error=my_errno;
202
 
            break;
203
 
          }
204
179
          share->r_locks--;
205
180
          share->w_locks++;
206
181
          info->lock_type=lock_type;
212
187
        if (!share->w_locks)
213
188
        {
214
189
          flag=1;
215
 
          if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
216
 
                      info->lock_wait | MY_SEEK_NOT_DONE))
217
 
          {
218
 
            error=my_errno;
219
 
            break;
220
 
          }
221
190
          if (!share->r_locks)
222
191
          {
223
192
            if (mi_state_info_read_dsk(share->kfile, &share->state, 1))
224
193
            {
225
194
              error=my_errno;
226
 
              VOID(my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF,
227
 
                           info->lock_wait | MY_SEEK_NOT_DONE));
228
195
              my_errno=error;
229
196
              break;
230
197
            }
411
378
    MYISAM_SHARE *share=info->s;
412
379
    if (!share->tot_locks)
413
380
    {
414
 
      if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
415
 
                  info->lock_wait | MY_SEEK_NOT_DONE))
416
 
        DBUG_RETURN(1);
417
381
      if (mi_state_info_read_dsk(share->kfile, &share->state, 1))
418
382
      {
419
383
        int error=my_errno ? my_errno : -1;
420
 
        VOID(my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF,
421
 
                     MYF(MY_SEEK_NOT_DONE)));
422
384
        my_errno=error;
423
385
        DBUG_RETURN(1);
424
386
      }
468
430
      }
469
431
#endif
470
432
    }
471
 
    if (!(operation & WRITEINFO_NO_UNLOCK) &&
472
 
        my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF,
473
 
                MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error)
474
 
      DBUG_RETURN(1);
475
433
    my_errno=olderror;
476
434
  }
477
435
  else if (operation)
520
478
    was incremented in the same process.
521
479
 
522
480
  This mean that if we are the only process using the file, the open_count
523
 
  tells us if the MYISAM file wasn't properly closed. (This is true if
524
 
  my_disable_locking is set).
525
 
*/
 
481
  tells us if the MYISAM file wasn't properly closed.*/
526
482
 
527
483
 
528
484
int _mi_mark_file_changed(MI_INFO *info)