~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/user_locks/get_lock.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

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 */