mariadb/usr/usr0sess.c
marko 2c2b06ad75 branches/zip: Introduce UNIV_INTERN, a linkage specifier for InnoDB-global
symbols.  Use it for all definitions of non-static variables and functions.

lexyy.c, make_flex.sh: Declare yylex as UNIV_INTERN, not static.  It is
referenced from pars0grm.c.

Actually, according to
	nm .libs/ha_innodb.so|grep -w '[ABCE-TVXYZ]'
the following symbols are still global:

* The vtable for class ha_innodb
* pars0grm.c: The function yyparse() and the variables yychar, yylval, yynerrs

The required changes to the Bison-generated file pars0grm.c will be addressed
in a separate commit, which will add a script similar to make_flex.sh.

The class ha_innodb is renamed from class ha_innobase by a #define.  Thus,
there will be no clash with the builtin InnoDB.  However, there will be some
overhead for invoking virtual methods of class ha_innodb.  Ideas for making
the vtable hidden are welcome.  -fvisibility=hidden is not available in GCC 3.
2008-02-06 14:17:36 +00:00

81 lines
1.6 KiB
C

/******************************************************
Sessions
(c) 1996 Innobase Oy
Created 6/25/1996 Heikki Tuuri
*******************************************************/
#include "usr0sess.h"
#ifdef UNIV_NONINL
#include "usr0sess.ic"
#endif
#include "trx0trx.h"
/*************************************************************************
Closes a session, freeing the memory occupied by it. */
static
void
sess_close(
/*=======*/
sess_t* sess); /* in, own: session object */
/*************************************************************************
Opens a session. */
UNIV_INTERN
sess_t*
sess_open(void)
/*===========*/
/* out, own: session object */
{
sess_t* sess;
ut_ad(mutex_own(&kernel_mutex));
sess = mem_alloc(sizeof(sess_t));
sess->state = SESS_ACTIVE;
sess->trx = trx_create(sess);
UT_LIST_INIT(sess->graphs);
return(sess);
}
/*************************************************************************
Closes a session, freeing the memory occupied by it. */
static
void
sess_close(
/*=======*/
sess_t* sess) /* in, own: session object */
{
ut_ad(mutex_own(&kernel_mutex));
ut_ad(sess->trx == NULL);
mem_free(sess);
}
/*************************************************************************
Closes a session, freeing the memory occupied by it, if it is in a state
where it should be closed. */
UNIV_INTERN
ibool
sess_try_close(
/*===========*/
/* out: TRUE if closed */
sess_t* sess) /* in, own: session object */
{
ut_ad(mutex_own(&kernel_mutex));
if (UT_LIST_GET_LEN(sess->graphs) == 0) {
sess_close(sess);
return(TRUE);
}
return(FALSE);
}