~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

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
@file usr/usr0sess.c
 
21
Sessions
 
22
 
 
23
Created 6/25/1996 Heikki Tuuri
 
24
*******************************************************/
 
25
 
 
26
#include "usr0sess.h"
 
27
 
 
28
#ifdef UNIV_NONINL
 
29
#include "usr0sess.ic"
 
30
#endif
 
31
 
 
32
#include "trx0trx.h"
 
33
 
 
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
/*********************************************************************//**
 
43
Opens a session.
 
44
@return own: session object */
 
45
UNIV_INTERN
 
46
sess_t*
 
47
sess_open(void)
 
48
/*===========*/
 
49
{
 
50
        sess_t* sess;
 
51
 
 
52
        ut_ad(mutex_own(&kernel_mutex));
 
53
 
 
54
        sess = mem_alloc(sizeof(sess_t));
 
55
 
 
56
        sess->state = SESS_ACTIVE;
 
57
 
 
58
        sess->trx = trx_create(sess);
 
59
 
 
60
        UT_LIST_INIT(sess->graphs);
 
61
 
 
62
        return(sess);
 
63
}
 
64
 
 
65
/*********************************************************************//**
 
66
Closes a session, freeing the memory occupied by it. */
 
67
static
 
68
void
 
69
sess_close(
 
70
/*=======*/
 
71
        sess_t* sess)   /*!< in, own: session object */
 
72
{
 
73
        ut_ad(mutex_own(&kernel_mutex));
 
74
        ut_ad(sess->trx == NULL);
 
75
 
 
76
        mem_free(sess);
 
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
}