Drizzled Public API Documentation

usr0sess.cc

00001 /*****************************************************************************
00002 
00003 Copyright (C) 1996, 2009, Innobase Oy. All Rights Reserved.
00004 
00005 This program is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; version 2 of the License.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT
00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with
00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
00015 St, Fifth Floor, Boston, MA 02110-1301 USA
00016 
00017 *****************************************************************************/
00018 
00019 /**************************************************/
00026 #include "usr0sess.h"
00027 
00028 #ifdef UNIV_NONINL
00029 #include "usr0sess.ic"
00030 #endif
00031 
00032 #include "trx0trx.h"
00033 
00034 /*********************************************************************/
00037 UNIV_INTERN
00038 sess_t*
00039 sess_open(void)
00040 /*===========*/
00041 {
00042   sess_t* sess;
00043 
00044   ut_ad(mutex_own(&kernel_mutex));
00045 
00046   sess = static_cast<sess_t *>(mem_alloc(sizeof(sess_t)));
00047 
00048   sess->state = SESS_ACTIVE;
00049 
00050   sess->trx = trx_create(sess);
00051 
00052   UT_LIST_INIT(sess->graphs);
00053 
00054   return(sess);
00055 }
00056 
00057 /*********************************************************************/
00059 UNIV_INTERN
00060 void
00061 sess_close(
00062 /*=======*/
00063   sess_t* sess) 
00064 {
00065   ut_ad(!mutex_own(&kernel_mutex));
00066 
00067   ut_a(UT_LIST_GET_LEN(sess->graphs) == 0);
00068 
00069   trx_free_for_background(sess->trx);
00070   mem_free(sess);
00071 }