~mordred/libmemcached/fix-weird-link

« back to all changes in this revision

Viewing changes to clients/memslap.c

  • Committer: Brian Aker
  • Date: 2010-01-19 04:59:05 UTC
  • mfrom: (753.1.1 libmemcached)
  • Revision ID: brian@gaz-20100119045905-e6vjp6lcp0b7bymi
Merge memslap

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
  pthread_mutex_init(&ms_global.init_lock.lock, NULL);
127
127
  pthread_cond_init(&ms_global.init_lock.cond, NULL);
128
128
 
 
129
  ms_global.warmup_lock.count = 0;
 
130
  pthread_mutex_init(&ms_global.warmup_lock.lock, NULL);
 
131
  pthread_cond_init(&ms_global.warmup_lock.cond, NULL);
 
132
 
129
133
  ms_global.run_lock.count= 0;
130
134
  pthread_mutex_init(&ms_global.run_lock.lock, NULL);
131
135
  pthread_cond_init(&ms_global.run_lock.cond, NULL);
141
145
  pthread_mutex_destroy(&ms_global.init_lock.lock);
142
146
  pthread_cond_destroy(&ms_global.init_lock.cond);
143
147
 
 
148
  pthread_mutex_destroy(&ms_global.warmup_lock.lock);
 
149
  pthread_cond_destroy(&ms_global.warmup_lock.cond);
 
150
 
144
151
  pthread_mutex_destroy(&ms_global.run_lock.lock);
145
152
  pthread_cond_destroy(&ms_global.run_lock.cond);
146
153
 
771
778
  int second= 0;
772
779
  struct timeval start_time, end_time;
773
780
 
 
781
  /* Wait all the threads complete initialization. */
 
782
  pthread_mutex_lock(&ms_global.init_lock.lock);
 
783
  while (ms_global.init_lock.count < ms_setting.nthreads)
 
784
  {
 
785
    pthread_cond_wait(&ms_global.init_lock.cond,
 
786
                      &ms_global.init_lock.lock);
 
787
  }
 
788
  pthread_mutex_unlock(&ms_global.init_lock.lock);
 
789
 
774
790
  /* only when there is no set operation it need warm up */
775
791
  if (ms_setting.cmd_distr[CMD_SET].cmd_prop < PROP_ERROR)
776
792
  {
777
793
    /* Wait all the connects complete warm up. */
778
 
    pthread_mutex_lock(&ms_global.init_lock.lock);
779
 
    while (ms_global.init_lock.count < (int)ms_setting.nconns)
780
 
    {
781
 
      pthread_cond_wait(&ms_global.init_lock.cond,
782
 
                        &ms_global.init_lock.lock);
 
794
    pthread_mutex_lock(&ms_global.warmup_lock.lock);
 
795
    while (ms_global.warmup_lock.count < (int)ms_setting.nconns) {
 
796
      pthread_cond_wait(&ms_global.warmup_lock.cond, &ms_global.warmup_lock.lock);
783
797
    }
784
 
    pthread_mutex_unlock(&ms_global.init_lock.lock);
 
798
    pthread_mutex_unlock(&ms_global.warmup_lock.lock);
785
799
  }
786
 
 
787
800
  ms_global.finish_warmup= true;
788
801
 
789
802
  /* running in "run time" mode, user specify run time */