Hello,

looking at ndb_redis module source code I see replies are not freed when module is destroyed.

Also a reply is only freed when another one with same name is performed. This could cause problems if an user would ask for
a lot of different named replies.

IMHO freeing reply list when module is destroyed and creating a new redisc_free_reply function would solve this.


I attach a patch that compiles but not tested to show the idea.

If you agree I can perform the task, I suppose redisc_free_reply function should also be exported in cmd_export_t module structure.


This solution would be compatible with old ndb redis module configuration.



Regards,
Vicente.

diff --git modules/ndb_redis/api.h modules/ndb_redis/api.h
new file mode 100644
index 0000000..d54071d
--- /dev/null
+++ modules/ndb_redis/api.h
@@ -0,0 +1,66 @@
+/**
+ * $Id$
+ *
+ * Copyright (C) 2012 Vicente Hernando Ara (System One: www.systemonenoc.com)
+ *
+ * This file is part of kamailio, a free SIP server.
+ *
+ * kamailio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _NDB_REDIS_API_H_
+#define _NDB_REDIS_API_H_
+
+#include "../../sr_module.h"
+#include "../../str.h"
+
+#include "redis_client.h"
+
+
+typedef int (*redisc_exec_f)(str *srv, str *cmd, str *argv1, str *argv2,
+							str *argv3, str *res);
+
+typedef redisc_reply_t* (*redisc_get_reply_f)(str *name);
+
+typedef struct ndb_redis_api {
+	redisc_exec_f exec;
+	redisc_get_reply_f get_reply;
+} ndb_redis_api_t;
+
+typedef int (*bind_ndb_redis_f)(ndb_redis_api_t* api);
+int bind_ndb_redis(ndb_redis_api_t* api);
+
+
+/**
+ * @brief Load the NDB_REDIS API
+ */
+static inline int ndb_redis_load_api(ndb_redis_api_t *api)
+{
+	bind_ndb_redis_f bindredis;
+
+	bindredis = (bind_ndb_redis_f)find_export("bind_ndb_redis", 0, 0);
+	if(bindredis == 0) {
+		LM_ERR("cannot find bind_ndb_redis\n");
+		return -1;
+	}
+	if(bindredis(api)<0)
+	{
+		LM_ERR("cannot bind ndb redis api\n");
+		return -1;
+	}
+	return 0;
+}
+
+#endif
diff --git modules/ndb_redis/ndb_redis_mod.c modules/ndb_redis/ndb_redis_mod.c
index d91626c..f436ffd 100644
--- modules/ndb_redis/ndb_redis_mod.c
+++ modules/ndb_redis/ndb_redis_mod.c
@@ -36,6 +36,7 @@
 #include "../../trim.h"
 
 #include "redis_client.h"
+#include "api.h"
 
 MODULE_VERSION
 
@@ -556,3 +557,21 @@ static int pv_get_redisc(struct sip_msg *msg,  pv_param_t *param,
 			return pv_get_null(msg, param, res);
 	}
 }
+
+
+/**
+ *
+ */
+int bind_ndb_redis(ndb_redis_api_t* api)
+{
+	if (!api)
+	{
+		LM_ERR("bind_ndb_redis: Invalid parameter value\n");
+		return -1;
+	}
+
+	api->exec = redisc_exec;
+	api->get_reply = redisc_get_reply;
+
+	return 0;
+}
_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to