Browse code

- changed malloc status to LOG(L_INFO) - fixed a malloc(0) in tm/sip_msg.c/*cloner (new_uri)

Andrei Pelinescu-Onciul authored on 06/12/2001 23:43:46
Showing 8 changed files
... ...
@@ -35,7 +35,7 @@ NAME=ser
35 35
 #                  twice, trying to free a pointer alloc'ed with a different
36 36
 #                  malloc etc.)
37 37
 DEFS=-DNOCR -DMACROEATER -DDNS_IP_HACK  -DSHM_MEM \
38
-	 -DPKG_MALLOC -DDBG_QM_MALLOC 
38
+	 -DPKG_MALLOC -DNO_DEBUG -DDBG_QM_MALLOC 
39 39
 #-DEXTRA_DEBUG
40 40
 # -DUSE_SHM_MEM
41 41
 #-DNO_DEBUG 
... ...
@@ -330,11 +330,14 @@ static void sig_usr(int signo)
330 330
 		if (is_main)
331 331
 			destroy_modules();
332 332
 #ifdef PKG_MALLOC
333
+		LOG(L_INFO, "Memory status (pkg):\n");
333 334
 		pkg_status();
334 335
 #endif
335 336
 #ifdef SHM_MEM
336
-		if (is_main)
337
+		if (is_main){
338
+			LOG(L_INFO, "Memory status (shm):\n");
337 339
 			shm_status();
340
+		}
338 341
 #endif
339 342
 #ifdef SHM_MEM
340 343
 		if (is_main)
... ...
@@ -346,9 +349,11 @@ static void sig_usr(int signo)
346 349
 		dump_all_statistic();
347 350
 #endif
348 351
 #ifdef PKG_MALLOC
352
+		LOG(L_INFO, "Memory status (pkg):\n");
349 353
 		pkg_status();
350 354
 #endif
351 355
 #ifdef SHM_MEM
356
+		LOG(L_INFO, "Memory status (shm):\n");
352 357
 		shm_status();
353 358
 #endif
354 359
 	}
... ...
@@ -62,9 +62,12 @@ struct sip_msg* sip_msg_cloner( struct sip_msg *org_msg )
62 62
     }
63 63
 
64 64
     /* new_uri  ( str type )*/
65
-    if (!(new_msg->new_uri.s = (char*)sh_malloc( org_msg->new_uri.len )))
66
-	goto error;
67
-    memcpy( new_msg->new_uri.s , org_msg->new_uri.s , org_msg->new_uri.len );
65
+	if (org_msg->new_uri.s){ 
66
+		if (!(new_msg->new_uri.s = (char*)sh_malloc( org_msg->new_uri.len )))
67
+			goto error;
68
+		memcpy( new_msg->new_uri.s , org_msg->new_uri.s ,
69
+				org_msg->new_uri.len );
70
+	}
68 71
 
69 72
     /* add_rm ( struct lump* )  -> have to be changed!!!!!!! */
70 73
     new_msg->add_rm  = 0;
... ...
@@ -258,19 +258,20 @@ void qm_status(struct qm_block* qm)
258 258
 	struct qm_frag* f;
259 259
 	int i;
260 260
 
261
-	DBG("qm_status (%x):\n", qm);
262
-	DBG(" heap size= %d\n", qm->size);
263
-	DBG(" used= %d, used+overhead=%d, free=%d\n",
261
+	LOG(L_INFO, "qm_status (%x):\n", qm);
262
+	LOG(L_INFO, " heap size= %d\n", qm->size);
263
+	LOG(L_INFO, " used= %d, used+overhead=%d, free=%d\n",
264 264
 			qm->used, qm->real_used, qm->size-qm->real_used);
265
-	DBG(" max used (+overhead)= %d\n", qm->max_real_used);
265
+	LOG(L_INFO, " max used (+overhead)= %d\n", qm->max_real_used);
266 266
 	
267
-	DBG("dumping all fragments:\n");
267
+	LOG(L_INFO, "dumping all fragments:\n");
268 268
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)
269 269
 			,i++){
270
-		DBG("    %3d. %c  address=%x  size=%d\n", i, (f->u.is_free)?'a':'N',
270
+		LOG(L_INFO, "    %3d. %c  address=%x  size=%d\n", i, 
271
+				(f->u.is_free)?'a':'N',
271 272
 				(char*)f+sizeof(struct qm_frag), f->size);
272 273
 #ifdef DBG_QM_MALLOC
273
-		DBG("            %s from %s: %s(%d)\n",
274
+		LOG(L_INFO, "            %s from %s: %s(%d)\n",
274 275
 				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
275 276
 #endif
276 277
 	}
... ...
@@ -284,7 +285,7 @@ void qm_status(struct qm_block* qm)
284 285
 				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
285 286
 #endif
286 287
 	}
287
-	DBG("-----------------------------\n");
288
+	LOG(L_INFO, "-----------------------------\n");
288 289
 }
289 290
 
290 291
 
291 292
new file mode 100644
... ...
@@ -0,0 +1,9 @@
1
+INVITE sip:foo@127.0.0.1:5061  SIP/2.0
2
+Via: SIP/2.0/UDP 127.0.0.1:5062
3
+From:  <sip:x@foo.bar>
4
+To: <sip:y@bar.foo>
5
+Call-ID: 9437892232b@foo.bar
6
+CSeq: 143 INVITE
7
+Contact:<sip:x@foo.bar>
8
+
9
+
0 10
new file mode 100644
... ...
@@ -0,0 +1,58 @@
1
+debug=9          # debug level (cmd line: -dddddddddd)
2
+check_via=yes     # (cmd. line: -v)
3
+dns=on           # (cmd. line: -r)
4
+rev_dns=yes      # (cmd. line: -R)
5
+fork=no          # (cmd. line: -D)
6
+#children=5
7
+log_stderror=yes # (cmd line: -E)
8
+#port=5080
9
+#listen=192.168.99.100
10
+loop_checks=1
11
+# for more info: sip_router -h
12
+
13
+#modules
14
+loadmodule "modules/print/print.so"
15
+loadmodule "modules/tm/tm.so"
16
+
17
+route{
18
+	#rewritehost("iptel.org");
19
+	log("trying forward to uri");
20
+#	forward(uri:host,uri:port);
21
+#	forward(127.0.0.1, 5090);
22
+	log("after forward");
23
+
24
+	if ( t_lookup_request()) {
25
+		print("\nFOUND REQUEST\n");
26
+		if ( method=="ACK" )	{
27
+			log("SER: ACK received -> t_release\n");
28
+			t_release();
29
+		} else {
30
+			t_retransmit_reply();
31
+			log("SER: yet another annoying retranmission\n");
32
+		};
33
+	} else {
34
+		print("\nbefore add transaction\n");
35
+		t_add_transaction();
36
+		print("\nafter add transaction\n");
37
+		if (method=="CANCEL") {
38
+			log("SER: new CANCEL\n");
39
+			# XXX ... it wants me to put status code in ""
40
+			t_send_reply( "200", "glad to cancel");
41
+		} else {
42
+		print("\nELSE if method\n");
43
+			log("SER: new transaction\n");
44
+			t_send_reply("100", "trying -- your call is important to us");
45
+		};
46
+		print("\nbefore rewrite host\n");
47
+		rewritehost("iptel.org");
48
+		# XXX ... it wants me to put port nr in ""
49
+		#t_forward("benetnash.fokus.gmd.de", "5080" );
50
+		#t_forward("iptel.org", "5060" );
51
+		print("\nbefore forward uri\n");
52
+		t_forward_uri();
53
+		# XXX ... it doesn't like default port numbers
54
+		# t_forward("fox.iptel.org" );
55
+		# XXX t_forward_uri ... not done yet
56
+	};
57
+		
58
+}
0 59
new file mode 100644
... ...
@@ -0,0 +1,50 @@
1
+debug=9          # debug level (cmd line: -dddddddddd)
2
+check_via=yes     # (cmd. line: -v)
3
+dns=on           # (cmd. line: -r)
4
+rev_dns=yes      # (cmd. line: -R)
5
+fork=no          # (cmd. line: -D)
6
+#children=5
7
+log_stderror=yes # (cmd line: -E)
8
+#port=5080
9
+#listen=192.168.99.100
10
+loop_checks=1
11
+# for more info: sip_router -h
12
+
13
+#modules
14
+loadmodule "modules/print/print.so"
15
+loadmodule "modules/tm/tm.so"
16
+
17
+route{
18
+	#rewritehost("iptel.org");
19
+#	forward(uri:host,uri:port);
20
+#	forward(127.0.0.1, 5090);
21
+
22
+	if ( t_lookup_request()) {
23
+		if ( method=="ACK" )	{
24
+			log("SER: ACK received -> t_release\n");
25
+			t_release();
26
+		} else {
27
+			t_retransmit_reply();
28
+#			log("SER: yet another annoying retranmission\n");
29
+		};
30
+	} else {
31
+		t_add_transaction();
32
+		if (method=="CANCEL") {
33
+			log("SER: new CANCEL\n");
34
+			# XXX ... it wants me to put status code in ""
35
+			t_send_reply( "200", "glad to cancel");
36
+		} else {
37
+			log("SER: new transaction\n");
38
+			t_send_reply("100", "trying -- your call is important to us");
39
+		};
40
+#		rewritehost("iptel.org");
41
+		# XXX ... it wants me to put port nr in ""
42
+		#t_forward("benetnash.fokus.gmd.de", "5080" );
43
+		#t_forward("iptel.org", "5060" );
44
+		t_forward_uri();
45
+		# XXX ... it doesn't like default port numbers
46
+		# t_forward("fox.iptel.org" );
47
+		# XXX t_forward_uri ... not done yet
48
+	};
49
+		
50
+}
... ...
@@ -240,7 +240,9 @@ again:
240 240
 	n=sendto(udp_sock, buf, len, 0, to, tolen);
241 241
 /*	n=sendto(udp_sock, buf, len, 0, &a2, sizeof(struct sockaddr_in) );*/
242 242
 	if (n==-1){
243
-		LOG(L_ERR, "ERROR: udp_send: sendto: %s\n", strerror(errno));
243
+		LOG(L_ERR, "ERROR: udp_send: sendto(sock,%x,%d,0,%x,%d): %s(%d)\n",
244
+				buf,len,to,tolen,
245
+				strerror(errno),errno);
244 246
 		if (errno==EINTR) goto again;
245 247
 		if (errno==EINVAL) LOG(L_CRIT,"CRITICAL: invalid sendtoparameters\n"
246 248
 			"one possible reason is the server is bound to localhost and\n"