~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

MergedĀ inĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/******************************************************
2
 
Sessions
3
 
 
4
 
(c) 1996 Innobase Oy
5
 
 
6
 
Created 6/25/1996 Heikki Tuuri
7
 
*******************************************************/
8
 
 
9
 
#include "usr0sess.h"
10
 
 
11
 
#ifdef UNIV_NONINL
12
 
#include "usr0sess.ic"
13
 
#endif
14
 
 
15
 
#include "trx0trx.h"
16
 
 
17
 
/*************************************************************************
18
 
Closes a session, freeing the memory occupied by it. */
19
 
static
20
 
void
21
 
sess_close(
22
 
/*=======*/
23
 
        sess_t*         sess);  /* in, own: session object */
24
 
 
25
 
/*************************************************************************
26
 
Opens a session. */
27
 
 
28
 
sess_t*
29
 
sess_open(void)
30
 
/*===========*/
31
 
                                        /* out, own: session object */
32
 
{
33
 
        sess_t* sess;
34
 
 
35
 
        ut_ad(mutex_own(&kernel_mutex));
36
 
 
37
 
        sess = mem_alloc(sizeof(sess_t));
38
 
 
39
 
        sess->state = SESS_ACTIVE;
40
 
 
41
 
        sess->trx = trx_create(sess);
42
 
 
43
 
        UT_LIST_INIT(sess->graphs);
44
 
 
45
 
        return(sess);
46
 
}
47
 
 
48
 
/*************************************************************************
49
 
Closes a session, freeing the memory occupied by it. */
50
 
static
51
 
void
52
 
sess_close(
53
 
/*=======*/
54
 
        sess_t* sess)   /* in, own: session object */
55
 
{
56
 
        ut_ad(mutex_own(&kernel_mutex));
57
 
        ut_ad(sess->trx == NULL);
58
 
 
59
 
        mem_free(sess);
60
 
}
61
 
 
62
 
/*************************************************************************
63
 
Closes a session, freeing the memory occupied by it, if it is in a state
64
 
where it should be closed. */
65
 
 
66
 
ibool
67
 
sess_try_close(
68
 
/*===========*/
69
 
                        /* out: TRUE if closed */
70
 
        sess_t* sess)   /* in, own: session object */
71
 
{
72
 
        ut_ad(mutex_own(&kernel_mutex));
73
 
 
74
 
        if (UT_LIST_GET_LEN(sess->graphs) == 0) {
75
 
                sess_close(sess);
76
 
 
77
 
                return(TRUE);
78
 
        }
79
 
 
80
 
        return(FALSE);
81
 
}