~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/thr_lock.cc

  • Committer: Mark Atwood
  • Date: 2011-12-15 23:13:18 UTC
  • mfrom: (2465.3.1 rf3)
  • Revision ID: me@mark.atwood.name-20111215231318-mt2y2q4s5ydp79q3
mergeĀ lp:~olafvdspek/drizzle/refactor14

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
 
115
115
void THR_LOCK_INFO::init()
116
116
{
117
 
  thread_id= internal::my_thread_var()->id;
 
117
  thread_id= internal::my_thread_var2()->id;
118
118
  n_cursors= 0;
119
119
}
120
120
 
146
146
 
147
147
static enum enum_thr_lock_result wait_for_lock(Session &session, struct st_lock_list *wait, THR_LOCK_DATA *data)
148
148
{
149
 
  internal::st_my_thread_var *thread_var= session.getThreadVar();
150
 
 
151
 
  boost::condition_variable_any *cond= &thread_var->suspend;
 
149
  boost::condition_variable_any *cond= &session.getThreadVar()->suspend;
152
150
  enum enum_thr_lock_result result= THR_LOCK_ABORTED;
153
151
  bool can_deadlock= test(data->owner->info->n_cursors);
154
152
 
161
159
  current_global_counters.locks_waited++;
162
160
 
163
161
  /* Set up control struct to allow others to abort locks */
164
 
  thread_var->current_mutex= data->lock->native_handle();
165
 
  thread_var->current_cond=  &thread_var->suspend;
166
 
  data->cond= &thread_var->suspend;;
 
162
  session.getThreadVar()->current_mutex= data->lock->native_handle();
 
163
  session.getThreadVar()->current_cond=  &session.getThreadVar()->suspend;
 
164
  data->cond= &session.getThreadVar()->suspend;;
167
165
 
168
 
  while (not thread_var->abort)
 
166
  while (not session.getThreadVar()->abort)
169
167
  {
170
168
    boost::mutex::scoped_lock scoped(*data->lock->native_handle(), boost::adopt_lock_t());
171
169
 
187
185
    }
188
186
    /*
189
187
      We must break the wait if one of the following occurs:
190
 
      - the connection has been aborted (!thread_var->abort), but
 
188
      - the connection has been aborted (!session.getThreadVar()->abort), but
191
189
        this is not a delayed insert thread (in_wait_list). For a delayed
192
190
        insert thread the proper action at shutdown is, apparently, to
193
191
        acquire the lock and complete the insert.
210
208
    if (data->cond)                             /* aborted or timed out */
211
209
    {
212
210
      if (((*data->prev)=data->next))           /* remove from wait-list */
 
211
      {
213
212
        data->next->prev= data->prev;
 
213
      }
214
214
      else
 
215
      {
215
216
        wait->last=data->prev;
 
217
      }
216
218
      data->type= TL_UNLOCK;                    /* No lock */
217
219
      wake_up_waiters(data->lock);
218
220
    }
224
226
  data->lock->unlock();
225
227
 
226
228
  /* The following must be done after unlock of lock->mutex */
227
 
  boost::mutex::scoped_lock scopedLock(thread_var->mutex);
228
 
  thread_var->current_mutex= NULL;
229
 
  thread_var->current_cond= NULL;
 
229
  boost::mutex::scoped_lock scopedLock(session.getThreadVar()->mutex);
 
230
  session.getThreadVar()->current_mutex= NULL;
 
231
  session.getThreadVar()->current_cond= NULL;
 
232
 
230
233
  return(result);
231
234
}
232
235
 
374
377
 
375
378
  /* Can't get lock yet;  Wait for it */
376
379
  return(wait_for_lock(session, wait_queue, data));
 
380
 
377
381
end:
378
382
  lock->unlock();
379
383