Browse code

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

Jiri Kuthan authored on 29/03/2003 02:30:35
Showing 7 changed files
... ...
@@ -53,8 +53,9 @@
53 53
  *
54 54
  * History:
55 55
  * --------
56
- *  2003-01-29  new built-in fifo commands: arg and pwd (jiri)
56
+ *  2003-03-29  destroy pkg mem introduced (jiri)
57 57
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
58
+ *  2003-01-29  new built-in fifo commands: arg and pwd (jiri)
58 59
  */
59 60
 
60 61
 
... ...
@@ -135,6 +136,19 @@ int register_fifo_cmd(fifo_cmd f, char *cmd_name, void *param)
135 135
 	return 1;
136 136
 }
137 137
 
138
+void destroy_fifo()
139
+{
140
+	struct fifo_command *c, *foo;
141
+
142
+	c=cmd_list;
143
+
144
+	while(c) {
145
+		foo=c->next;
146
+		pkg_free(c);
147
+		c=foo;
148
+	}
149
+}
150
+
138 151
 
139 152
 int read_line( char *b, int max, FILE *stream, int *read )
140 153
 {
... ...
@@ -84,5 +84,7 @@ FILE *open_reply_pipe( char *pipe_name );
84 84
 /* tell FIFO client an error occured via reply pipe */
85 85
 void fifo_reply( char *reply_fifo, char *reply_fmt, ... );
86 86
 
87
+/* memory deallocation */
88
+void destroy_fifo();
87 89
 
88 90
 #endif
... ...
@@ -29,6 +29,7 @@
29 29
  * 2002-01-29  argc/argv globalized via my_{argc|argv} (jiri)
30 30
  * 2003-01-23  mhomed added (jiri)
31 31
  * 2003-03-19  replaced all malloc/frees w/ pkg_malloc/pkg_free (andrei)
32
+ * 2003-03-29  pkg cleaners for fifo and script callbacks introduced (jiri)
32 33
  *
33 34
  */
34 35
 
... ...
@@ -80,6 +81,7 @@
80 80
 #include "name_alias.h"
81 81
 #include "hash_func.h"
82 82
 #include "pt.h"
83
+#include "script_cb.h"
83 84
 #ifdef USE_TCP
84 85
 #include "tcp_init.h"
85 86
 #endif
... ...
@@ -355,6 +357,8 @@ void cleanup(show_status)
355 355
 	destroy_tcp();
356 356
 #endif
357 357
 	destroy_timer();
358
+	destroy_fifo();
359
+	destroy_script_cb();
358 360
 #ifdef PKG_MALLOC
359 361
 	if (show_status){
360 362
 		LOG(memlog, "Memory status (pkg):\n");
... ...
@@ -31,6 +31,7 @@
31 31
  */
32 32
 /* History:
33 33
  * --------
34
+ *  2003-03-29  cleaning pkg allocation introduced (jiri)
34 35
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
35 36
  */
36 37
 
... ...
@@ -72,6 +73,16 @@ int register_script_cb( cb_function f, callback_t t, void *param )
72 72
 	return 1;
73 73
 }
74 74
 
75
+void destroy_script_cb()
76
+{
77
+	struct script_cb *cb, *foo;
78
+
79
+	cb=pre_cb;
80
+	while(cb) { foo=cb->next;pkg_free(cb);cb=foo; }
81
+	cb=post_cb;
82
+	while(cb) { foo=cb->next;pkg_free(cb);cb=foo; }
83
+}
84
+
75 85
 int exec_pre_cb( struct sip_msg *msg)
76 86
 {
77 87
 	struct script_cb *i;
... ...
@@ -46,5 +46,6 @@ struct script_cb{
46 46
 int register_script_cb( cb_function f, callback_t t, void *param );
47 47
 int exec_pre_cb( struct sip_msg *msg);
48 48
 void exec_post_cb( struct sip_msg *msg);
49
+void destroy_script_cb();
49 50
 
50 51
 
... ...
@@ -30,6 +30,7 @@
30 30
  *               find_export_param, find_module (andrei)
31 31
  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
32 32
  *  2003-03-19  Support for flags in find_export (janakj)
33
+ *  2003-03-29  cleaning pkg_mallocs introduced (jiri)
33 34
  */
34 35
 
35 36
 
... ...
@@ -266,10 +267,15 @@ struct sr_module* find_module(void* f, cmd_export_t  **c)
266 266
 
267 267
 void destroy_modules()
268 268
 {
269
-	struct sr_module* t;
270
-
271
-	for(t=modules;t;t=t->next)
272
-		if  ((t->exports)&&(t->exports->destroy_f)) t->exports->destroy_f();
269
+	struct sr_module* t, *foo;
270
+
271
+	t=modules;
272
+	while(t) {
273
+		foo=t->next;
274
+		if ((t->exports)&&(t->exports->destroy_f)) t->exports->destroy_f();
275
+		pkg_free(t);
276
+		t=foo;
277
+	}
273 278
 	modules=0;
274 279
 }
275 280
 
... ...
@@ -27,6 +27,7 @@
27 27
 /* History:
28 28
  * --------
29 29
  *  2003-03-19  replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
30
+ *  2003-03-29  cleaning pkg_mallocs introduced (jiri)
30 31
  */
31 32
 
32 33
 
... ...
@@ -72,6 +73,8 @@ int init_timer()
72 72
 
73 73
 void destroy_timer()
74 74
 {
75
+	struct sr_timer* t, *foo;
76
+
75 77
 	if (jiffies){
76 78
 #ifdef SHM_MEM
77 79
 		shm_free(jiffies); jiffies=0;
... ...
@@ -79,6 +82,13 @@ void destroy_timer()
79 79
 		pkg_free(jiffies); jiffies=0;
80 80
 #endif
81 81
 	}
82
+
83
+	t=timer_list;
84
+	while(t) {
85
+		foo=t->next;
86
+		pkg_free(t);
87
+		t=foo;
88
+	}
82 89
 }
83 90
 
84 91