Browse code

tcp_read.c: logging: convert LOG to LM_*

Ovidiu Sas authored on 04/10/2014 02:53:34
Showing 1 changed files
... ...
@@ -191,7 +191,7 @@ int tcp_http11_continue(struct tcp_connection *c)
191 191
 	{
192 192
 		init_dst_from_rcv(&dst, &c->rcv);
193 193
 		if (tcp_send(&dst, 0, HTTP11CONTINUE, HTTP11CONTINUE_LEN) < 0) {
194
-			LOG(L_ERR, "HTTP/1.1 continue failed\n");
194
+			LM_ERR("HTTP/1.1 continue failed\n");
195 195
 		}
196 196
 	}
197 197
 	/* check for Transfer-Encoding header */
... ...
@@ -337,7 +337,7 @@ int tcp_read(struct tcp_connection *c, int* flags)
337 337
 	bytes_free=r->b_size- (int)(r->pos - r->buf);
338 338
 	
339 339
 	if (unlikely(bytes_free==0)){
340
-		LOG(L_ERR, "ERROR: tcp_read: buffer overrun, dropping\n");
340
+		LM_ERR("buffer overrun, dropping\n");
341 341
 		r->error=TCP_REQ_OVERRUN;
342 342
 		return -1;
343 343
 	}
... ...
@@ -798,7 +798,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
798 798
 					case ' ':
799 799
 					case '\t': /* FIXME: check if line contains only WS */
800 800
 						if(r->content_len<0) {
801
-							LOG(L_ERR, "bad Content-Length header value %d in"
801
+							LM_ERR("bad Content-Length header value %d in"
802 802
 									" state %d\n", r->content_len, r->state);
803 803
 							r->content_len=0;
804 804
 							r->error=TCP_REQ_BAD_LEN;
... ...
@@ -810,7 +810,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
810 810
 					case '\n':
811 811
 						/* end of line, parse successful */
812 812
 						if(r->content_len<0) {
813
-							LOG(L_ERR, "bad Content-Length header value %d in"
813
+							LM_ERR("bad Content-Length header value %d in"
814 814
 									" state %d\n", r->content_len, r->state);
815 815
 							r->content_len=0;
816 816
 							r->error=TCP_REQ_BAD_LEN;
... ...
@@ -820,8 +820,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
820 820
 						r->flags|=F_TCP_REQ_HAS_CLEN;
821 821
 						break;
822 822
 					default:
823
-						LOG(L_ERR, "ERROR: tcp_read_headers: bad "
824
-								"Content-Length header value, unexpected "
823
+						LM_ERR("bad Content-Length header value, unexpected "
825 824
 								"char %c in state %d\n", *p, r->state);
826 825
 						r->state=H_SKIP; /* try to find another?*/
827 826
 				}
... ...
@@ -990,8 +989,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
990 990
 #endif
991 991
 
992 992
 			default:
993
-				LOG(L_CRIT, "BUG: tcp_read_headers: unexpected state %d\n",
994
-						r->state);
993
+				LM_CRIT("unexpected state %d\n", r->state);
995 994
 				abort();
996 995
 		}
997 996
 	}
... ...
@@ -1296,10 +1294,10 @@ again:
1296 1296
 			}
1297 1297
 		}
1298 1298
 		if (unlikely(req->error!=TCP_REQ_OK)){
1299
-			LOG(L_ERR,"ERROR: tcp_read_req: bad request, state=%d, error=%d "
1300
-					  "buf:\n%.*s\nparsed:\n%.*s\n", req->state, req->error,
1301
-					  (int)(req->pos-req->buf), req->buf,
1302
-					  (int)(req->parsed-req->start), req->start);
1299
+			LM_ERR("bad request, state=%d, error=%d buf:\n%.*s\nparsed:\n%.*s\n",
1300
+					req->state, req->error,
1301
+					(int)(req->pos-req->buf), req->buf,
1302
+					(int)(req->parsed-req->start), req->start);
1303 1303
 			DBG("- received from: port %d\n", con->rcv.src_port);
1304 1304
 			print_ip("- received from: ip ",&con->rcv.src_ip, "\n");
1305 1305
 			resp=CONN_ERROR;
... ...
@@ -1321,8 +1319,7 @@ again:
1321 1321
 			}else{
1322 1322
 				if (cfg_get(tcp, tcp_cfg, accept_no_cl)==0) {
1323 1323
 					req->error=TCP_REQ_BAD_LEN;
1324
-					LOG(L_ERR, "ERROR: tcp_read_req: content length not present or"
1325
-						" unparsable\n");
1324
+					LM_ERR("content length not present or unparsable\n");
1326 1325
 					resp=CONN_ERROR;
1327 1326
 					goto end_req;
1328 1327
 				}
... ...
@@ -1353,7 +1350,7 @@ again:
1353 1353
 				init_dst_from_rcv(&dst, &con->rcv);
1354 1354
 
1355 1355
 				if (tcp_send(&dst, 0, CRLF, CRLF_LEN) < 0) {
1356
-					LOG(L_ERR, "CRLF ping: tcp_send() failed\n");
1356
+					LM_ERR("CRLF ping: tcp_send() failed\n");
1357 1357
 				}
1358 1358
 				ret = 0;
1359 1359
 			} else if (unlikely(req->state==H_STUN_END)) {
... ...
@@ -1447,7 +1444,7 @@ void release_tcpconn(struct tcp_connection* c, long state, int unix_sock)
1447 1447
 		response[1]=state;
1448 1448
 		
1449 1449
 		if (tsend_stream(unix_sock, (char*)response, sizeof(response), -1)<=0)
1450
-			LOG(L_ERR, "ERROR: release_tcpconn: tsend_stream failed\n");
1450
+			LM_ERR("tsend_stream failed\n");
1451 1451
 }
1452 1452
 
1453 1453
 
... ...
@@ -1465,7 +1462,7 @@ static ticks_t tcpconn_read_timeout(ticks_t t, struct timer_ln* tl, void* data)
1465 1465
 	}
1466 1466
 	/* if conn->state is ERROR or BAD => force timeout too */
1467 1467
 	if (unlikely(io_watch_del(&io_w, c->fd, -1, IO_FD_CLOSING)<0)){
1468
-		LOG(L_ERR, "ERROR: tcpconn_read_timeout: io_watch_del failed for %p"
1468
+		LM_ERR("io_watch_del failed for %p"
1469 1469
 					" id %d fd %d, state %d, flags %x, main fd %d\n",
1470 1470
 					c, c->id, c->fd, c->state, c->flags, c->s);
1471 1471
 	}
... ...
@@ -1514,37 +1511,33 @@ again:
1514 1514
 					break;
1515 1515
 				}else if (errno == EINTR) goto again;
1516 1516
 				else{
1517
-					LOG(L_CRIT,"BUG: tcp_receive: handle_io: read_fd: %s \n",
1518
-							strerror(errno));
1517
+					LM_CRIT("read_fd: %s \n", strerror(errno));
1519 1518
 						abort(); /* big error*/
1520 1519
 				}
1521 1520
 			}
1522 1521
 			if (unlikely(n==0)){
1523
-				LOG(L_ERR, "WARNING: tcp_receive: handle_io: 0 bytes read\n");
1522
+				LM_ERR("0 bytes read\n");
1524 1523
 				goto error;
1525 1524
 			}
1526 1525
 			if (unlikely(con==0)){
1527
-					LOG(L_CRIT, "BUG: tcp_receive: handle_io null pointer\n");
1526
+					LM_CRIT("null pointer\n");
1528 1527
 					goto error;
1529 1528
 			}
1530 1529
 			con->fd=s;
1531 1530
 			if (unlikely(s==-1)) {
1532
-				LOG(L_ERR, "ERROR: tcp_receive: handle_io: read_fd:"
1533
-									"no fd read\n");
1531
+				LM_ERR("read_fd: no fd read\n");
1534 1532
 				goto con_error;
1535 1533
 			}
1536 1534
 			con->reader_pid=my_pid();
1537 1535
 			if (unlikely(con==tcp_conn_lst)){
1538
-				LOG(L_CRIT, "BUG: tcp_receive: handle_io: duplicate"
1539
-							" connection received: %p, id %d, fd %d, refcnt %d"
1536
+				LM_CRIT("duplicate connection received: %p, id %d, fd %d, refcnt %d"
1540 1537
 							" state %d (n=%d)\n", con, con->id, con->fd,
1541 1538
 							atomic_get(&con->refcnt), con->state, n);
1542 1539
 				goto con_error;
1543 1540
 				break; /* try to recover */
1544 1541
 			}
1545 1542
 			if (unlikely(con->state==S_CONN_BAD)){
1546
-				LOG(L_WARN, "WARNING: tcp_receive: handle_io: received an"
1547
-							" already bad connection: %p id %d refcnt %d\n",
1543
+				LM_WARN("received an already bad connection: %p id %d refcnt %d\n",
1548 1544
 							con, con->id, atomic_get(&con->refcnt));
1549 1545
 				goto con_error;
1550 1546
 			}
... ...
@@ -1584,8 +1577,7 @@ repeat_1st_read:
1584 1584
 			local_timer_add(&tcp_reader_ltimer, &con->timer,
1585 1585
 								S_TO_TICKS(TCP_CHILD_TIMEOUT), t);
1586 1586
 			if (unlikely(io_watch_add(&io_w, s, POLLIN, F_TCPCONN, con)<0)){
1587
-				LOG(L_CRIT, "ERROR: tcpconn_receive: handle_io: io_watch_add "
1588
-							"failed for %p id %d fd %d, state %d, flags %x,"
1587
+				LM_CRIT("io_watch_add failed for %p id %d fd %d, state %d, flags %x,"
1589 1588
 							" main fd %d, refcnt %d\n",
1590 1589
 							con, con->id, con->fd, con->state, con->flags,
1591 1590
 							con->s, atomic_get(&con->refcnt));
... ...
@@ -1599,8 +1591,7 @@ repeat_1st_read:
1599 1599
 			if (unlikely(con->state==S_CONN_BAD)){
1600 1600
 				resp=CONN_ERROR;
1601 1601
 				if (!(con->send_flags.f & SND_F_CON_CLOSE))
1602
-					LOG(L_WARN, "WARNING: tcp_receive: handle_io: F_TCPCONN"
1603
-							" connection marked as bad: %p id %d refcnt %d\n",
1602
+					LM_WARN("F_TCPCONN connection marked as bad: %p id %d refcnt %d\n",
1604 1603
 							con, con->id, atomic_get(&con->refcnt));
1605 1604
 				goto read_error;
1606 1605
 			}
... ...
@@ -1620,8 +1611,7 @@ read_error:
1620 1620
 				ret=-1; /* some error occured */
1621 1621
 				if (unlikely(io_watch_del(&io_w, con->fd, idx,
1622 1622
 											IO_FD_CLOSING) < 0)){
1623
-					LOG(L_CRIT, "ERROR: tcpconn_receive: handle_io: "
1624
-							"io_watch_del failed for %p id %d fd %d,"
1623
+					LM_CRIT("io_watch_del failed for %p id %d fd %d,"
1625 1624
 							" state %d, flags %x, main fd %d, refcnt %d\n",
1626 1625
 							con, con->id, con->fd, con->state,
1627 1626
 							con->flags, con->s, atomic_get(&con->refcnt));
... ...
@@ -1645,12 +1635,12 @@ read_error:
1645 1645
 			}
1646 1646
 			break;
1647 1647
 		case F_NONE:
1648
-			LOG(L_CRIT, "BUG: handle_io: empty fd map %p (%d): "
1649
-						"{%d, %d, %p}\n", fm, (int)(fm-io_w.fd_hash),
1648
+			LM_CRIT("empty fd map %p (%d): {%d, %d, %p}\n",
1649
+						fm, (int)(fm-io_w.fd_hash),
1650 1650
 						fm->fd, fm->type, fm->data);
1651 1651
 			goto error;
1652 1652
 		default:
1653
-			LOG(L_CRIT, "BUG: handle_io: uknown fd type %d\n", fm->type); 
1653
+			LM_CRIT("uknown fd type %d\n", fm->type); 
1654 1654
 			goto error;
1655 1655
 	}
1656 1656
 	
... ...
@@ -1690,8 +1680,7 @@ void tcp_receive_loop(int unix_sock)
1690 1690
 		goto error;
1691 1691
 	/* add the unix socket */
1692 1692
 	if (io_watch_add(&io_w, tcpmain_sock, POLLIN,  F_TCPMAIN, 0)<0){
1693
-		LOG(L_CRIT, "ERROR: tcp_receive_loop: init: failed to add socket "
1694
-							" to the fd list\n");
1693
+		LM_CRIT("failed to add socket to the fd list\n");
1695 1694
 		goto error;
1696 1695
 	}
1697 1696
 
... ...
@@ -1753,14 +1742,13 @@ void tcp_receive_loop(int unix_sock)
1753 1753
 			break;
1754 1754
 #endif
1755 1755
 		default:
1756
-			LOG(L_CRIT, "BUG: tcp_receive_loop: no support for poll method "
1757
-					" %s (%d)\n", 
1756
+			LM_CRIT("no support for poll method %s (%d)\n", 
1758 1757
 					poll_method_name(io_w.poll_method), io_w.poll_method);
1759 1758
 			goto error;
1760 1759
 	}
1761 1760
 error:
1762 1761
 	destroy_io_wait(&io_w);
1763
-	LOG(L_CRIT, "ERROR: tcp_receive_loop: exiting...");
1762
+	LM_CRIT("exiting...");
1764 1763
 	exit(-1);
1765 1764
 }
1766 1765