~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/user_locks/create_barrier.cc

  • Committer: Andrew Hutchings
  • Date: 2011-02-01 10:23:22 UTC
  • mto: (2136.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2137.
  • Revision ID: andrew@linuxjedi.co.uk-20110201102322-oxztcyrjzg3c7yta
Fix counters cleanup

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/barrier_storage.h>
 
21
#include "config.h"
 
22
#include "plugin/user_locks/module.h"
 
23
#include "plugin/user_locks/barrier_storage.h"
24
24
 
25
25
#include <string>
26
26
 
38
38
  }
39
39
  null_value= false;
40
40
 
41
 
  drizzled::identifier::user::ptr user_identifier(getSession().user());
42
 
  bool result= arg_count == 2
43
 
    ? Barriers::getInstance().create(Key(*user_identifier, res->c_str()), getSession().getSessionId(), args[1]->val_int())
44
 
    : Barriers::getInstance().create(Key(*user_identifier, res->c_str()), getSession().getSessionId());
45
 
  if (not result)
46
 
    return 0;
47
 
  barriers::Storable *list= getSession().getProperty<barriers::Storable>(barriers::property_key);
48
 
  if (not list)
49
 
    list= getSession().setProperty(barriers::property_key, new barriers::Storable(getSession().getSessionId()));
50
 
  list->insert(Key(*user_identifier, res->c_str()));
51
 
  return 1;
 
41
  barriers::Storable *list= static_cast<barriers::Storable *>(getSession().getProperty(barriers::property_key));
 
42
 
 
43
  bool result;
 
44
 
 
45
  drizzled::identifier::User::const_shared_ptr user_identifier(getSession().user());
 
46
  if (arg_count == 2)
 
47
  {
 
48
    int64_t wait_for;
 
49
    wait_for= args[1]->val_int();
 
50
 
 
51
    result= Barriers::getInstance().create(Key(*user_identifier, res->c_str()), getSession().getSessionId(), wait_for);
 
52
  }
 
53
  else
 
54
  {
 
55
    result= Barriers::getInstance().create(Key(*user_identifier, res->c_str()), getSession().getSessionId());
 
56
  }
 
57
 
 
58
 
 
59
  if (result)
 
60
  {
 
61
    if (not list)
 
62
    {
 
63
      list= new barriers::Storable(getSession().getSessionId());
 
64
      getSession().setProperty(barriers::property_key, list);
 
65
    }
 
66
 
 
67
    list->insert(Key(*user_identifier, res->c_str()));
 
68
 
 
69
    return 1;
 
70
  }
 
71
 
 
72
  return 0;
52
73
}
53
74
 
54
75
} /* namespace barriers */