From 80e87a461a7d2ee54430127bdb6ac014778c54c5 Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Fri, 22 Jul 2011 12:11:40 +0200
Subject: [PATCH] Close the listening sockets. Apparently this allows faster
 restarts.

---
 src/redis.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/redis.c b/src/redis.c
index 4e2f73a71..0bedc25b3 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -1190,6 +1190,10 @@ int prepareForShutdown() {
         redisLog(REDIS_NOTICE,"Removing the pid file.");
         unlink(server.pidfile);
     }
+    /* Close the listening sockets. Apparently this allows faster restarts. */
+    if (server.ipfd != -1) close(server.ipfd);
+    if (server.sofd != -1) close(server.sofd);
+
     redisLog(REDIS_WARNING,"Redis is now ready to exit, bye bye...");
     return REDIS_OK;
 }