You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.5 KiB

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