Ver código fonte

fifo, script callbacks and timer release pkg mem from cleanup;
note that it affects only the main process

Jiri Kuthan 22 anos atrás
pai
commit
3c8bd369e6
7 arquivos alterados com 53 adições e 5 exclusões
  1. 15 1
      fifo_server.c
  2. 2 0
      fifo_server.h
  3. 4 0
      main.c
  4. 11 0
      script_cb.c
  5. 1 0
      script_cb.h
  6. 10 4
      sr_module.c
  7. 10 0
      timer.c

+ 15 - 1
fifo_server.c

@@ -53,8 +53,9 @@
  *
  * History:
  * --------
- *  2003-01-29  new built-in fifo commands: arg and pwd (jiri)
+ *  2003-03-29  destroy pkg mem introduced (jiri)
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
+ *  2003-01-29  new built-in fifo commands: arg and pwd (jiri)
  */
 
 
@@ -135,6 +136,19 @@ int register_fifo_cmd(fifo_cmd f, char *cmd_name, void *param)
 	return 1;
 }
 
+void destroy_fifo()
+{
+	struct fifo_command *c, *foo;
+
+	c=cmd_list;
+
+	while(c) {
+		foo=c->next;
+		pkg_free(c);
+		c=foo;
+	}
+}
+
 
 int read_line( char *b, int max, FILE *stream, int *read )
 {

+ 2 - 0
fifo_server.h

@@ -84,5 +84,7 @@ FILE *open_reply_pipe( char *pipe_name );
 /* tell FIFO client an error occured via reply pipe */
 void fifo_reply( char *reply_fifo, char *reply_fmt, ... );
 
+/* memory deallocation */
+void destroy_fifo();
 
 #endif

+ 4 - 0
main.c

@@ -29,6 +29,7 @@
  * 2002-01-29  argc/argv globalized via my_{argc|argv} (jiri)
  * 2003-01-23  mhomed added (jiri)
  * 2003-03-19  replaced all malloc/frees w/ pkg_malloc/pkg_free (andrei)
+ * 2003-03-29  pkg cleaners for fifo and script callbacks introduced (jiri)
  *
  */
 
@@ -80,6 +81,7 @@
 #include "name_alias.h"
 #include "hash_func.h"
 #include "pt.h"
+#include "script_cb.h"
 #ifdef USE_TCP
 #include "tcp_init.h"
 #endif
@@ -355,6 +357,8 @@ void cleanup(show_status)
 	destroy_tcp();
 #endif
 	destroy_timer();
+	destroy_fifo();
+	destroy_script_cb();
 #ifdef PKG_MALLOC
 	if (show_status){
 		LOG(memlog, "Memory status (pkg):\n");

+ 11 - 0
script_cb.c

@@ -31,6 +31,7 @@
  */
 /* History:
  * --------
+ *  2003-03-29  cleaning pkg allocation introduced (jiri)
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
  */
 
@@ -72,6 +73,16 @@ int register_script_cb( cb_function f, callback_t t, void *param )
 	return 1;
 }
 
+void destroy_script_cb()
+{
+	struct script_cb *cb, *foo;
+
+	cb=pre_cb;
+	while(cb) { foo=cb->next;pkg_free(cb);cb=foo; }
+	cb=post_cb;
+	while(cb) { foo=cb->next;pkg_free(cb);cb=foo; }
+}
+
 int exec_pre_cb( struct sip_msg *msg)
 {
 	struct script_cb *i;

+ 1 - 0
script_cb.h

@@ -46,5 +46,6 @@ struct script_cb{
 int register_script_cb( cb_function f, callback_t t, void *param );
 int exec_pre_cb( struct sip_msg *msg);
 void exec_post_cb( struct sip_msg *msg);
+void destroy_script_cb();
 
 

+ 10 - 4
sr_module.c

@@ -30,6 +30,7 @@
  *               find_export_param, find_module (andrei)
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
  *  2003-03-19  Support for flags in find_export (janakj)
+ *  2003-03-29  cleaning pkg_mallocs introduced (jiri)
  */
 
 
@@ -266,10 +267,15 @@ struct sr_module* find_module(void* f, cmd_export_t  **c)
 
 void destroy_modules()
 {
-	struct sr_module* t;
-
-	for(t=modules;t;t=t->next)
-		if  ((t->exports)&&(t->exports->destroy_f)) t->exports->destroy_f();
+	struct sr_module* t, *foo;
+
+	t=modules;
+	while(t) {
+		foo=t->next;
+		if ((t->exports)&&(t->exports->destroy_f)) t->exports->destroy_f();
+		pkg_free(t);
+		t=foo;
+	}
 	modules=0;
 }
 

+ 10 - 0
timer.c

@@ -27,6 +27,7 @@
 /* History:
  * --------
  *  2003-03-19  replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
+ *  2003-03-29  cleaning pkg_mallocs introduced (jiri)
  */
 
 
@@ -72,6 +73,8 @@ int init_timer()
 
 void destroy_timer()
 {
+	struct sr_timer* t, *foo;
+
 	if (jiffies){
 #ifdef SHM_MEM
 		shm_free(jiffies); jiffies=0;
@@ -79,6 +82,13 @@ void destroy_timer()
 		pkg_free(jiffies); jiffies=0;
 #endif
 	}
+
+	t=timer_list;
+	while(t) {
+		foo=t->next;
+		pkg_free(t);
+		t=foo;
+	}
 }