~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/thr_lock.cc

  • Committer: Brian Aker
  • Date: 2010-11-27 13:38:27 UTC
  • mfrom: (1955.1.3 quick)
  • Revision ID: brian@tangent.org-20101127133827-fowoi26sizq1zneg
Rollup of staging, mostly UDL

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
#include "drizzled/pthread_globals.h"
60
60
 
61
61
#include "drizzled/session.h"
 
62
#include "drizzled/current_session.h"
62
63
 
63
64
#include "thr_lock.h"
64
65
#include "drizzled/internal/m_string.h"
91
92
 
92
93
uint64_t max_write_lock_count= UINT64_MAX;
93
94
 
94
 
void thr_multi_unlock(THR_LOCK_DATA **data,uint32_t count);
 
95
static void thr_multi_unlock(THR_LOCK_DATA **data,uint32_t count);
95
96
 
96
97
/*
97
98
** For the future (now the thread specific cond is alloced by my_pthread.c)
119
120
void THR_LOCK_INFO::init()
120
121
{
121
122
  internal::st_my_thread_var *tmp= my_thread_var;
 
123
  thread= tmp->pthread_self;
122
124
  thread_id= tmp->id;
123
125
  n_cursors= 0;
124
126
}
149
151
static void wake_up_waiters(THR_LOCK *lock);
150
152
 
151
153
 
152
 
static enum enum_thr_lock_result wait_for_lock(Session &session, struct st_lock_list *wait, THR_LOCK_DATA *data)
 
154
static enum enum_thr_lock_result wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, bool in_wait_list)
153
155
{
154
 
  internal::st_my_thread_var *thread_var= session.getThreadVar();
 
156
  Session *session= current_session;
 
157
  internal::st_my_thread_var *thread_var= session->getThreadVar();
155
158
 
156
159
  boost::condition_variable_any *cond= &thread_var->suspend;
157
160
  enum enum_thr_lock_result result= THR_LOCK_ABORTED;
158
161
  bool can_deadlock= test(data->owner->info->n_cursors);
159
162
 
 
163
  if (!in_wait_list)
160
164
  {
161
165
    (*wait->last)=data;                         /* Wait for lock */
162
166
    data->prev= wait->last;
170
174
  thread_var->current_cond=  &thread_var->suspend;
171
175
  data->cond= &thread_var->suspend;;
172
176
 
173
 
  while (not thread_var->abort)
 
177
  while (!thread_var->abort || in_wait_list)
174
178
  {
175
179
    boost_unique_lock_t scoped(*data->lock->native_handle(), boost::adopt_lock_t());
176
180
 
236
240
}
237
241
 
238
242
 
239
 
static enum enum_thr_lock_result thr_lock(Session &session, THR_LOCK_DATA *data, THR_LOCK_OWNER *owner, enum thr_lock_type lock_type)
 
243
static enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner, enum thr_lock_type lock_type)
240
244
{
241
245
  THR_LOCK *lock= data->lock;
242
246
  enum enum_thr_lock_result result= THR_LOCK_SUCCESS;
384
388
  }
385
389
 
386
390
  /* Can't get lock yet;  Wait for it */
387
 
  return(wait_for_lock(session, wait_queue, data));
 
391
  return(wait_for_lock(wait_queue, data, 0));
388
392
end:
389
393
  lock->unlock();
390
394
 
591
595
 
592
596
 
593
597
enum enum_thr_lock_result
594
 
thr_multi_lock(Session &session, THR_LOCK_DATA **data, uint32_t count, THR_LOCK_OWNER *owner)
 
598
thr_multi_lock(THR_LOCK_DATA **data, uint32_t count, THR_LOCK_OWNER *owner)
595
599
{
596
600
  THR_LOCK_DATA **pos,**end;
597
601
  if (count > 1)
599
603
  /* lock everything */
600
604
  for (pos=data,end=data+count; pos < end ; pos++)
601
605
  {
602
 
    enum enum_thr_lock_result result= thr_lock(session, *pos, owner, (*pos)->type);
 
606
    enum enum_thr_lock_result result= thr_lock(*pos, owner, (*pos)->type);
603
607
    if (result != THR_LOCK_SUCCESS)
604
608
    {                                           /* Aborted */
605
609
      thr_multi_unlock(data,(uint32_t) (pos-data));
628
632
 
629
633
  /* free all locks */
630
634
 
631
 
void thr_multi_unlock(THR_LOCK_DATA **data,uint32_t count)
 
635
static void thr_multi_unlock(THR_LOCK_DATA **data,uint32_t count)
632
636
{
633
637
  THR_LOCK_DATA **pos,**end;
634
638