Get rid of 'retRecPtr' in RdbCache methods (not thread safe)

This commit is contained in:
Ivan Skytte Jørgensen
2016-07-21 16:08:14 +02:00
parent cdb443ec17
commit e5392ef08a
2 changed files with 21 additions and 18 deletions

@ -259,8 +259,7 @@ int64_t RdbCache::getLongLong2 ( collnum_t collnum ,
// this puts a int32_t in there
void RdbCache::addLongLong2 ( collnum_t collnum ,
uint64_t key , int64_t value ,
char **retRecPtr ) {
uint64_t key , int64_t value ) {
key_t k;
k.n0 = (uint64_t)key;
k.n1 = 0;
@ -269,15 +268,14 @@ void RdbCache::addLongLong2 ( collnum_t collnum ,
if ( m_dks != 0 ) gbshutdownLogicError();
addRecord ( collnum , (char *)&k , NULL , 0 , (char *)&value , 8 ,
0 , // timestamp=now
retRecPtr );
NULL );
// clear error in case addRecord set it
g_errno = 0;
}
// this puts a int32_t in there
void RdbCache::addLongLong ( collnum_t collnum ,
uint32_t key , int64_t value ,
char **retRecPtr ) {
uint32_t key , int64_t value ) {
key_t k;
k.n0 = 0;
k.n1 = (uint64_t)key;
@ -290,7 +288,7 @@ void RdbCache::addLongLong ( collnum_t collnum ,
//addRecord ( collnum , (char *)&key , NULL , 0 , (char *)&value , 8 ,
addRecord ( collnum , (char *)&k , NULL , 0 , (char *)&value , 8 ,
0 , // timestamp=now
retRecPtr );
NULL );
// clear error in case addRecord set it
g_errno = 0;
}
@ -328,8 +326,7 @@ int32_t RdbCache::getLong ( collnum_t collnum ,
// this puts a int32_t in there
void RdbCache::addLong ( collnum_t collnum ,
uint64_t key , int32_t value ,
char **retRecPtr ) {
uint64_t key , int32_t value ) {
key_t k;
k.n0 = 0;
k.n1 = key;
@ -338,8 +335,7 @@ void RdbCache::addLong ( collnum_t collnum ,
addRecord ( collnum , (char *)&k , NULL , 0 , (char *)&value ,
// by long we really mean 32 bits!
4,//sizeof(char *), // 4 , now 8 for 64 bit archs
0 , // timestamp=now
retRecPtr );
0 ); // timestamp=now
// clear error in case addRecord set it
g_errno = 0;
}

@ -94,8 +94,7 @@ class RdbCache {
// this puts a int32_t in there
void addLongLong ( collnum_t collnum ,
uint32_t key , int64_t value ,
char **retRecPtr = NULL ) ;
uint32_t key , int64_t value ) ;
// . both key and data are int64_ts here
// . returns -1 if not found
@ -106,16 +105,14 @@ class RdbCache {
// this puts a int32_t in there
void addLongLong2 ( collnum_t collnum ,
uint64_t key , int64_t value ,
char **retRecPtr = NULL ) ;
uint64_t key , int64_t value ) ;
// same routines for int32_ts now, but key is a int64_t
int32_t getLong ( collnum_t collnum ,
uint64_t key , int32_t maxAge , // in seconds
bool promoteRecord );
void addLong ( collnum_t collnum ,
uint64_t key , int32_t value ,
char **retRecPtr = NULL ) ;
uint64_t key , int32_t value ) ;
// . returns true if found, false if not found in cache
// . sets *rec and *recSize iff found
@ -264,6 +261,17 @@ class RdbCache {
const char *m_dbname;
bool addRecord(collnum_t collnum,
const char *cacheKey,
const char *rec1,
int32_t recSize1,
const char *rec2,
int32_t recSize2,
int32_t timestamp) {
return addRecord(collnum,cacheKey,rec1,recSize1,rec2,recSize2,timestamp,NULL);
}
private:
bool addRecord ( collnum_t collnum ,
const char *cacheKey ,
const char *rec1 ,
@ -271,10 +279,9 @@ class RdbCache {
const char *rec2 ,
int32_t recSize2 ,
int32_t timestamp ,
char **retRecPtr = NULL ) ;
char **retRecPtr );
private:
static void saveWrapper(void *state);
static void threadDoneWrapper(void *state, job_exit_t exit_type);
void threadDone();