From 82ea1c6f5d05cb016e1eb85c54fa5105be2ac0b6 Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Mon, 24 Jun 2013 19:27:49 +0200
Subject: [PATCH] Move Replication Script Cache initialization in safer place.

It should be called just one time at startup and not every time the Lua
scripting engine is re-initialized, otherwise memory is leaked.
---
 src/redis.c     | 1 +
 src/scripting.c | 4 ----
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/redis.c b/src/redis.c
index fdd30d148..21298e6eb 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -1517,6 +1517,7 @@ void initServer() {
     }
 
     if (server.cluster_enabled) clusterInit();
+    replicationScriptCacheInit();
     scriptingInit();
     slowlogInit();
     bioInit();
diff --git a/src/scripting.c b/src/scripting.c
index f30956bd2..ff94ae165 100644
--- a/src/scripting.c
+++ b/src/scripting.c
@@ -655,10 +655,6 @@ void scriptingInit(void) {
      * to global variables. */
     scriptingEnableGlobalsProtection(lua);
 
-    /* Initialize the Replication Script Cache for EVALSHA propagation to
-     * slaves and AOF. */
-    replicationScriptCacheInit();
-
     server.lua = lua;
 }