}
}
-/* Sets type */
+/* Sets type and diskstore negative caching hash table */
dictType setDictType = {
dictEncObjHash, /* hash function */
NULL, /* key dup */
if ((server.maxidletime && !(loops % 100)) || server.bpop_blocked_clients)
closeTimedoutClients();
- /* Check if a background saving or AOF rewrite in progress terminated */
+ /* Check if a background saving or AOF rewrite in progress terminated. */
if (server.bgsavechildpid != -1 || server.bgrewritechildpid != -1) {
int statloc;
pid_t pid;
if ((pid = wait3(&statloc,WNOHANG,NULL)) != 0) {
+ int exitcode = WEXITSTATUS(statloc);
+ int bysignal = 0;
+
+ if (WIFSIGNALED(statloc)) bysignal = WTERMSIG(statloc);
+
if (pid == server.bgsavechildpid) {
- backgroundSaveDoneHandler(statloc);
+ backgroundSaveDoneHandler(exitcode,bysignal);
} else {
- backgroundRewriteDoneHandler(statloc);
+ backgroundRewriteDoneHandler(exitcode,bysignal);
}
updateDictResizePolicy();
}
- } else {
+ } else if (server.bgsavethread != (pthread_t) -1) {
+ if (server.bgsavethread != (pthread_t) -1) {
+ int state;
+
+ pthread_mutex_lock(&server.bgsavethread_mutex);
+ state = server.bgsavethread_state;
+ pthread_mutex_unlock(&server.bgsavethread_mutex);
+
+ if (state == REDIS_BGSAVE_THREAD_DONE_OK ||
+ state == REDIS_BGSAVE_THREAD_DONE_ERR)
+ {
+ backgroundSaveDoneHandler(
+ (state == REDIS_BGSAVE_THREAD_DONE_OK) ? 0 : 1, 0);
+ }
+ }
+ } else if (!server.ds_enabled) {
/* If there is not a background saving in progress check if
* we have to save now */
time_t now = time(NULL);
server.syslog_enabled = 0;
server.syslog_ident = zstrdup("redis");
server.syslog_facility = LOG_LOCAL0;
- server.glueoutputbuf = 1;
server.daemonize = 0;
server.appendonly = 0;
server.appendfsync = APPENDFSYNC_EVERYSEC;
server.list_max_ziplist_value = REDIS_LIST_MAX_ZIPLIST_VALUE;
server.set_max_intset_entries = REDIS_SET_MAX_INTSET_ENTRIES;
server.shutdown_asap = 0;
+ server.cache_flush_delay = 0;
updateLRUClock();
resetServerSaveParams();
server.slaves = listCreate();
server.monitors = listCreate();
server.unblocked_clients = listCreate();
- server.cache_flush_queue = listCreate();
- server.cache_flush_delay = 0;
+ server.cache_io_queue = listCreate();
createSharedObjects();
server.el = aeCreateEventLoop();
server.db[j].expires = dictCreate(&keyptrDictType,NULL);
server.db[j].blocking_keys = dictCreate(&keylistDictType,NULL);
server.db[j].watched_keys = dictCreate(&keylistDictType,NULL);
- if (server.ds_enabled)
+ if (server.ds_enabled) {
server.db[j].io_keys = dictCreate(&keylistDictType,NULL);
+ server.db[j].io_negcache = dictCreate(&setDictType,NULL);
+ server.db[j].io_queued = dictCreate(&setDictType,NULL);
+ }
server.db[j].id = j;
}
server.pubsub_channels = dictCreate(&keylistDictType,NULL);
server.cronloops = 0;
server.bgsavechildpid = -1;
server.bgrewritechildpid = -1;
+ server.bgsavethread_state = REDIS_BGSAVE_THREAD_UNACTIVE;
+ server.bgsavethread = (pthread_t) -1;
server.bgrewritebuf = sdsempty();
server.aofbuf = sdsempty();
server.lastsave = time(NULL);
server.loading,
server.appendonly,
server.dirty,
- server.bgsavechildpid != -1,
+ server.bgsavechildpid != -1 || server.bgsavethread != (pthread_t) -1,
server.lastsave,
server.bgrewritechildpid != -1,
server.stat_numconnections,
eta
);
}
+
+ info = sdscat(info,"allocation_stats:");
+ for (j = 0; j <= ZMALLOC_MAX_ALLOC_STAT; j++) {
+ size_t count = zmalloc_allocations_for_size(j);
+ if (count) {
+ if (info[sdslen(info)-1] != ':') info = sdscatlen(info,",",1);
+ info = sdscatprintf(info,"%s%d=%zu",
+ (j == ZMALLOC_MAX_ALLOC_STAT) ? ">=" : "",
+ j,count);
+ }
+ }
+ info = sdscat(info,"\r\n");
+
for (j = 0; j < server.dbnum; j++) {
long long keys, vkeys;
/* Try to write the pid file in a best-effort way. */
FILE *fp = fopen(server.pidfile,"w");
if (fp) {
- fprintf(fp,"%d\n",getpid());
+ fprintf(fp,"%d\n",(int)getpid());
fclose(fp);
}
}