~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_locking.c

MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
          if (share->r_locks)
118
118
          {                                     /* Only read locks left */
119
119
            flag=1;
120
 
            if (my_lock(share->kfile,F_RDLCK,0L,F_TO_EOF,
121
 
                        MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error)
122
 
              error=my_errno;
123
120
          }
124
121
          else if (!share->w_locks)
125
122
          {                                     /* No more locks */
126
123
            flag=1;
127
 
            if (my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF,
128
 
                        MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error)
129
 
              error=my_errno;
130
124
          }
131
125
        }
132
126
      }
146
140
        if (share->w_locks == 1)
147
141
        {
148
142
          flag=1;
149
 
          if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
150
 
                      MYF(MY_SEEK_NOT_DONE)))
151
 
          {
152
 
            error=my_errno;
153
 
            break;
154
 
          }
155
143
        }
156
144
        share->w_locks--;
157
145
        share->r_locks++;
161
149
      if (!share->r_locks && !share->w_locks)
162
150
      {
163
151
        flag=1;
164
 
        if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
165
 
                    info->lock_wait | MY_SEEK_NOT_DONE))
 
152
        if (mi_state_info_read_dsk(share->kfile, &share->state, 1))
166
153
        {
167
154
          error=my_errno;
168
155
          break;
170
157
        if (mi_state_info_read_dsk(share->kfile, &share->state, 1))
171
158
        {
172
159
          error=my_errno;
173
 
          VOID(my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)));
174
160
          my_errno=error;
175
161
          break;
176
162
        }
187
173
        if (share->r_locks == 1)
188
174
        {
189
175
          flag=1;
190
 
          if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
191
 
                      MYF(info->lock_wait | MY_SEEK_NOT_DONE)))
192
 
          {
193
 
            error=my_errno;
194
 
            break;
195
 
          }
196
176
          share->r_locks--;
197
177
          share->w_locks++;
198
178
          info->lock_type=lock_type;
204
184
        if (!share->w_locks)
205
185
        {
206
186
          flag=1;
207
 
          if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
208
 
                      info->lock_wait | MY_SEEK_NOT_DONE))
209
 
          {
210
 
            error=my_errno;
211
 
            break;
212
 
          }
213
187
          if (!share->r_locks)
214
188
          {
215
189
            if (mi_state_info_read_dsk(share->kfile, &share->state, 1))
216
190
            {
217
191
              error=my_errno;
218
 
              VOID(my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF,
219
 
                           info->lock_wait | MY_SEEK_NOT_DONE));
220
192
              my_errno=error;
221
193
              break;
222
194
            }
352
324
    1  not ok
353
325
*/
354
326
 
355
 
my_bool mi_check_status(void *param)
 
327
bool mi_check_status(void *param)
356
328
{
357
329
  MI_INFO *info=(MI_INFO*) param;
358
330
  /*
377
349
    MYISAM_SHARE *share=info->s;
378
350
    if (!share->tot_locks)
379
351
    {
380
 
      if (my_lock(share->kfile,lock_type,0L,F_TO_EOF,
381
 
                  info->lock_wait | MY_SEEK_NOT_DONE))
382
 
        return(1);
383
352
      if (mi_state_info_read_dsk(share->kfile, &share->state, 1))
384
353
      {
385
354
        int error=my_errno ? my_errno : -1;
386
 
        VOID(my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF,
387
 
                     MYF(MY_SEEK_NOT_DONE)));
388
355
        my_errno=error;
389
356
        return(1);
390
357
      }
431
398
      }
432
399
#endif
433
400
    }
434
 
    if (!(operation & WRITEINFO_NO_UNLOCK) &&
435
 
        my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF,
436
 
                MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error)
437
 
      return(1);
438
401
    my_errno=olderror;
439
402
  }
440
403
  else if (operation)
482
445
    was incremented in the same process.
483
446
 
484
447
  This mean that if we are the only process using the file, the open_count
485
 
  tells us if the MYISAM file wasn't properly closed. (This is true if
486
 
  my_disable_locking is set).
487
 
*/
 
448
  tells us if the MYISAM file wasn't properly closed.*/
488
449
 
489
450
 
490
451
int _mi_mark_file_changed(MI_INFO *info)