29 unsigned char *
buf = *
p;
30 unsigned char *pointers0 =
buf +
size;
33 unsigned char **pointers = &pointers0;
34 int generatePtrDesc = 1;
50 const int SHMEM_TO_MAX_HASHTABLE_SIZE_RATIO{40};
55 ecopy->appRuleSet =
NULL;
57 ecopy->extRuleSet =
NULL;
61 ecopy->appFuncDescIndex =
NULL;
63 ecopy->extFuncDescIndex =
NULL;
65 ecopy->dataSize = ( *
p -
buf );
67 ecopy->pointers = pointers0;
68 ecopy->cacheSize =
size;
70 ecopy->appRegion =
NULL;
72 ecopy->coreRegion =
NULL;
74 ecopy->extRegion =
NULL;
76 ecopy->sysRegion =
NULL;
78 ecopy->sysFuncDescIndex =
NULL;
102 unsigned char *bufCopy;
103 unsigned char *pointers;
105 unsigned char *bufMapped;
107 unsigned char *pointersCopy;
108 unsigned char *pointersMapped;
111 bufCopy = (
unsigned char * )malloc( dataSize );
112 if ( bufCopy ==
NULL ) {
113 rodsLog(
LOG_ERROR,
"Cannot allocate object buffer of size %lld" , dataSize);
119 pointersMapped = cacheCopy->
pointers;
120 bufMapped = cacheCopy->
address;
121 pointersSize = bufMapped +
SHMMAX - pointersMapped;
122 pointersCopy = (
unsigned char * )malloc( pointersSize );
123 if ( pointersCopy ==
NULL ) {
125 rodsLog(
LOG_ERROR,
"Cannot allocate pointer pointer buffer of size %lld", pointersSize);
130 memcpy( pointersCopy, pointersMapped + (
buf - bufMapped ), pointersSize );
133 pointers = pointersCopy;
146 long diff = bufCopy - bufMapped;
147 long pointerDiff = diff;
148 applyDiff( pointers, pointersSize, diff, pointerDiff );
149 free( pointersCopy );
151 #ifdef RE_CACHE_CHECK
153 cacheChkEnv( cacheCopy->
coreFuncDescIndex, cacheCopy, ( CacheChkFuncType * ) cacheChkNode, objectMap );
154 cacheChkRuleSet( cacheCopy->
coreRuleSet, cacheCopy, objectMap );
158 void applyDiff(
unsigned char *pointers,
long pointersSize,
long diff,
long pointerDiff ) {
161 printf(
"storing cache from buf = %p, pointers = %p\n",
buf, pointers );
163 for (
p = pointers;
p - pointers < pointersSize;
p +=
CACHE_SIZE(
unsigned char *, 1 ) ) {
165 printf(
"p = %p\n",
p );
167 unsigned char *
pointer = *( (
unsigned char ** )
p ) + pointerDiff;
169 printf(
"applying diff to pointer at %p\n",
pointer );
171 *( (
unsigned char ** )
pointer ) += diff;
178 printf(
"storing cache from buf = %p, pointers = %p\n",
buf, pointers );
180 for (
p = pointers;
p - pointers < pointersSize;
p +=
CACHE_SIZE(
unsigned char *, 1 ) ) {
182 printf(
"p = %p\n",
p );
184 *( (
unsigned char ** )
p ) += pointerDiff;
186 printf(
"applying diff to pointer at %p\n",
pointer );
204 unsigned char *
buf = (
unsigned char * ) malloc(
size );
207 unsigned char *cacheBuf =
buf;
209 if ( cacheCopy !=
NULL ) {
211 printf(
"Buffer usage: %fM\n", ( (
double )( cacheCopy->
dataSize ) ) / ( 1024 * 1024 ) );
217 if (shared ==
NULL) {
220 long diff = shared - cacheCopy->
address;
221 unsigned char *pointers = cacheCopy->
pointers;
223 applyDiff( pointers, pointersSize, diff, 0 );
226 memset( shared, 0,
SHMMAX );
230 memcpy( cacheCopy->
pointers, pointers, pointersSize );
244 rodsLog(
LOG_ERROR,
"Cannot update cache because of out of memory error, let some other process update it later when memory is available." );