From: Salvatore Sanfilippo <antirez@gmail.com> Date: Fri, 2 Nov 2012 11:10:47 +0000 (-0700) Subject: Merge pull request #741 from Run/typo X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/06851a93de54c4d9bb0a6c52234ef5bb3db07d96?hp=c23c657cdd8696c66295962947b85c793c5d7b93 Merge pull request #741 from Run/typo fix a typo in redis.h line 595 comment --- diff --git a/deps/Makefile b/deps/Makefile index 7cd9c0f6..d58ee568 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -73,6 +73,6 @@ JEMALLOC_LDFLAGS= $(LDFLAGS) jemalloc: .make-prerequisites @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) cd jemalloc && ./configure --with-jemalloc-prefix=je_ --enable-cc-silence CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" - cd jemalloc && $(MAKE) lib/libjemalloc.a + cd jemalloc && $(MAKE) CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" lib/libjemalloc.a .PHONY: jemalloc diff --git a/src/networking.c b/src/networking.c index 3bc084f7..22392f06 100644 --- a/src/networking.c +++ b/src/networking.c @@ -486,11 +486,11 @@ void copyClientOutputBuffer(redisClient *dst, redisClient *src) { dst->reply_bytes = src->reply_bytes; } -static void acceptCommonHandler(int fd) { +static void acceptCommonHandler(int fd, int flags) { redisClient *c; if ((c = createClient(fd)) == NULL) { - redisLog(REDIS_WARNING,"Error allocating resoures for the client"); - close(fd); /* May be already closed, just ingore errors */ + redisLog(REDIS_WARNING,"Error allocating resources for the client"); + close(fd); /* May be already closed, just ignore errors */ return; } /* If maxclient directive is set and this is one client more... close the @@ -509,6 +509,7 @@ static void acceptCommonHandler(int fd) { return; } server.stat_numconnections++; + c->flags |= flags; } void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) { @@ -524,7 +525,7 @@ void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) { return; } redisLog(REDIS_VERBOSE,"Accepted %s:%d", cip, cport); - acceptCommonHandler(cfd); + acceptCommonHandler(cfd,0); } void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) { @@ -539,7 +540,7 @@ void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) { return; } redisLog(REDIS_VERBOSE,"Accepted connection to %s", server.unixsocket); - acceptCommonHandler(cfd); + acceptCommonHandler(cfd,REDIS_UNIX_SOCKET); } @@ -990,9 +991,9 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) { server.current_client = c; readlen = REDIS_IOBUF_LEN; /* If this is a multi bulk request, and we are processing a bulk reply - * that is large enough, try to maximize the probabilty that the query - * buffer contains excatly the SDS string representing the object, even - * at the risk of requring more read(2) calls. This way the function + * that is large enough, try to maximize the probability that the query + * buffer contains exactly the SDS string representing the object, even + * at the risk of requiring more read(2) calls. This way the function * processMultiBulkBuffer() can avoid copying buffers to create the * Redis Object representing the argument. */ if (c->reqtype == REDIS_REQ_MULTIBULK && c->multibulklen && c->bulklen != -1 @@ -1062,10 +1063,11 @@ void getClientsMaxBuffers(unsigned long *longest_output_list, /* Turn a Redis client into an sds string representing its state. */ sds getClientInfoString(redisClient *client) { char ip[32], flags[16], events[3], *p; - int port; + int port = 0; /* initialized to zero for the unix socket case. */ int emask; - anetPeerToString(client->fd,ip,&port); + if (!(client->flags & REDIS_UNIX_SOCKET)) + anetPeerToString(client->fd,ip,&port); p = flags; if (client->flags & REDIS_SLAVE) { if (client->flags & REDIS_MONITOR) @@ -1080,6 +1082,7 @@ sds getClientInfoString(redisClient *client) { if (client->flags & REDIS_CLOSE_AFTER_REPLY) *p++ = 'c'; if (client->flags & REDIS_UNBLOCKED) *p++ = 'u'; if (client->flags & REDIS_CLOSE_ASAP) *p++ = 'A'; + if (client->flags & REDIS_UNIX_SOCKET) *p++ = 'U'; if (p == flags) *p++ = 'N'; *p++ = '\0'; @@ -1090,7 +1093,8 @@ sds getClientInfoString(redisClient *client) { *p = '\0'; return sdscatprintf(sdsempty(), "addr=%s:%d fd=%d age=%ld idle=%ld flags=%s db=%d sub=%d psub=%d multi=%d qbuf=%lu qbuf-free=%lu obl=%lu oll=%lu omem=%lu events=%s cmd=%s", - ip,port,client->fd, + (client->flags & REDIS_UNIX_SOCKET) ? server.unixsocket : ip, + port,client->fd, (long)(server.unixtime - client->ctime), (long)(server.unixtime - client->lastinteraction), flags, @@ -1227,7 +1231,7 @@ unsigned long getClientOutputBufferMemoryUsage(redisClient *c) { return c->reply_bytes + (list_item_size*listLength(c->reply)); } -/* Get the class of a client, used in order to envorce limits to different +/* Get the class of a client, used in order to enforce limits to different * classes of clients. * * The function will return one of the following: diff --git a/src/redis.c b/src/redis.c index 86a702d0..e4b36798 100644 --- a/src/redis.c +++ b/src/redis.c @@ -915,8 +915,12 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { if (pid == server.rdb_child_pid) { backgroundSaveDoneHandler(exitcode,bysignal); - } else { + } else if (pid == server.aof_child_pid) { backgroundRewriteDoneHandler(exitcode,bysignal); + } else { + redisLog(REDIS_WARNING, + "Warning, detected child with unmatched pid: %ld", + (long)pid); } updateDictResizePolicy(); } @@ -1548,7 +1552,7 @@ void call(redisClient *c, int flags) { } /* If this function gets called we already read a whole - * command, argments are in the client argv/argc fields. + * command, arguments are in the client argv/argc fields. * processCommand() execute the command or prepare the * server for a bulk read from the client. * @@ -2229,7 +2233,7 @@ void infoCommand(redisClient *c) { } void monitorCommand(redisClient *c) { - /* ignore MONITOR if aleady slave or in monitor mode */ + /* ignore MONITOR if already slave or in monitor mode */ if (c->flags & REDIS_SLAVE) return; c->flags |= (REDIS_SLAVE|REDIS_MONITOR); @@ -2328,7 +2332,7 @@ int freeMemoryIfNeeded(void) { de = dictGetRandomKey(dict); thiskey = dictGetKey(de); - /* When policy is volatile-lru we need an additonal lookup + /* When policy is volatile-lru we need an additional lookup * to locate the real key, as dict is set to db->expires. */ if (server.maxmemory_policy == REDIS_MAXMEMORY_VOLATILE_LRU) de = dictFind(db->dict, thiskey); @@ -2631,7 +2635,7 @@ int main(int argc, char **argv) { redisAsciiArt(); if (!server.sentinel_mode) { - /* Things only needed when not runnign in Sentinel mode. */ + /* Things only needed when not running in Sentinel mode. */ redisLog(REDIS_WARNING,"Server started, Redis version " REDIS_VERSION); #ifdef __linux__ linuxOvercommitMemoryWarning(); diff --git a/src/redis.h b/src/redis.h index 5b1dc1de..9f6c0406 100644 --- a/src/redis.h +++ b/src/redis.h @@ -152,6 +152,7 @@ #define REDIS_LUA_CLIENT 512 /* This is a non connected client used by Lua */ #define REDIS_ASKING 1024 /* Client issued the ASKING command */ #define REDIS_CLOSE_ASAP 2048 /* Close this client ASAP */ +#define REDIS_UNIX_SOCKET 4096 /* Client connected via Unix domain socket */ /* Client request types */ #define REDIS_REQ_INLINE 1 diff --git a/src/replication.c b/src/replication.c index c1e46191..222032cf 100644 --- a/src/replication.c +++ b/src/replication.c @@ -54,10 +54,12 @@ void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj ** gettimeofday(&tv,NULL); cmdrepr = sdscatprintf(cmdrepr,"%ld.%06ld ",(long)tv.tv_sec,(long)tv.tv_usec); if (c->flags & REDIS_LUA_CLIENT) { - cmdrepr = sdscatprintf(cmdrepr,"[%d lua] ", dictid); + cmdrepr = sdscatprintf(cmdrepr,"[%d lua] ",dictid); + } else if (c->flags & REDIS_UNIX_SOCKET) { + cmdrepr = sdscatprintf(cmdrepr,"[%d unix:%s] ",dictid,server.unixsocket); } else { anetPeerToString(c->fd,ip,&port); - cmdrepr = sdscatprintf(cmdrepr,"[%d %s:%d] ", dictid,ip,port); + cmdrepr = sdscatprintf(cmdrepr,"[%d %s:%d] ",dictid,ip,port); } for (j = 0; j < argc; j++) {