~stewart/haildb/trunk

« back to all changes in this revision

Viewing changes to usr/usr0sess.c

  • Committer: Stewart Smith
  • Date: 2010-04-09 07:57:43 UTC
  • Revision ID: stewart@flamingspork.com-20100409075743-jfh1oml3el1uouvh
Embedded InnoDB 1.0.0 released

2009-04-21      The InnoDB Team

        Embedded InnoDB 1.0.0 released

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
Opens a session. */
 
35
UNIV_INTERN
 
36
sess_t*
 
37
sess_open(void)
 
38
/*===========*/
 
39
                                        /* out, own: session object */
 
40
{
 
41
        sess_t* sess;
 
42
 
 
43
        ut_ad(mutex_own(&kernel_mutex));
 
44
 
 
45
        sess = mem_alloc(sizeof(sess_t));
 
46
 
 
47
        sess->state = SESS_ACTIVE;
 
48
 
 
49
        sess->trx = trx_create(sess);
 
50
 
 
51
        UT_LIST_INIT(sess->graphs);
 
52
 
 
53
        return(sess);
 
54
}
 
55
 
 
56
/*************************************************************************
 
57
Closes a session, freeing the memory occupied by it. */
 
58
UNIV_INTERN
 
59
void
 
60
sess_close(
 
61
/*=======*/
 
62
        sess_t* sess)   /* in, own: session object */
 
63
{
 
64
        ut_ad(!mutex_own(&kernel_mutex));
 
65
 
 
66
        ut_a(UT_LIST_GET_LEN(sess->graphs) == 0);
 
67
 
 
68
        trx_free_for_background(sess->trx);
 
69
        mem_free(sess);
 
70
}