~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-03-25 21:06:47 UTC
  • mto: This revision was merged to the branch mainline in revision 964.
  • Revision ID: mordred@inaugust.com-20090325210647-7j1tm98gvct3jxsu
Removed legacy_db_type.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
 
4
 
 
5
This program is free software; you can redistribute it and/or modify it under
 
6
the terms of the GNU General Public License as published by the Free Software
 
7
Foundation; version 2 of the License.
 
8
 
 
9
This program is distributed in the hope that it will be useful, but WITHOUT
 
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
12
 
 
13
You should have received a copy of the GNU General Public License along with
 
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
/******************************************************
 
20
Sessions
 
21
 
 
22
Created 6/25/1996 Heikki Tuuri
 
23
*******************************************************/
 
24
 
 
25
#include "usr0sess.h"
 
26
 
 
27
#ifdef UNIV_NONINL
 
28
#include "usr0sess.ic"
 
29
#endif
 
30
 
 
31
#include "trx0trx.h"
 
32
 
 
33
/*************************************************************************
 
34
Closes a session, freeing the memory occupied by it. */
 
35
static
 
36
void
 
37
sess_close(
 
38
/*=======*/
 
39
        sess_t*         sess);  /* in, own: session object */
 
40
 
 
41
/*************************************************************************
 
42
Opens a session. */
 
43
UNIV_INTERN
 
44
sess_t*
 
45
sess_open(void)
 
46
/*===========*/
 
47
                                        /* out, own: session object */
 
48
{
 
49
        sess_t* sess;
 
50
 
 
51
        ut_ad(mutex_own(&kernel_mutex));
 
52
 
 
53
        sess = mem_alloc(sizeof(sess_t));
 
54
 
 
55
        sess->state = SESS_ACTIVE;
 
56
 
 
57
        sess->trx = trx_create(sess);
 
58
 
 
59
        UT_LIST_INIT(sess->graphs);
 
60
 
 
61
        return(sess);
 
62
}
 
63
 
 
64
/*************************************************************************
 
65
Closes a session, freeing the memory occupied by it. */
 
66
static
 
67
void
 
68
sess_close(
 
69
/*=======*/
 
70
        sess_t* sess)   /* in, own: session object */
 
71
{
 
72
        ut_ad(mutex_own(&kernel_mutex));
 
73
        ut_ad(sess->trx == NULL);
 
74
 
 
75
        mem_free(sess);
 
76
}
 
77
 
 
78
/*************************************************************************
 
79
Closes a session, freeing the memory occupied by it, if it is in a state
 
80
where it should be closed. */
 
81
UNIV_INTERN
 
82
ibool
 
83
sess_try_close(
 
84
/*===========*/
 
85
                        /* out: TRUE if closed */
 
86
        sess_t* sess)   /* in, own: session object */
 
87
{
 
88
        ut_ad(mutex_own(&kernel_mutex));
 
89
 
 
90
        if (UT_LIST_GET_LEN(sess->graphs) == 0) {
 
91
                sess_close(sess);
 
92
 
 
93
                return(TRUE);
 
94
        }
 
95
 
 
96
        return(FALSE);
 
97
}