"encoding:%s serializedlength:%lld "
"lru:%d lru_seconds_idle:%lu",
(void*)val, val->refcount,
- strenc, (long long) rdbSavedObjectLen(val,NULL),
+ strenc, (long long) rdbSavedObjectLen(val),
val->lru, estimateObjectIdleTime(val));
} else {
vmpointer *vp = (vmpointer*) val;
* the rdbSaveObject() function. Currently we use a trick to get
* this length with very little changes to the code. In the future
* we could switch to a faster solution. */
-off_t rdbSavedObjectLen(robj *o, FILE *fp) {
- int nwritten;
- if (fp == NULL) fp = server.devnull;
- rewind(fp);
-
- /* Determining the saved length of an object should never return -1 */
- redisAssert((nwritten = rdbSaveObject(fp,o)) != -1);
- return nwritten;
+off_t rdbSavedObjectLen(robj *o) {
+ int len = rdbSaveObject(NULL,o);
+ redisAssert(len != -1);
+ return len;
}
/* Return the number of pages required to save this object in the swap file */
-off_t rdbSavedObjectPages(robj *o, FILE *fp) {
- off_t bytes = rdbSavedObjectLen(o,fp);
-
+off_t rdbSavedObjectPages(robj *o) {
+ off_t bytes = rdbSavedObjectLen(o);
return (bytes+(server.vm_page_size-1))/server.vm_page_size;
}
setupSigSegvAction();
server.mainthread = pthread_self();
- server.devnull = fopen("/dev/null","w");
- if (server.devnull == NULL) {
- redisLog(REDIS_WARNING, "Can't open /dev/null: %s", server.neterr);
- exit(1);
- }
server.clients = listCreate();
server.slaves = listCreate();
server.monitors = listCreate();
dict *pubsub_channels; /* Map channels to list of subscribed clients */
list *pubsub_patterns; /* A list of pubsub_patterns */
/* Misc */
- FILE *devnull;
unsigned lruclock:22; /* clock incrementing every minute, for LRU */
unsigned lruclock_padding:10;
};
void rdbRemoveTempFile(pid_t childpid);
int rdbSave(char *filename);
int rdbSaveObject(FILE *fp, robj *o);
-off_t rdbSavedObjectPages(robj *o, FILE *fp);
-off_t rdbSavedObjectLen(robj *o, FILE *fp);
+off_t rdbSavedObjectLen(robj *o);
+off_t rdbSavedObjectPages(robj *o);
robj *rdbLoadObject(int type, FILE *fp);
void backgroundSaveDoneHandler(int statloc);
* If we can't find enough contiguous empty pages to swap the object on disk
* NULL is returned. */
vmpointer *vmSwapObjectBlocking(robj *val) {
- off_t pages = rdbSavedObjectPages(val,NULL);
+ off_t pages = rdbSavedObjectPages(val);
off_t page;
vmpointer *vp;
vmpointer *vp = (vmpointer*)j->id;
j->val = vmReadObjectFromSwap(j->page,vp->vtype);
} else if (j->type == REDIS_IOJOB_PREPARE_SWAP) {
- FILE *fp = fopen("/dev/null","w+");
- j->pages = rdbSavedObjectPages(j->val,fp);
- fclose(fp);
+ j->pages = rdbSavedObjectPages(j->val);
} else if (j->type == REDIS_IOJOB_DO_SWAP) {
if (vmWriteObjectOnSwap(j->val,j->page) == REDIS_ERR)
j->canceled = 1;