1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2018, Oracle and/or its affiliates. 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, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
24 
25 *****************************************************************************/
26 
27 /** @file usr/usr0sess.cc
28  Sessions
29 
30  Created 6/25/1996 Heikki Tuuri
31  *******************************************************/
32 
33 #include "usr0sess.h"
34 #include "trx0trx.h"
35 
36 /** Opens a session.
37  @return own: session object */
sess_open(void)38 sess_t *sess_open(void) {
39   sess_t *sess;
40 
41   sess = static_cast<sess_t *>(ut_zalloc_nokey(sizeof(*sess)));
42 
43   sess->state = SESS_ACTIVE;
44 
45   sess->trx = trx_allocate_for_background();
46   sess->trx->sess = sess;
47 
48   return (sess);
49 }
50 
51 /** Closes a session, freeing the memory occupied by it. */
sess_close(sess_t * sess)52 void sess_close(sess_t *sess) /*!< in, own: session object */
53 {
54   trx_free_for_background(sess->trx);
55   ut_free(sess);
56 }
57