~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_locking.c

  • Committer: Stewart Smith
  • Date: 2009-01-12 05:43:13 UTC
  • mto: (784.1.4 for-brian)
  • mto: This revision was merged to the branch mainline in revision 785.
  • Revision ID: stewart@flamingspork.com-20090112054313-edk6kpf4l6kpz4j7
fix archive_basic for drizzle

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <mystrings/m_ctype.h>
25
25
#include <mysys/my_tree.h>
26
26
#include <mysys/queues.h>
 
27
#include <drizzled/util/test.h>
27
28
 
28
29
        /* lock table by F_UNLCK, F_RDLCK or F_WRLCK */
29
30
 
30
31
int mi_lock_database(MI_INFO *info, int lock_type)
31
32
{
32
33
  int error;
33
 
  uint count;
 
34
  uint32_t count;
34
35
  MYISAM_SHARE *share=info->s;
35
 
  uint flag;
 
36
  uint32_t flag;
36
37
 
37
38
  if (share->options & HA_OPTION_READ_ONLY_DATA ||
38
39
      info->lock_type == lock_type)
83
84
        (info->s->nonmmaped_inserts > MAX_NONMAPPED_INSERTS))
84
85
    {
85
86
      if (info->s->concurrent_insert)
86
 
        rw_wrlock(&info->s->mmap_lock);
 
87
        pthread_rwlock_wrlock(&info->s->mmap_lock);
87
88
      mi_remap_file(info, info->s->state.state.data_file_length);
88
89
      info->s->nonmmaped_inserts= 0;
89
90
      if (info->s->concurrent_insert)
90
 
        rw_unlock(&info->s->mmap_lock);
 
91
        pthread_rwlock_unlock(&info->s->mmap_lock);
91
92
    }
92
93
#endif
93
94
          share->state.process= share->last_process=share->this_process;
160
161
          break;
161
162
        }
162
163
      }
163
 
      VOID(_mi_test_if_changed(info));
 
164
      _mi_test_if_changed(info);
164
165
      share->r_locks++;
165
166
      share->tot_locks++;
166
167
      info->lock_type=lock_type;
194
195
          }
195
196
        }
196
197
      }
197
 
      VOID(_mi_test_if_changed(info));
198
 
        
 
198
      _mi_test_if_changed(info);
 
199
 
199
200
      info->lock_type=lock_type;
200
201
      info->invalidator=info->s->invalidator;
201
202
      share->w_locks++;
212
213
    /*
213
214
       Check for bad file descriptors if this table is part
214
215
       of a merge union. Failing to capture this may cause
215
 
       a crash on windows if the table is renamed and 
 
216
       a crash on windows if the table is renamed and
216
217
       later on referenced by the merge table.
217
218
     */
218
219
    if( info->owned_by_merge && (info->s)->kfile < 0 )
224
225
  pthread_mutex_unlock(&share->intern_lock);
225
226
#if defined(FULL_LOG) || defined(_lint)
226
227
  lock_type|=(int) (flag << 8);         /* Set bit to set if real lock */
227
 
  myisam_log_command(MI_LOG_LOCK,info,(uchar*) &lock_type,sizeof(lock_type),
 
228
  myisam_log_command(MI_LOG_LOCK,info,(unsigned char*) &lock_type,sizeof(lock_type),
228
229
                     error);
229
230
#endif
230
231
  return(error);
307
308
 
308
309
  IMPLEMENTATION
309
310
    Allow concurrent inserts if we don't have a hole in the table or
310
 
    if there is no active write lock and there is active read locks and 
 
311
    if there is no active write lock and there is active read locks and
311
312
    myisam_concurrent_insert == 2. In this last case the new
312
313
    row('s) are inserted at end of file instead of filling up the hole.
313
314
 
356
357
      }
357
358
    }
358
359
    if (check_keybuffer)
359
 
      VOID(_mi_test_if_changed(info));
 
360
      _mi_test_if_changed(info);
360
361
    info->invalidator=info->s->invalidator;
361
362
  }
362
363
  else if (lock_type == F_WRLCK && info->lock_type == F_RDLCK)
373
374
  request
374
375
*/
375
376
 
376
 
int _mi_writeinfo(register MI_INFO *info, uint operation)
 
377
int _mi_writeinfo(register MI_INFO *info, uint32_t operation)
377
378
{
378
379
  int error,olderror;
379
380
  MYISAM_SHARE *share=info->s;
416
417
      share->state.update_count != info->last_loop)
417
418
  {                                             /* Keyfile has changed */
418
419
    if (share->state.process != share->this_process)
419
 
      VOID(flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE));
 
420
      flush_key_blocks(share->key_cache, share->kfile, FLUSH_RELEASE);
420
421
    share->last_process=share->state.process;
421
422
    info->last_unique=  share->state.unique;
422
423
    info->last_loop=    share->state.update_count;
449
450
 
450
451
int _mi_mark_file_changed(MI_INFO *info)
451
452
{
452
 
  uchar buff[3];
 
453
  unsigned char buff[3];
453
454
  register MYISAM_SHARE *share=info->s;
454
455
 
455
456
  if (!(share->state.changed & STATE_CHANGED) || ! share->global_changed)
481
482
 
482
483
int _mi_decrement_open_count(MI_INFO *info)
483
484
{
484
 
  uchar buff[2];
 
485
  unsigned char buff[2];
485
486
  register MYISAM_SHARE *share=info->s;
486
487
  int lock_error=0,write_error=0;
487
488
  if (share->global_changed)
488
489
  {
489
 
    uint old_lock=info->lock_type;
 
490
    uint32_t old_lock=info->lock_type;
490
491
    share->global_changed=0;
491
492
    lock_error=mi_lock_database(info,F_WRLCK);
492
493
    /* Its not fatal even if we couldn't get the lock ! */