+#include "redis.h"
+#include "lzf.h" /* LZF compression library */
+
#include <math.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <arpa/inet.h>
#include <sys/stat.h>
-#include "rdb.h"
-#include "lzf.h" /* LZF compression library */
static int rdbWriteRaw(rio *rdb, void *p, size_t len) {
if (rdb && rioWrite(rdb,p,len) == 0)
if (obj->encoding == REDIS_ENCODING_INT) {
return rdbSaveLongLongAsStringObject(rdb,(long)obj->ptr);
} else {
- redisAssert(obj->encoding == REDIS_ENCODING_RAW);
+ redisAssertWithInfo(NULL,obj,obj->encoding == REDIS_ENCODING_RAW);
return rdbSaveRawString(rdb,obj->ptr,sdslen(obj->ptr));
}
}
nwritten += n;
while((de = dictNext(di)) != NULL) {
- robj *eleobj = dictGetEntryKey(de);
+ robj *eleobj = dictGetKey(de);
if ((n = rdbSaveStringObject(rdb,eleobj)) == -1) return -1;
nwritten += n;
}
nwritten += n;
while((de = dictNext(di)) != NULL) {
- robj *eleobj = dictGetEntryKey(de);
- double *score = dictGetEntryVal(de);
+ robj *eleobj = dictGetKey(de);
+ double *score = dictGetVal(de);
if ((n = rdbSaveStringObject(rdb,eleobj)) == -1) return -1;
nwritten += n;
nwritten += n;
while((de = dictNext(di)) != NULL) {
- robj *key = dictGetEntryKey(de);
- robj *val = dictGetEntryVal(de);
+ robj *key = dictGetKey(de);
+ robj *val = dictGetVal(de);
if ((n = rdbSaveStringObject(rdb,key)) == -1) return -1;
nwritten += n;
* we could switch to a faster solution. */
off_t rdbSavedObjectLen(robj *o) {
int len = rdbSaveObject(NULL,o);
- redisAssert(len != -1);
+ redisAssertWithInfo(NULL,o,len != -1);
return len;
}
/* Iterate this DB writing every entry */
while((de = dictNext(di)) != NULL) {
- sds keystr = dictGetEntryKey(de);
- robj key, *o = dictGetEntryVal(de);
+ sds keystr = dictGetKey(de);
+ robj key, *o = dictGetVal(de);
time_t expire;
initStaticStringObject(key,keystr);
rio rdb;
fp = fopen(filename,"r");
- if (!fp) return REDIS_ERR;
+ if (!fp) {
+ errno = ENOENT;
+ return REDIS_ERR;
+ }
rioInitWithFile(&rdb,fp);
if (rioRead(&rdb,buf,9) == 0) goto eoferr;
buf[9] = '\0';
if (memcmp(buf,"REDIS",5) != 0) {
fclose(fp);
redisLog(REDIS_WARNING,"Wrong signature trying to load DB from file");
+ errno = EINVAL;
return REDIS_ERR;
}
rdbver = atoi(buf+5);
if (rdbver < 1 || rdbver > 2) {
fclose(fp);
redisLog(REDIS_WARNING,"Can't handle RDB format version %d",rdbver);
+ errno = EINVAL;
return REDIS_ERR;
}