~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/user_locks/get_locks.cc

  • Committer: Olaf van der Spek
  • Date: 2011-04-20 09:27:49 UTC
  • mto: This revision was merged to the branch mainline in revision 2285.
  • Revision ID: olafvdspek@gmail.com-20110420092749-hw1q9rfj1pumc2no
Session Cache

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
22
 
#include "plugin/user_locks/module.h"
23
 
#include "plugin/user_locks/lock_storage.h"
 
21
#include <config.h>
 
22
#include <plugin/user_locks/module.h>
 
23
#include <plugin/user_locks/lock_storage.h>
24
24
 
25
25
#include <string>
26
26
 
36
36
 
37
37
    if (res && res->length())
38
38
    {
39
 
      list_of_locks.insert(Key(getSession().getSecurityContext(), res->c_str()));
 
39
      list_of_locks.insert(Key(*getSession().user(), res->c_str()));
40
40
    }
41
41
    else
42
42
    {
44
44
      return 0;
45
45
    }
46
46
  }
47
 
 
48
 
  boost::tribool result;
49
47
  {
50
48
    boost::this_thread::restore_interruption dl(getSession().getThreadInterupt());
51
 
 
52
 
    try {
53
 
      result= user_locks::Locks::getInstance().lock(getSession().getSessionId(), list_of_locks);
 
49
    try 
 
50
    {
 
51
      if (not user_locks::Locks::getInstance().lock(getSession().getSessionId(), list_of_locks))
 
52
        return 0;
54
53
    }
55
 
    catch(boost::thread_interrupted const& error)
 
54
    catch (boost::thread_interrupted const&)
56
55
    {
57
56
      my_error(drizzled::ER_QUERY_INTERRUPTED, MYF(0));
58
57
      null_value= true;
59
 
 
60
58
      return 0;
61
59
    }
62
60
  }
63
61
 
64
 
  if (boost::indeterminate(result))
65
 
    null_value= true;
66
 
 
67
 
  if (result)
68
 
  {
69
 
    user_locks::Storable *list= static_cast<user_locks::Storable *>(getSession().getProperty("user_locks"));
70
 
    if (not list)
71
 
    {
72
 
      list= new user_locks::Storable(getSession().getSessionId());
73
 
      getSession().setProperty("user_locks", list);
74
 
    }
75
 
 
76
 
    for (Keys::iterator iter= list_of_locks.begin();
77
 
         iter != list_of_locks.end(); iter++)
78
 
    {
79
 
      list->insert(*iter);
80
 
    }
81
 
 
82
 
    null_value= false;
83
 
 
84
 
    return 1;
85
 
  }
86
 
 
87
 
  return 0;
 
62
  user_locks::Storable *list= getSession().getProperty<user_locks::Storable>("user_locks");
 
63
  if (not list)
 
64
    list= getSession().setProperty("user_locks", new user_locks::Storable(getSession().getSessionId()));
 
65
  BOOST_FOREACH(Keys::const_reference iter, list_of_locks)
 
66
    list->insert(iter);
 
67
  null_value= false;
 
68
  return 1;
88
69
}
89
70
 
90
71
} /* namespace user_locks */