22
22
#pragma warning(disable : 4702)
23
23
#endif
24
24
25
- struct ipc_handle_cache_entry_t ;
25
+ struct ipc_opened_cache_entry_t ;
26
26
27
- typedef struct ipc_handle_cache_entry_t * hash_map_t ;
28
- typedef struct ipc_handle_cache_entry_t * lru_list_t ;
27
+ typedef struct ipc_opened_cache_entry_t * hash_map_t ;
28
+ typedef struct ipc_opened_cache_entry_t * lru_list_t ;
29
29
30
- typedef struct ipc_handle_cache_entry_t {
30
+ typedef struct ipc_opened_cache_entry_t {
31
31
UT_hash_handle hh ;
32
- struct ipc_handle_cache_entry_t * next , * prev ;
33
- ipc_mapped_handle_cache_key_t key ;
32
+ struct ipc_opened_cache_entry_t * next , * prev ;
33
+ ipc_opened_cache_key_t key ;
34
34
uint64_t ref_count ;
35
35
uint64_t handle_id ;
36
36
hash_map_t
37
37
* hash_table ; // pointer to the hash table to which the entry belongs
38
- ipc_mapped_handle_cache_value_t value ;
39
- } ipc_handle_cache_entry_t ;
38
+ ipc_opened_cache_value_t value ;
39
+ } ipc_opened_cache_entry_t ;
40
40
41
- typedef struct ipc_mapped_handle_cache_global_t {
41
+ typedef struct ipc_opened_cache_global_t {
42
42
utils_mutex_t cache_lock ;
43
43
umf_ba_pool_t * cache_allocator ;
44
44
size_t max_size ;
45
45
size_t cur_size ;
46
46
lru_list_t lru_list ;
47
- } ipc_mapped_handle_cache_global_t ;
47
+ } ipc_opened_cache_global_t ;
48
48
49
- typedef struct ipc_mapped_handle_cache_t {
50
- ipc_mapped_handle_cache_global_t * global ;
49
+ typedef struct ipc_opened_cache_t {
50
+ ipc_opened_cache_global_t * global ;
51
51
hash_map_t hash_table ;
52
- ipc_mapped_handle_cache_eviction_cb_t eviction_cb ;
53
- } ipc_mapped_handle_cache_t ;
52
+ ipc_opened_cache_eviction_cb_t eviction_cb ;
53
+ } ipc_opened_cache_t ;
54
54
55
- ipc_mapped_handle_cache_global_t * IPC_MAPPED_CACHE_GLOBAL = NULL ;
55
+ ipc_opened_cache_global_t * IPC_OPENED_CACHE_GLOBAL = NULL ;
56
56
57
57
umf_result_t umfIpcCacheGlobalInit (void ) {
58
58
umf_result_t ret = UMF_RESULT_SUCCESS ;
59
- ipc_mapped_handle_cache_global_t * cache_global =
59
+ ipc_opened_cache_global_t * cache_global =
60
60
umf_ba_global_alloc (sizeof (* cache_global ));
61
61
if (!cache_global ) {
62
62
LOG_ERR ("Failed to allocate memory for the IPC cache global data" );
@@ -71,7 +71,7 @@ umf_result_t umfIpcCacheGlobalInit(void) {
71
71
}
72
72
73
73
cache_global -> cache_allocator =
74
- umf_ba_create (sizeof (ipc_handle_cache_entry_t ));
74
+ umf_ba_create (sizeof (ipc_opened_cache_entry_t ));
75
75
if (!cache_global -> cache_allocator ) {
76
76
LOG_ERR ("Failed to create IPC cache allocator" );
77
77
ret = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY ;
@@ -83,7 +83,7 @@ umf_result_t umfIpcCacheGlobalInit(void) {
83
83
cache_global -> cur_size = 0 ;
84
84
cache_global -> lru_list = NULL ;
85
85
86
- IPC_MAPPED_CACHE_GLOBAL = cache_global ;
86
+ IPC_OPENED_CACHE_GLOBAL = cache_global ;
87
87
goto err_exit ;
88
88
89
89
err_mutex_destroy :
@@ -97,15 +97,15 @@ umf_result_t umfIpcCacheGlobalInit(void) {
97
97
#ifndef NDEBUG
98
98
static size_t getGlobalLruListSize (lru_list_t lru_list ) {
99
99
size_t size = 0 ;
100
- ipc_handle_cache_entry_t * tmp ;
100
+ ipc_opened_cache_entry_t * tmp ;
101
101
DL_COUNT (lru_list , tmp , size );
102
102
return size ;
103
103
}
104
104
#endif /* NDEBUG */
105
105
106
106
void umfIpcCacheGlobalTearDown (void ) {
107
- ipc_mapped_handle_cache_global_t * cache_global = IPC_MAPPED_CACHE_GLOBAL ;
108
- IPC_MAPPED_CACHE_GLOBAL = NULL ;
107
+ ipc_opened_cache_global_t * cache_global = IPC_OPENED_CACHE_GLOBAL ;
108
+ IPC_OPENED_CACHE_GLOBAL = NULL ;
109
109
110
110
if (!cache_global ) {
111
111
return ;
@@ -119,31 +119,31 @@ void umfIpcCacheGlobalTearDown(void) {
119
119
umf_ba_global_free (cache_global );
120
120
}
121
121
122
- ipc_mapped_handle_cache_handle_t umfIpcHandleMappedCacheCreate (
123
- ipc_mapped_handle_cache_eviction_cb_t eviction_cb ) {
122
+ ipc_opened_cache_handle_t
123
+ umfIpcOpenedCacheCreate ( ipc_opened_cache_eviction_cb_t eviction_cb ) {
124
124
if (eviction_cb == NULL ) {
125
125
LOG_ERR ("Eviction callback is NULL" );
126
126
return NULL ;
127
127
}
128
128
129
- ipc_mapped_handle_cache_t * cache = umf_ba_global_alloc (sizeof (* cache ));
129
+ ipc_opened_cache_t * cache = umf_ba_global_alloc (sizeof (* cache ));
130
130
131
131
if (!cache ) {
132
132
LOG_ERR ("Failed to allocate memory for the IPC cache" );
133
133
return NULL ;
134
134
}
135
135
136
- assert (IPC_MAPPED_CACHE_GLOBAL != NULL );
136
+ assert (IPC_OPENED_CACHE_GLOBAL != NULL );
137
137
138
- cache -> global = IPC_MAPPED_CACHE_GLOBAL ;
138
+ cache -> global = IPC_OPENED_CACHE_GLOBAL ;
139
139
cache -> hash_table = NULL ;
140
140
cache -> eviction_cb = eviction_cb ;
141
141
142
142
return cache ;
143
143
}
144
144
145
- void umfIpcHandleMappedCacheDestroy ( ipc_mapped_handle_cache_handle_t cache ) {
146
- ipc_handle_cache_entry_t * entry , * tmp ;
145
+ void umfIpcOpenedCacheDestroy ( ipc_opened_cache_handle_t cache ) {
146
+ ipc_opened_cache_entry_t * entry , * tmp ;
147
147
HASH_ITER (hh , cache -> hash_table , entry , tmp ) {
148
148
DL_DELETE (cache -> global -> lru_list , entry );
149
149
HASH_DEL (cache -> hash_table , entry );
@@ -157,15 +157,14 @@ void umfIpcHandleMappedCacheDestroy(ipc_mapped_handle_cache_handle_t cache) {
157
157
umf_ba_global_free (cache );
158
158
}
159
159
160
- umf_result_t
161
- umfIpcHandleMappedCacheGet (ipc_mapped_handle_cache_handle_t cache ,
162
- const ipc_mapped_handle_cache_key_t * key ,
163
- uint64_t handle_id ,
164
- ipc_mapped_handle_cache_value_t * * retEntry ) {
165
- ipc_handle_cache_entry_t * entry = NULL ;
160
+ umf_result_t umfIpcOpenedCacheGet (ipc_opened_cache_handle_t cache ,
161
+ const ipc_opened_cache_key_t * key ,
162
+ uint64_t handle_id ,
163
+ ipc_opened_cache_value_t * * retEntry ) {
164
+ ipc_opened_cache_entry_t * entry = NULL ;
166
165
umf_result_t ret = UMF_RESULT_SUCCESS ;
167
166
bool evicted = false;
168
- ipc_mapped_handle_cache_value_t evicted_value ;
167
+ ipc_opened_cache_value_t evicted_value ;
169
168
170
169
if (!cache || !key || !retEntry ) {
171
170
LOG_ERR ("Some arguments are NULL, cache=%p, key=%p, retEntry=%p" ,
0 commit comments