CUBRID Engine
latest
|
#include "config.h"
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include "api_handle.h"
#include "api_util.h"
#include "error_code.h"
Go to the source code of this file.
Classes | |
struct | bh_root_s |
struct | bhifs_node_s |
struct | bh_context_fe_s |
struct | bh_context_be_s |
struct | sh_context_be_s |
Macros | |
#define | bhifs_node_init(n, h, b) |
#define | bhifs_node_prune(n) |
#define | bhifs_node_prune_and_register_root(fe, n) |
#define | RR_LOCK() API_LOCK(&rr_mutex) |
#define | RR_UNLOCK() API_UNLOCK(&rr_mutex) |
#define | MAX_NUM_ROOTS 1024 |
#define | BH_RID_BITS 16 |
#define | BH_RID_OFFSET 48 |
#define | BH_RID_MASK 0xffff000000000000ULL |
#define | BH_RID_FILTER(h) (0xffffULL & (h)) |
#define | BH_ID_BITS 48 |
#define | BH_ID_OFFSET 0 |
#define | BH_ID_MASK 0x0000ffffffffffffULL |
#define | BH_ID_FILTER(h) (0xffffffffffffULL & (h)) |
#define | BH_MAKE(rr_, id_) |
#define | BH_GET_RID(h) BH_RID_FILTER(((h)&BH_RID_MASK)>>BH_RID_OFFSET) |
#define | BH_SET_RID(h, r) h = (((r)<<BH_RID_OFFSET)&BH_RID_MASK) | ((h) & ~BH_RID_MASK) |
#define | BH_GET_ID(h) BH_ID_FILTER(((h)&BH_ID_MASK)>>BH_ID_OFFSET) |
#define | BH_SET_ID(h, r) h = (((r)<<BH_ID_OFFSET)&BH_ID_MASK) | ((h) & ~BH_ID_MASK) |
Typedefs | |
typedef struct bh_root_s | BH_ROOT |
typedef struct bhifs_node_s | BHIFS_NODE |
typedef struct bh_context_fe_s | bh_context_fe |
typedef struct bh_context_be_s | bh_context_be |
typedef struct sh_context_be_s | sh_context_be |
Variables | |
static API_MUTEX | rr_mutex = API_MUTEX_INITIALIZER |
static int | rr_initialized = 0 |
static BH_ROOT * | rr_free_list |
static BH_ROOT | Roots [MAX_NUM_ROOTS] |
static int | rr_alloc_count = 0 |
#define BH_GET_ID | ( | h | ) | BH_ID_FILTER(((h)&BH_ID_MASK)>>BH_ID_OFFSET) |
Definition at line 135 of file api_handle.c.
#define BH_GET_RID | ( | h | ) | BH_RID_FILTER(((h)&BH_RID_MASK)>>BH_RID_OFFSET) |
Definition at line 129 of file api_handle.c.
Referenced by bh_get_rid().
#define BH_ID_BITS 48 |
Definition at line 120 of file api_handle.c.
#define BH_ID_FILTER | ( | h | ) | (0xffffffffffffULL & (h)) |
Definition at line 123 of file api_handle.c.
#define BH_ID_MASK 0x0000ffffffffffffULL |
Definition at line 122 of file api_handle.c.
#define BH_ID_OFFSET 0 |
Definition at line 121 of file api_handle.c.
#define BH_MAKE | ( | rr_, | |
id_ | |||
) |
#define BH_RID_BITS 16 |
Definition at line 115 of file api_handle.c.
#define BH_RID_FILTER | ( | h | ) | (0xffffULL & (h)) |
Definition at line 118 of file api_handle.c.
#define BH_RID_MASK 0xffff000000000000ULL |
Definition at line 117 of file api_handle.c.
#define BH_RID_OFFSET 48 |
Definition at line 116 of file api_handle.c.
#define BH_SET_ID | ( | h, | |
r | |||
) | h = (((r)<<BH_ID_OFFSET)&BH_ID_MASK) | ((h) & ~BH_ID_MASK) |
Definition at line 138 of file api_handle.c.
#define BH_SET_RID | ( | h, | |
r | |||
) | h = (((r)<<BH_RID_OFFSET)&BH_RID_MASK) | ((h) & ~BH_RID_MASK) |
Definition at line 132 of file api_handle.c.
#define bhifs_node_init | ( | n, | |
h, | |||
b | |||
) |
Definition at line 59 of file api_handle.c.
Referenced by fe_alloc_handle().
#define bhifs_node_prune | ( | n | ) |
Definition at line 69 of file api_handle.c.
Referenced by fe_bind_graft(), fe_destroy(), and fe_destroy_handle_worker().
#define bhifs_node_prune_and_register_root | ( | fe, | |
n | |||
) |
Definition at line 75 of file api_handle.c.
Referenced by fe_bind_prune().
#define MAX_NUM_ROOTS 1024 |
Definition at line 109 of file api_handle.c.
Referenced by bri_alloc_root().
Definition at line 107 of file api_handle.c.
Referenced by bh_root_acquire(), bh_root_release(), and rr_lazy_init().
#define RR_UNLOCK | ( | ) | API_UNLOCK(&rr_mutex) |
Definition at line 108 of file api_handle.c.
Referenced by bh_root_acquire(), bh_root_release(), and rr_lazy_init().
typedef struct bh_context_be_s bh_context_be |
Definition at line 37 of file api_handle.c.
typedef struct bh_context_fe_s bh_context_fe |
Definition at line 36 of file api_handle.c.
Definition at line 34 of file api_handle.c.
typedef struct bhifs_node_s BHIFS_NODE |
Definition at line 35 of file api_handle.c.
typedef struct sh_context_be_s sh_context_be |
Definition at line 38 of file api_handle.c.
|
static |
Definition at line 769 of file api_handle.c.
References API_MALLOC, sh_context_be_s::be, sh_context_be_s::bucket_sz, bh_context_be_s::delete, bh_context_be_s::destroy, ER_INTERFACE_NO_MORE_MEMORY, hash_destroy(), hash_new(), sh_context_be_s::ht, bh_context_be_s::insert, bh_context_be_s::lookup, NO_ERROR, NULL, sh_comparef(), sh_delete(), sh_destroy(), sh_hashf(), sh_insert(), sh_keyf(), and sh_lookup().
Referenced by create_handle_context().
int bh_get_rid | ( | BIND_HANDLE | bh, |
int * | rid | ||
) |
Definition at line 802 of file api_handle.c.
References BH_GET_RID, ER_INTERFACE_INVALID_HANDLE, NO_ERROR, and NULL.
Referenced by ci_stmt_close().
int bh_root_acquire | ( | int * | rrid, |
BH_ROOT_TYPE | rt | ||
) |
Definition at line 817 of file api_handle.c.
References API_LOCK, API_UNLOCK, assert, bh_root_s::bhifs, bri_alloc_root(), create_handle_context(), ER_INTERFACE_INVALID_ARGUMENT, bh_root_s::free_link, bh_root_s::mutex, NO_ERROR, NULL, rr_free_list, rr_lazy_init(), RR_LOCK, RR_UNLOCK, and bh_root_s::rrid.
Referenced by ci_create_connection_impl().
int bh_root_lock | ( | int | rrid, |
BH_INTERFACE ** | bhifs | ||
) |
Definition at line 908 of file api_handle.c.
References API_TRYLOCK, API_UNLOCK, bh_root_s::bhifs, bri_access_root(), ER_INTERFACE_GENERIC, ER_INTERFACE_HANDLE_TIMEOUT, ER_INTERFACE_INVALID_HANDLE, bh_root_s::mutex, NO_ERROR, NULL, and rr_initialized.
Referenced by ci_create_connection_impl(), and ci_stmt_close().
int bh_root_release | ( | int | rrid | ) |
Definition at line 871 of file api_handle.c.
References API_LOCK, API_UNLOCK, assert, bh_root_s::bhifs, bri_access_root(), bh_interface_s::destroy, ER_INTERFACE_INVALID_HANDLE, bh_root_s::free_link, bh_root_s::mutex, NO_ERROR, NULL, rr_free_list, RR_LOCK, and RR_UNLOCK.
Referenced by ci_conn_close(), and ci_create_connection_impl().
int bh_root_unlock | ( | int | rrid | ) |
Definition at line 944 of file api_handle.c.
References API_UNLOCK, bri_access_root(), ER_INTERFACE_GENERIC, bh_root_s::mutex, NO_ERROR, and rr_initialized.
Referenced by ci_create_connection_impl(), and ci_stmt_close().
|
static |
Definition at line 279 of file api_handle.c.
References ER_INTERFACE_INVALID_HANDLE, NO_ERROR, rr_alloc_count, and bh_root_s::rrid.
Referenced by bh_root_lock(), bh_root_release(), and bh_root_unlock().
|
static |
Definition at line 260 of file api_handle.c.
References ER_INTERFACE_TOO_MANY_CONNECTION, MAX_NUM_ROOTS, NO_ERROR, rr_alloc_count, rr_init_root(), and bh_root_s::rrid.
Referenced by bh_root_acquire().
|
static |
Definition at line 248 of file api_handle.c.
References NO_ERROR.
Referenced by rr_lazy_init().
int create_handle_context | ( | bh_provider * | prov, |
BH_ROOT_TYPE | rt, | ||
BH_INTERFACE ** | bhifs | ||
) |
Definition at line 967 of file api_handle.c.
References bh_interface_s::alloc_handle, API_MALLOC, assert, bh_context_fe_s::be, be_create_static_hash(), BH_ROOT_TYPE_EXTENDIBLE_HASH, BH_ROOT_TYPE_RB_TREE, BH_ROOT_TYPE_STATIC_HASH_1024, BH_ROOT_TYPE_STATIC_HASH_128, BH_ROOT_TYPE_STATIC_HASH_64, bh_context_fe_s::bhifs, bh_interface_s::bind_get_first_child, bh_interface_s::bind_get_next_sibling, bh_interface_s::bind_get_parent, bh_interface_s::bind_graft, bh_interface_s::bind_map, bh_interface_s::bind_prune, bh_interface_s::bind_to_handle, bh_interface_s::destroy, bh_interface_s::destroy_handle, dlisth_init, ER_INTERFACE_NO_MORE_MEMORY, ER_INTERFACE_NOT_SUPPORTED_OPERATION, fe_alloc_handle(), fe_bind_get_first_child(), fe_bind_get_next_sibling(), fe_bind_get_parent(), fe_bind_graft(), fe_bind_map(), fe_bind_prune(), fe_bind_to_handle(), fe_destroy(), fe_destroy_handle(), fe_lookup(), bh_context_fe_s::handle_provider, bh_interface_s::lookup, NO_ERROR, NULL, and bh_context_fe_s::root_handles.
Referenced by bh_root_acquire().
|
static |
Definition at line 296 of file api_handle.c.
References API_FREE, API_MALLOC, assert, bh_context_fe_s::be, bhifs_node_init, dlisth_insert_after, ER_INTERFACE_NO_MORE_MEMORY, handle, bh_context_fe_s::handle_provider, bh_context_be_s::insert, bh_provider_s::next_handle, NO_ERROR, NULL, and bh_context_fe_s::root_handles.
Referenced by create_handle_context().
|
static |
Definition at line 513 of file api_handle.c.
References assert, bhifs_node_s::bind, bh_bind_s::bptr, bhifs_node_s::children, dlisth_is_empty, dlisth_s::next, NO_ERROR, and NULL.
Referenced by create_handle_context().
|
static |
Definition at line 542 of file api_handle.c.
References assert, bhifs_node_s::bind, bh_bind_s::bptr, bhifs_node_s::children, bhifs_node_s::head, dlisth_s::next, NO_ERROR, NULL, and bhifs_node_s::parent.
Referenced by create_handle_context().
|
static |
Definition at line 435 of file api_handle.c.
References assert, bhifs_node_s::bind, bh_bind_s::bptr, NO_ERROR, NULL, and bhifs_node_s::parent.
Referenced by create_handle_context().
|
static |
Definition at line 484 of file api_handle.c.
References assert, bhifs_node_prune, bh_bind_s::bptr, bhifs_node_s::children, dlisth_insert_before, NO_ERROR, NULL, and bhifs_node_s::parent.
Referenced by create_handle_context().
|
static |
Definition at line 596 of file api_handle.c.
References assert, bh_bind_s::bptr, fe_bind_map_worker(), and NULL.
Referenced by create_handle_context().
|
static |
Definition at line 572 of file api_handle.c.
References bhifs_node_s::bind, bhifs_node_s::children, dlisth_s::next, and NO_ERROR.
Referenced by fe_bind_map().
|
static |
Definition at line 460 of file api_handle.c.
References assert, bh_root_s::bhifs, bhifs_node_prune_and_register_root, bh_bind_s::bptr, NO_ERROR, and NULL.
Referenced by create_handle_context().
|
static |
Definition at line 413 of file api_handle.c.
References assert, bh_bind_s::bptr, bhifs_node_s::handle, NO_ERROR, and NULL.
Referenced by create_handle_context().
|
static |
Definition at line 612 of file api_handle.c.
References API_FREE, assert, bh_context_fe_s::be, bhifs_node_prune, bh_context_be_s::destroy, fe_destroy_handle_worker(), dlisth_s::next, NO_ERROR, NULL, and bh_context_fe_s::root_handles.
Referenced by create_handle_context().
|
static |
Definition at line 365 of file api_handle.c.
References assert, bh_context_fe_s::be, fe_destroy_handle_worker(), bh_context_be_s::lookup, NO_ERROR, and NULL.
Referenced by create_handle_context().
|
static |
Definition at line 332 of file api_handle.c.
References API_FREE, assert, bh_context_fe_s::be, bhifs_node_prune, bhifs_node_s::bind, bhifs_node_s::children, bh_context_be_s::delete, dlisth_is_empty, bh_bind_s::dtor, bhifs_node_s::handle, dlisth_s::next, NO_ERROR, and NULL.
Referenced by fe_destroy(), and fe_destroy_handle().
|
static |
Definition at line 388 of file api_handle.c.
References assert, bh_context_fe_s::be, bhifs_node_s::bind, bh_context_be_s::lookup, NO_ERROR, and NULL.
Referenced by create_handle_context().
|
static |
Definition at line 233 of file api_handle.c.
References API_MUTEX_INIT, bh_root_s::bhifs, bh_root_s::free_link, i, bh_root_s::mutex, bh_provider_s::next_handle, NULL, bh_root_s::provider, rr_next_handle(), bh_root_s::rrid, and bh_root_s::rrv.
Referenced by bri_alloc_root().
|
static |
Definition at line 202 of file api_handle.c.
References bri_init_root(), NO_ERROR, NULL, rr_initialized, RR_LOCK, and RR_UNLOCK.
Referenced by bh_root_acquire().
|
static |
Definition at line 186 of file api_handle.c.
References assert, BH_MAKE, NO_ERROR, NULL, bh_root_s::rrid, and bh_root_s::rrv.
Referenced by rr_init_root().
|
static |
Definition at line 645 of file api_handle.c.
References assert, NO_ERROR, and NULL.
Referenced by be_create_static_hash().
|
static |
Definition at line 754 of file api_handle.c.
References assert, hash_delete(), sh_context_be_s::ht, and NULL.
Referenced by be_create_static_hash().
|
static |
Definition at line 703 of file api_handle.c.
References API_FREE, assert, hash_destroy(), sh_context_be_s::ht, and NULL.
Referenced by be_create_static_hash().
|
static |
Definition at line 666 of file api_handle.c.
References assert, NO_ERROR, NULL, and p.
Referenced by be_create_static_hash().
|
static |
Definition at line 737 of file api_handle.c.
References assert, hash_insert(), sh_context_be_s::ht, and NULL.
Referenced by be_create_static_hash().
|
static |
Definition at line 685 of file api_handle.c.
References assert, bhifs_node_s::handle, NO_ERROR, and NULL.
Referenced by be_create_static_hash().
|
static |
Definition at line 722 of file api_handle.c.
References assert, hash_lookup(), sh_context_be_s::ht, and NULL.
Referenced by be_create_static_hash().
|
static |
Definition at line 176 of file api_handle.c.
|
static |
Definition at line 177 of file api_handle.c.
Referenced by bri_access_root(), and bri_alloc_root().
|
static |
Definition at line 175 of file api_handle.c.
Referenced by bh_root_acquire(), and bh_root_release().
|
static |
Definition at line 174 of file api_handle.c.
Referenced by bh_root_lock(), bh_root_unlock(), and rr_lazy_init().
|
static |
Definition at line 173 of file api_handle.c.