~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/usr/usr0sess.c

  • Committer: Brian Aker
  • Date: 2010-10-13 02:49:48 UTC
  • mto: This revision was merged to the branch mainline in revision 1853.
  • Revision ID: brian@tangent.org-20101013024948-xwel5qe6z7j21w73
Cleans up namespace for locks (now per user).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
32
32
#include "trx0trx.h"
33
33
 
34
34
/*********************************************************************//**
 
35
Closes a session, freeing the memory occupied by it. */
 
36
static
 
37
void
 
38
sess_close(
 
39
/*=======*/
 
40
        sess_t*         sess);  /*!< in, own: session object */
 
41
 
 
42
/*********************************************************************//**
35
43
Opens a session.
36
44
@return own: session object */
37
45
UNIV_INTERN
43
51
 
44
52
        ut_ad(mutex_own(&kernel_mutex));
45
53
 
46
 
        sess = static_cast<sess_t *>(mem_alloc(sizeof(sess_t)));
 
54
        sess = mem_alloc(sizeof(sess_t));
47
55
 
48
56
        sess->state = SESS_ACTIVE;
49
57
 
56
64
 
57
65
/*********************************************************************//**
58
66
Closes a session, freeing the memory occupied by it. */
59
 
UNIV_INTERN
 
67
static
60
68
void
61
69
sess_close(
62
70
/*=======*/
63
71
        sess_t* sess)   /*!< in, own: session object */
64
72
{
65
 
        ut_ad(!mutex_own(&kernel_mutex));
66
 
 
67
 
        ut_a(UT_LIST_GET_LEN(sess->graphs) == 0);
68
 
 
69
 
        trx_free_for_background(sess->trx);
 
73
        ut_ad(mutex_own(&kernel_mutex));
 
74
        ut_ad(sess->trx == NULL);
 
75
 
70
76
        mem_free(sess);
71
77
}
 
78
 
 
79
/*********************************************************************//**
 
80
Closes a session, freeing the memory occupied by it, if it is in a state
 
81
where it should be closed.
 
82
@return TRUE if closed */
 
83
UNIV_INTERN
 
84
ibool
 
85
sess_try_close(
 
86
/*===========*/
 
87
        sess_t* sess)   /*!< in, own: session object */
 
88
{
 
89
        ut_ad(mutex_own(&kernel_mutex));
 
90
 
 
91
        if (UT_LIST_GET_LEN(sess->graphs) == 0) {
 
92
                sess_close(sess);
 
93
 
 
94
                return(TRUE);
 
95
        }
 
96
 
 
97
        return(FALSE);
 
98
}