~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/thr_lock.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

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