~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/user_locks/release_lock.cc

  • Committer: Stewart Smith
  • Date: 2010-11-03 03:28:23 UTC
  • mto: (1902.1.1 build) (1910.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1903.
  • Revision ID: stewart@flamingspork.com-20101103032823-44k21f0njmk97omr
fix docs warning: Title underline (and overline) is too short in brief_history_of_drizzle.rst

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
{
31
31
  drizzled::String *res= args[0]->val_str(&value);
32
32
 
33
 
  if (not res || not res->length())
 
33
  if (not res)
34
34
  {
35
 
    my_error(drizzled::ER_USER_LOCKS_INVALID_NAME_LOCK, MYF(0));
 
35
    null_value= true;
36
36
    return 0;
37
37
  }
38
38
  null_value= false;
39
39
 
40
 
  drizzled::identifier::User::const_shared_ptr user_identifier(getSession().user());
 
40
  if (not res->length())
 
41
    return 0;
 
42
 
41
43
  drizzled::session_id_t id= getSession().getSessionId();
42
 
  locks::return_t result;
43
 
  {
44
 
    boost::this_thread::restore_interruption dl(getSession().getThreadInterupt());
45
 
    try {
46
 
      result= user_locks::Locks::getInstance().release(Key(*user_identifier, res->c_str()), id);
47
 
    }
48
 
    catch(boost::thread_interrupted const& error)
49
 
    {
50
 
      my_error(drizzled::ER_QUERY_INTERRUPTED, MYF(0));
51
 
      return 0;
52
 
    }
53
 
  }
54
 
 
55
 
  switch (result)
56
 
  {
57
 
  default:
58
 
  case locks::SUCCESS:
59
 
    {
60
 
      user_locks::Storable *list= static_cast<user_locks::Storable *>(getSession().getProperty("user_locks"));
61
 
      assert(list);
62
 
      if (list) // Just in case we ever blow the assert
63
 
        list->erase(Key(*user_identifier, res->c_str()));
64
 
 
65
 
      return 1;
66
 
    }
67
 
  case locks::NOT_FOUND:
68
 
    null_value= true;
69
 
    return 0;
70
 
  case locks::NOT_OWNED_BY:
71
 
    my_error(drizzled::ER_USER_LOCKS_NOT_OWNER_OF_LOCK, MYF(0));
72
 
    return 0;
73
 
  }
 
44
  boost::tribool result= user_locks::Locks::getInstance().release(Key(getSession().getSecurityContext(), res->c_str()), id);
 
45
 
 
46
  if (result)
 
47
  {
 
48
    user_locks::Storable *list= static_cast<user_locks::Storable *>(getSession().getProperty("user_locks"));
 
49
    assert(list);
 
50
    if (list) // Just in case we ever blow the assert
 
51
      list->erase(Key(getSession().getSecurityContext(), res->c_str()));
 
52
 
 
53
    return 1;
 
54
  }
 
55
  else if (not result)
 
56
  {
 
57
    return 0;
 
58
  }
 
59
 
 
60
  null_value= true;
 
61
 
 
62
  return 0;
74
63
}
75
64
 
76
65
} /* namespace user_locks */