Browse code

- fixed memory leak when rewritting uri - route match after new uri - dmalloc debuging support

Andrei Pelinescu-Onciul authored on 26/09/2001 17:18:01
Showing 12 changed files
... ...
@@ -16,13 +16,13 @@ NAME=sip_router
16 16
 
17 17
 
18 18
 CC=gcc
19
-CFLAGS=-O2 -Wcast-align  #-Wmissing-prototypes  -Wall
19
+CFLAGS=-O2 -Wcast-align #-Wmissing-prototypes  -Wall
20 20
 LEX=lex
21 21
 YACC=yacc
22 22
 YACC_FLAGS=-d -b cfg
23 23
 # on linux and freebsd keep it empty (e.g. LIBS= )
24 24
 # on solaris add -lxnet (e.g. LIBS= -lxnet)
25
-LIBS=-lfl -L/usr/local/lib
25
+LIBS=-lfl -L/usr/local/lib 
26 26
 ALLDEP=Makefile
27 27
 
28 28
 MKDEP=gcc -M
... ...
@@ -21,6 +21,10 @@
21 21
 #include <netinet/in.h>
22 22
 #include <arpa/inet.h>
23 23
 
24
+#ifdef DEBUG_DMALLOC
25
+#include <dmalloc.h>
26
+#endif
27
+
24 28
 
25 29
 /* ret= 0! if action -> end of list(e.g DROP), 
26 30
       > 0 to continue processing next actions
... ...
@@ -9,6 +9,11 @@
9 9
 	#include "cfg.tab.h"
10 10
 	#include "dprint.h"
11 11
 	#include <string.h>
12
+	#include <stdlib.h>
13
+
14
+#ifdef DEBUG_DMALLOC
15
+#include <dmalloc.h>
16
+#endif
12 17
 
13 18
 	/* states */
14 19
 	#define INITIAL_S		0
... ...
@@ -17,6 +17,10 @@
17 17
 #include "route.h"
18 18
 #include "dprint.h"
19 19
 
20
+#ifdef DEBUG_DMALLOC
21
+#include <dmalloc.h>
22
+#endif
23
+
20 24
 void yyerror(char* s);
21 25
 char* tmp;
22 26
 
... ...
@@ -20,6 +20,10 @@
20 20
 #include "udp_server.h"
21 21
 #include "globals.h"
22 22
 
23
+#ifdef DEBUG_DMALLOC
24
+#include <dmalloc.h>
25
+#endif
26
+
23 27
 #define MAX_VIA_LINE_SIZE      240
24 28
 #define MAX_RECEIVED_SIZE  57
25 29
 
... ...
@@ -21,6 +21,11 @@
21 21
 #include "globals.h"
22 22
 
23 23
 
24
+#ifdef DEBUG_DMALLOC
25
+#include <dmalloc.h>
26
+#endif
27
+
28
+
24 29
 static char id[]="@(#) $Id$";
25 30
 static char version[]="sip_router 0.6";
26 31
 static char help_msg[]= "\
... ...
@@ -13,6 +13,10 @@
13 13
 #include "error.h"
14 14
 #include "dprint.h"
15 15
 
16
+#ifdef DEBUG_DMALLOC
17
+#include <dmalloc.h>
18
+#endif
19
+
16 20
 
17 21
 
18 22
 #define DEBUG
... ...
@@ -13,6 +13,9 @@
13 13
 #include <string.h>
14 14
 #include <stdlib.h>
15 15
 
16
+#ifdef DEBUG_DMALLOC
17
+#include <dmalloc.h>
18
+#endif
16 19
 
17 20
 struct proxy_l* proxies=0;
18 21
 
... ...
@@ -12,6 +12,9 @@
12 12
 #include "forward.h"
13 13
 #include "action.h"
14 14
 
15
+#ifdef DEBUG_DMALLOC
16
+#include <dmalloc.h>
17
+#endif
15 18
 
16 19
 int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
17 20
 {
... ...
@@ -78,9 +81,11 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
78 78
 		}
79 79
 	}
80 80
 skip:
81
+	if (msg.new_uri) free(msg.new_uri);
81 82
 	free(msg.orig);
82 83
 	return 0;
83 84
 error:
85
+	if (msg.new_uri) free(msg.new_uri);
84 86
 	free(msg.orig);
85 87
 error1:
86 88
 	return -1;
... ...
@@ -19,6 +19,10 @@
19 19
 #include "dprint.h"
20 20
 #include "proxy.h"
21 21
 
22
+#ifdef DEBUG_DMALLOC
23
+#include <dmalloc.h>
24
+#endif
25
+
22 26
 /* main routing list */
23 27
 struct route_elem* rlist[RT_NO];
24 28
 
... ...
@@ -284,8 +288,13 @@ static int eval_elem(struct expr* e, struct sip_msg* msg)
284 284
 								e->op, e->subtype);
285 285
 				break;
286 286
 		case URI_O:
287
-				ret=comp_str(msg->first_line.u.request.uri, e->r.param,
288
-								e->op, e->subtype);
287
+				if(msg->new_uri){
288
+					ret=comp_str(msg->new_uri, e->r.param,
289
+									e->op, e->subtype);
290
+				}else{
291
+					ret=comp_str(msg->first_line.u.request.uri, e->r.param,
292
+									e->op, e->subtype);
293
+				}
289 294
 				break;
290 295
 		case SRCIP_O:
291 296
 				ret=comp_ip(msg->src_ip, e->r.param, e->op, e->subtype);
... ...
@@ -14,6 +14,10 @@
14 14
 
15 15
 #include "dprint.h"
16 16
 
17
+#ifdef DEBUG_DMALLOC
18
+#include <dmalloc.h>
19
+#endif
20
+
17 21
 struct expr* mk_exp(int op, struct expr* left, struct expr* right)
18 22
 {
19 23
 	struct expr * e;
... ...
@@ -15,6 +15,9 @@
15 15
 #include "dprint.h"
16 16
 #include "receive.h"
17 17
 
18
+#ifdef DEBUG_DMALLOC
19
+#include <dmalloc.h>
20
+#endif
18 21
 
19 22
 int udp_sock;
20 23