Browse code

tcp_main.o: logging: DBG -> LM_DBG

Ovidiu Sas authored on 13/01/2015 15:18:20
Showing 1 changed files
... ...
@@ -982,7 +982,7 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su,
982 982
 		c->rcv.dst_port=ba->port_no;
983 983
 	}
984 984
 	print_ip("tcpconn_new: new tcp connection: ", &c->rcv.src_ip, "\n");
985
-	DBG(     "tcpconn_new: on port %d, type %d\n", c->rcv.src_port, type);
985
+	LM_DBG("on port %d, type %d\n", c->rcv.src_port, type);
986 986
 	init_tcp_req(&c->req, (char*)c+sizeof(struct tcp_connection), rd_b_size);
987 987
 	c->id=(*connection_id)++;
988 988
 	c->rcv.proto_reserved1=0; /* this will be filled before receive_message*/
... ...
@@ -1287,7 +1287,7 @@ inline static struct tcp_connection*  tcpconn_add(struct tcp_connection *c)
1287 1287
 		 *  of the add_alias would fail (e.g. first add_alias for 2 connections
1288 1288
 		 *   with the same destination but different src. ip*/
1289 1289
 		TCPCONN_UNLOCK;
1290
-		DBG("tcpconn_add: hashes: %d:%d:%d, %d\n",
1290
+		LM_DBG("hashes: %d:%d:%d, %d\n",
1291 1291
 												c->con_aliases[0].hash,
1292 1292
 												c->con_aliases[1].hash,
1293 1293
 												c->con_aliases[2].hash,
... ...
@@ -1372,14 +1372,14 @@ struct tcp_connection* _tcpconn_find(int id, struct ip_addr* ip, int port,
1372 1372
 	int is_local_ip_any;
1373 1373
 	
1374 1374
 #ifdef EXTRA_DEBUG
1375
-	DBG("tcpconn_find: %d  port %d\n",id, port);
1375
+	LM_DBG("%d  port %d\n",id, port);
1376 1376
 	if (ip) print_ip("tcpconn_find: ip ", ip, "\n");
1377 1377
 #endif
1378 1378
 	if (likely(id)){
1379 1379
 		hash=tcp_id_hash(id);
1380 1380
 		for (c=tcpconn_id_hash[hash]; c; c=c->id_next){
1381 1381
 #ifdef EXTRA_DEBUG
1382
-			DBG("c=%p, c->id=%d, port=%d\n",c, c->id, c->rcv.src_port);
1382
+			LM_DBG("c=%p, c->id=%d, port=%d\n", c, c->id, c->rcv.src_port);
1383 1383
 			print_ip("ip=", &c->rcv.src_ip, "\n");
1384 1384
 #endif
1385 1385
 			if ((id==c->id)&&(c->state!=S_CONN_BAD)) return c;
... ...
@@ -1389,7 +1389,7 @@ struct tcp_connection* _tcpconn_find(int id, struct ip_addr* ip, int port,
1389 1389
 		is_local_ip_any=ip_addr_any(l_ip);
1390 1390
 		for (a=tcpconn_aliases_hash[hash]; a; a=a->next){
1391 1391
 #ifdef EXTRA_DEBUG
1392
-			DBG("a=%p, c=%p, c->id=%d, alias port= %d port=%d\n", a, a->parent,
1392
+			LM_DBG("a=%p, c=%p, c->id=%d, alias port= %d port=%d\n", a, a->parent,
1393 1393
 					a->parent->id, a->port, a->parent->rcv.src_port);
1394 1394
 			print_ip("ip=",&a->parent->rcv.src_ip,"\n");
1395 1395
 #endif
... ...
@@ -1531,8 +1531,8 @@ inline static int _tcpconn_add_alias_unsafe(struct tcp_connection* c, int port,
1531 1531
 	}else goto error_not_found;
1532 1532
 ok:
1533 1533
 #ifdef EXTRA_DEBUG
1534
-	if (a) DBG("_tcpconn_add_alias_unsafe: alias already present\n");
1535
-	else   DBG("_tcpconn_add_alias_unsafe: alias port %d for hash %d, id %d\n",
1534
+	if (a) LM_DBG("alias already present\n");
1535
+	else   LM_DBG("alias port %d for hash %d, id %d\n",
1536 1536
 			port, hash, c->id);
1537 1537
 #endif
1538 1538
 	return 0;
... ...
@@ -1727,7 +1727,7 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
1727 1727
 		if (unlikely((dst->send_flags.f & SND_F_FORCE_CON_REUSE) ||
1728 1728
 						cfg_get(tcp, tcp_cfg, no_connect)))
1729 1729
 			return -1;
1730
-		DBG("tcp_send: no open tcp connection found, opening new one\n");
1730
+		LM_DBG("no open tcp connection found, opening new one\n");
1731 1731
 		/* create tcp connection */
1732 1732
 		if (likely(from==0)){
1733 1733
 			/* check to see if we have to use a specific source addr. */
... ...
@@ -2189,7 +2189,7 @@ static int tcpconn_send_put(struct tcp_connection* c, const char* buf,
2189 2189
 		/* check if this is not the same reader process holding
2190 2190
 		 *  c  and if so send directly on c->fd */
2191 2191
 		if (c->reader_pid==my_pid()){
2192
-			DBG("tcp_send: send from reader (%d (%d)), reusing fd\n",
2192
+			LM_DBG("send from reader (%d (%d)), reusing fd\n",
2193 2193
 					my_pid(), process_no);
2194 2194
 			fd=c->fd;
2195 2195
 			do_close_fd=0; /* don't close the fd on exit, it's in use */
... ...
@@ -2202,11 +2202,10 @@ static int tcpconn_send_put(struct tcp_connection* c, const char* buf,
2202 2202
 							((fd_cache_e=tcp_fd_cache_get(c))!=0))){
2203 2203
 			fd=fd_cache_e->fd;
2204 2204
 			do_close_fd=0;
2205
-			DBG("tcp_send: found fd in cache ( %d, %p, %d)\n",
2206
-					fd, c, fd_cache_e->id);
2205
+			LM_DBG("found fd in cache (%d, %p, %d)\n", fd, c, fd_cache_e->id);
2207 2206
 #endif /* TCP_FD_CACHE */
2208 2207
 		}else{
2209
-			DBG("tcp_send: tcp connection found (%p), acquiring fd\n", c);
2208
+			LM_DBG("tcp connection found (%p), acquiring fd\n", c);
2210 2209
 			/* get the fd */
2211 2210
 			response[0]=(long)c;
2212 2211
 			response[1]=CONN_GET_FD;
... ...
@@ -2216,7 +2215,7 @@ static int tcpconn_send_put(struct tcp_connection* c, const char* buf,
2216 2216
 				n=-1;
2217 2217
 				goto release_c;
2218 2218
 			}
2219
-			DBG("tcp_send, c= %p, n=%d\n", c, n);
2219
+			LM_DBG("c=%p, n=%d\n", c, n);
2220 2220
 			n=receive_fd(unix_tcp_sock, &tmp, sizeof(tmp), &fd, MSG_WAITALL);
2221 2221
 			if (unlikely(n<=0)){
2222 2222
 				LM_ERR("failed to get fd(receive_fd): %s (%d)\n",
... ...
@@ -2246,7 +2245,7 @@ static int tcpconn_send_put(struct tcp_connection* c, const char* buf,
2246 2246
 #endif /* TCP_FD_CACHE */
2247 2247
 				goto end;
2248 2248
 			}
2249
-			DBG("tcp_send: after receive_fd: c= %p n=%d fd=%d\n",c, n, fd);
2249
+			LM_DBG("after receive_fd: c= %p n=%d fd=%d\n",c, n, fd);
2250 2250
 		}
2251 2251
 	
2252 2252
 #ifdef USE_TLS
... ...
@@ -2425,7 +2424,7 @@ static int tcpconn_do_send(int fd, struct tcp_connection* c,
2425 2425
 	int enable_write_watch;
2426 2426
 #endif /* TCP_ASYNC */
2427 2427
 
2428
-	DBG("tcp_send: sending...\n");
2428
+	LM_DBG("sending...\n");
2429 2429
 	*resp = CONN_NOP;
2430 2430
 	if (likely(!locked)) lock_get(&c->write_lock);
2431 2431
 	/* update connection send flags with the current ones */
... ...
@@ -2459,8 +2458,8 @@ static int tcpconn_do_send(int fd, struct tcp_connection* c,
2459 2459
 	if (likely(!locked)) lock_release(&c->write_lock);
2460 2460
 #endif /* TCP_ASYNC */
2461 2461
 	
2462
-	DBG("tcp_send: after real write: c= %p n=%d fd=%d\n",c, n, fd);
2463
-	DBG("tcp_send: buf=\n%.*s\n", (int)len, buf);
2462
+	LM_DBG("after real write: c= %p n=%d fd=%d\n",c, n, fd);
2463
+	LM_DBG("buf=\n%.*s\n", (int)len, buf);
2464 2464
 	if (unlikely(n<(int)len)){
2465 2465
 #ifdef TCP_ASYNC
2466 2466
 		if (cfg_get(tcp, tcp_cfg, async) &&
... ...
@@ -2605,8 +2604,8 @@ static int tcpconn_1st_send(int fd, struct tcp_connection* c,
2605 2605
 		   ENOTCONN appears on newer FreeBSD versions (non-blocking socket,
2606 2606
 		   connect() & send immediately) */
2607 2607
 		if ((n>=0) || errno==EAGAIN || errno==EWOULDBLOCK || errno==ENOTCONN){
2608
-			DBG("pending write on new connection %p "
2609
-				" (%d/%d bytes written)\n", c, n, len);
2608
+			LM_DBG("pending write on new connection %p "
2609
+				"(%d/%d bytes written)\n", c, n, len);
2610 2610
 			if (unlikely(n<0)) n=0;
2611 2611
 			else{
2612 2612
 				if (likely(c->state == S_CONN_CONNECT))
... ...
@@ -2712,7 +2711,7 @@ int tcp_init(struct socket_info* sock_info)
2712 2712
 		LM_ERR("could no init sockaddr_union\n");
2713 2713
 		goto error;
2714 2714
 	}
2715
-	DBG("tcp_init: added %s\n", su2a(addr, sizeof(*addr)));
2715
+	LM_DBG("added %s\n", su2a(addr, sizeof(*addr)));
2716 2716
 	sock_info->socket=socket(AF2PF(addr->s.sa_family), SOCK_STREAM, 0);
2717 2717
 	if (sock_info->socket==-1){
2718 2718
 		LM_ERR("tcp_init: socket: %s\n", strerror(errno));
... ...
@@ -2852,9 +2851,8 @@ inline static void tcpconn_close_main_fd(struct tcp_connection* tcpconn)
2852 2852
 inline static int tcpconn_chld_put(struct tcp_connection* tcpconn)
2853 2853
 {
2854 2854
 	if (unlikely(atomic_dec_and_test(&tcpconn->refcnt))){
2855
-		DBG("tcpconn_chld_put: destroying connection %p (%d, %d) "
2856
-				"flags %04x\n", tcpconn, tcpconn->id,
2857
-				tcpconn->s, tcpconn->flags);
2855
+		LM_DBG("destroying connection %p (%d, %d) flags %04x\n",
2856
+				tcpconn, tcpconn->id, tcpconn->s, tcpconn->flags);
2858 2857
 		/* sanity checks */
2859 2858
 		membar_read_atomic_op(); /* make sure we see the current flags */
2860 2859
 		if (unlikely(!(tcpconn->flags & F_CONN_FD_CLOSED) ||
... ...
@@ -2877,9 +2875,8 @@ inline static int tcpconn_chld_put(struct tcp_connection* tcpconn)
2877 2877
  */
2878 2878
 inline static void tcpconn_destroy(struct tcp_connection* tcpconn)
2879 2879
 {
2880
-		DBG("tcpconn_destroy: destroying connection %p (%d, %d) "
2881
-				"flags %04x\n", tcpconn, tcpconn->id,
2882
-				tcpconn->s, tcpconn->flags);
2880
+		LM_DBG("destroying connection %p (%d, %d) flags %04x\n",
2881
+				tcpconn, tcpconn->id, tcpconn->s, tcpconn->flags);
2883 2882
 		if (unlikely(tcpconn->flags & F_CONN_HASHED)){
2884 2883
 			LM_CRIT("called with hashed connection (%p)\n", tcpconn);
2885 2884
 			/* try to continue */
... ...
@@ -3211,8 +3208,8 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
3211 3211
 	if (unlikely(bytes<(int)sizeof(response))){
3212 3212
 		if (bytes==0){
3213 3213
 			/* EOF -> bad, child has died */
3214
-			DBG("DBG: handle_tcp_child: dead tcp child %d (pid %ld, no %d)"
3215
-					" (shutting down?)\n", (int)(tcp_c-&tcp_children[0]), 
3214
+			LM_DBG("dead tcp child %d (pid %ld, no %d) (shutting down?)\n",
3215
+					(int)(tcp_c-&tcp_children[0]), 
3216 3216
 					(long)tcp_c->pid, tcp_c->proc_no );
3217 3217
 			/* don't listen on it any more */
3218 3218
 			io_watch_del(&io_h, tcp_c->unix_sock, fd_i, 0); 
... ...
@@ -3239,7 +3236,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
3239 3239
 		}
3240 3240
 	}
3241 3241
 	
3242
-	DBG("handle_tcp_child: reader response= %lx, %ld from %d \n",
3242
+	LM_DBG("reader response= %lx, %ld from %d \n",
3243 3243
 					response[0], response[1], (int)(tcp_c-&tcp_children[0]));
3244 3244
 	cmd=response[1];
3245 3245
 	tcpconn=(struct tcp_connection*)response[0];
... ...
@@ -3290,9 +3287,8 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
3290 3290
 			if (unlikely(cfg_get(tcp, tcp_cfg, async) && 
3291 3291
 							_wbufq_non_empty(tcpconn) )){
3292 3292
 				if (unlikely(TICKS_GE(t, tcpconn->wbuf_q.wr_timeout))){
3293
-					DBG("handle_tcp_child: wr. timeout on CONN_RELEASE for %p "
3294
-							"refcnt= %d\n", tcpconn,
3295
-							atomic_get(&tcpconn->refcnt));
3293
+					LM_DBG("wr. timeout on CONN_RELEASE for %p refcnt= %d\n",
3294
+							tcpconn, atomic_get(&tcpconn->refcnt));
3296 3295
 					/* timeout */
3297 3296
 					if (unlikely(tcpconn->state==S_CONN_CONNECT)){
3298 3297
 #ifdef USE_DST_BLACKLIST
... ...
@@ -3367,7 +3363,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
3367 3367
 #endif /* TCP_ASYNC */
3368 3368
 				break;
3369 3369
 			}
3370
-			DBG("handle_tcp_child: CONN_RELEASE  %p refcnt= %d\n", 
3370
+			LM_DBG("CONN_RELEASE  %p refcnt= %d\n", 
3371 3371
 							tcpconn, atomic_get(&tcpconn->refcnt));
3372 3372
 			break;
3373 3373
 		case CONN_ERROR:
... ...
@@ -3445,8 +3441,8 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3445 3445
 		/* too few bytes read */
3446 3446
 		if (bytes==0){
3447 3447
 			/* EOF -> bad, child has died */
3448
-			DBG("DBG: handle_ser_child: dead child %d, pid %d"
3449
-					" (shutting down?)\n", (int)(p-&pt[0]), p->pid);
3448
+			LM_DBG("dead child %d, pid %d (shutting down?)\n",
3449
+					(int)(p-&pt[0]), p->pid);
3450 3450
 			/* don't listen on it any more */
3451 3451
 			io_watch_del(&io_h, p->unix_sock, fd_i, 0);
3452 3452
 			goto error; /* child dead => no further io events from it */
... ...
@@ -3473,7 +3469,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3473 3473
 		}
3474 3474
 	}
3475 3475
 	ret=1; /* something was received, there might be more queued */
3476
-	DBG("handle_ser_child: read response= %lx, %ld, fd %d from %d (%d)\n",
3476
+	LM_DBG("read response= %lx, %ld, fd %d from %d (%d)\n",
3477 3477
 					response[0], response[1], fd, (int)(p-&pt[0]), p->pid);
3478 3478
 	cmd=response[1];
3479 3479
 	tcpconn=(struct tcp_connection*)response[0];
... ...
@@ -3617,9 +3613,8 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
3617 3617
 					local_timer_reinit(&tcpconn->timer);
3618 3618
 					local_timer_add(&tcp_main_ltimer, &tcpconn->timer,
3619 3619
 										tcpconn->wbuf_q.wr_timeout-t, t);
3620
-					DBG("tcp_main: handle_ser_child: CONN_QUEUED_WRITE; %p "
3621
-							"timeout adjusted to %d s\n", tcpconn, 
3622
-							TICKS_TO_S(tcpconn->wbuf_q.wr_timeout-t));
3620
+					LM_DBG("CONN_QUEUED_WRITE; %p timeout adjusted to %d s\n",
3621
+							tcpconn, TICKS_TO_S(tcpconn->wbuf_q.wr_timeout-t));
3623 3622
 				}
3624 3623
 				if (!(tcpconn->flags & F_CONN_WRITE_W)){
3625 3624
 					tcpconn->flags|=F_CONN_WRITE_W;
... ...
@@ -3805,8 +3800,8 @@ inline static int send2child(struct tcp_connection* tcpconn)
3805 3805
 	tcp_children[idx].busy++;
3806 3806
 	tcp_children[idx].n_reqs++;
3807 3807
 	if (unlikely(min_busy)){
3808
-		DBG("WARNING: send2child: no free tcp receiver, "
3809
-				" connection passed to the least busy one (%d)\n",
3808
+		LM_DBG("WARNING: no free tcp receiver, "
3809
+				"connection passed to the least busy one (%d)\n",
3810 3810
 				min_busy);
3811 3811
 	}
3812 3812
 	LM_DBG("selected tcp worker %d %d(%ld) for activity on [%s], %p\n",
... ...
@@ -3965,7 +3960,7 @@ static inline int handle_new_connect(struct socket_info* si)
3965 3965
 		/* prepare it for passing to a child */
3966 3966
 		tcpconn->flags|=F_CONN_READER;
3967 3967
 		tcpconn_add(tcpconn);
3968
-		DBG("handle_new_connect: new connection from %s: %p %d flags: %04x\n",
3968
+		LM_DBG("new connection from %s: %p %d flags: %04x\n",
3969 3969
 			su2a(&su, sizeof(su)), tcpconn, tcpconn->s, tcpconn->flags);
3970 3970
 		if(unlikely(send2child(tcpconn)<0)){
3971 3971
 			tcpconn->flags&=~F_CONN_READER;
... ...
@@ -4128,7 +4123,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
4128 4128
 #ifdef TCP_ASYNC
4129 4129
 send_to_child:
4130 4130
 #endif
4131
-		DBG("tcp: DBG: sending to child, events %x\n", ev);
4131
+		LM_DBG("sending to child, events %x\n", ev);
4132 4132
 #ifdef POLLRDHUP
4133 4133
 		tcpconn->flags|=((int)!(ev & (POLLRDHUP|POLLHUP|POLLERR)) -1) &
4134 4134
 							F_CONN_EOF_SEEN;
... ...
@@ -4225,7 +4220,7 @@ static ticks_t tcpconn_main_timeout(ticks_t t, struct timer_ln* tl, void* data)
4225 4225
 	/* or (struct tcp...*)(tl-offset(c->timer)) */
4226 4226
 	
4227 4227
 #ifdef TCP_ASYNC
4228
-	DBG( "tcp_main: entering timer for %p (ticks=%d, timeout=%d (%d s), "
4228
+	LM_DBG("entering timer for %p (ticks=%d, timeout=%d (%d s), "
4229 4229
 			"wr_timeout=%d (%d s)), write queue: %d bytes\n",
4230 4230
 			c, t, c->timeout, TICKS_TO_S(c->timeout-t),
4231 4231
 			c->wbuf_q.wr_timeout, TICKS_TO_S(c->wbuf_q.wr_timeout-t),
... ...
@@ -4271,7 +4266,7 @@ static ticks_t tcpconn_main_timeout(ticks_t t, struct timer_ln* tl, void* data)
4271 4271
 	TCP_EV_IDLE_CONN_CLOSED(0, &c->rcv);
4272 4272
 	TCP_STATS_CON_TIMEOUT();
4273 4273
 #endif /* TCP_ASYNC */
4274
-	DBG("tcp_main: timeout for %p\n", c);
4274
+	LM_DBG("timeout for %p\n", c);
4275 4275
 	if (likely(c->flags & F_CONN_HASHED)){
4276 4276
 		c->flags&=~(F_CONN_HASHED|F_CONN_MAIN_TIMER);
4277 4277
 		c->state=S_CONN_BAD;