~clint-fewbar/drizzle/regex-policy-cache-limiter

« back to all changes in this revision

Viewing changes to plugin/user_locks/get_lock.cc

  • Committer: Clint Byrum
  • Date: 2012-03-15 18:05:43 UTC
  • mfrom: (2224.1.302 workspace)
  • Revision ID: clint@ubuntu.com-20120315180543-9jxxm4q10k3np2ws
merging with latest trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
  }
44
44
  null_value= false;
45
45
 
46
 
  user_locks::Storable *list= static_cast<user_locks::Storable *>(getSession().getProperty("user_locks"));
 
46
  user_locks::Storable *list= getSession().getProperty<user_locks::Storable>("user_locks");
47
47
  if (list) // To be compatible with MySQL, we will now release all other locks we might have.
48
48
    list->erase_all();
49
49
 
50
 
  bool result;
51
 
  drizzled::identifier::User::const_shared_ptr user_identifier(getSession().user());
 
50
  drizzled::identifier::user::ptr user_identifier(getSession().user());
52
51
  {
53
52
    boost::this_thread::restore_interruption dl(getSession().getThreadInterupt());
54
53
 
55
 
    try {
56
 
      result= user_locks::Locks::getInstance().lock(getSession().getSessionId(), Key(*user_identifier, res->c_str()), wait_time);
 
54
    try 
 
55
    {
 
56
      if (not user_locks::Locks::getInstance().lock(getSession().getSessionId(), Key(*user_identifier, res->c_str()), wait_time))
 
57
        return 0;
57
58
    }
58
 
    catch(boost::thread_interrupted const& error)
 
59
    catch (boost::thread_interrupted const&)
59
60
    {
60
61
      my_error(drizzled::ER_QUERY_INTERRUPTED, MYF(0));
61
62
      null_value= true;
62
 
 
63
63
      return 0;
64
64
    }
65
65
  }
66
 
 
67
 
  if (result)
68
 
  {
69
 
    if (not list)
70
 
    {
71
 
      list= new user_locks::Storable(getSession().getSessionId());
72
 
      getSession().setProperty("user_locks", list);
73
 
    }
74
 
 
75
 
    list->insert(Key(*user_identifier, res->c_str()));
76
 
 
77
 
    return 1;
78
 
  }
79
 
 
80
 
  return 0;
 
66
  if (not list)
 
67
    list= getSession().setProperty("user_locks", new user_locks::Storable(getSession().getSessionId()));
 
68
  list->insert(Key(*user_identifier, res->c_str()));
 
69
  return 1;
81
70
}
82
71
 
83
72
} /* namespace user_locks */