From a36d524562a7f6d2e344c0aff3a2ea06a36199bb Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 7 Feb 2011 12:52:01 +0100 Subject: [PATCH] If port zero is specified, Redis will not listen for TCP connections --- redis.conf | 1 + src/redis.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/redis.conf b/redis.conf index ff694e43ac9c..b0332ea4084f 100644 --- a/redis.conf +++ b/redis.conf @@ -21,6 +21,7 @@ daemonize no pidfile /var/run/redis.pid # Accept connections on the specified port, default is 6379. +# If port 0 is specified Redis will not listen on a TCP socket. port 6379 # If you want you can bind a single interface, if the bind option is not diff --git a/src/redis.c b/src/redis.c index b18978fffc67..520fc8a9a4bf 100644 --- a/src/redis.c +++ b/src/redis.c @@ -852,7 +852,10 @@ void initServer() { createSharedObjects(); server.el = aeCreateEventLoop(); server.db = zmalloc(sizeof(redisDb)*server.dbnum); - server.ipfd = anetTcpServer(server.neterr,server.port,server.bindaddr); + + if (server.port != 0) + server.ipfd = anetTcpServer(server.neterr,server.port,server.bindaddr); + if (server.ipfd == ANET_ERR) { redisLog(REDIS_WARNING, "Opening port: %s", server.neterr); exit(1);