[sr-dev] git:master: tcp_read.c: logging: convert LOG to LM_*
Ovidiu Sas
osas at voipembedded.com
Sat Oct 4 04:53:40 CEST 2014
Module: sip-router
Branch: master
Commit: 8a1f2eded885cb7f2d73ebb1ea46f3a320efa742
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8a1f2eded885cb7f2d73ebb1ea46f3a320efa742
Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at voipembedded.com>
Date: Fri Oct 3 22:53:34 2014 -0400
tcp_read.c: logging: convert LOG to LM_*
---
tcp_read.c | 70 ++++++++++++++++++++++++-----------------------------------
1 files changed, 29 insertions(+), 41 deletions(-)
diff --git a/tcp_read.c b/tcp_read.c
index 925bd99..768f17c 100644
--- a/tcp_read.c
+++ b/tcp_read.c
@@ -191,7 +191,7 @@ int tcp_http11_continue(struct tcp_connection *c)
{
init_dst_from_rcv(&dst, &c->rcv);
if (tcp_send(&dst, 0, HTTP11CONTINUE, HTTP11CONTINUE_LEN) < 0) {
- LOG(L_ERR, "HTTP/1.1 continue failed\n");
+ LM_ERR("HTTP/1.1 continue failed\n");
}
}
/* check for Transfer-Encoding header */
@@ -337,7 +337,7 @@ int tcp_read(struct tcp_connection *c, int* flags)
bytes_free=r->b_size- (int)(r->pos - r->buf);
if (unlikely(bytes_free==0)){
- LOG(L_ERR, "ERROR: tcp_read: buffer overrun, dropping\n");
+ LM_ERR("buffer overrun, dropping\n");
r->error=TCP_REQ_OVERRUN;
return -1;
}
@@ -798,7 +798,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
case ' ':
case '\t': /* FIXME: check if line contains only WS */
if(r->content_len<0) {
- LOG(L_ERR, "bad Content-Length header value %d in"
+ LM_ERR("bad Content-Length header value %d in"
" state %d\n", r->content_len, r->state);
r->content_len=0;
r->error=TCP_REQ_BAD_LEN;
@@ -810,7 +810,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
case '\n':
/* end of line, parse successful */
if(r->content_len<0) {
- LOG(L_ERR, "bad Content-Length header value %d in"
+ LM_ERR("bad Content-Length header value %d in"
" state %d\n", r->content_len, r->state);
r->content_len=0;
r->error=TCP_REQ_BAD_LEN;
@@ -820,8 +820,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
r->flags|=F_TCP_REQ_HAS_CLEN;
break;
default:
- LOG(L_ERR, "ERROR: tcp_read_headers: bad "
- "Content-Length header value, unexpected "
+ LM_ERR("bad Content-Length header value, unexpected "
"char %c in state %d\n", *p, r->state);
r->state=H_SKIP; /* try to find another?*/
}
@@ -990,8 +989,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
#endif
default:
- LOG(L_CRIT, "BUG: tcp_read_headers: unexpected state %d\n",
- r->state);
+ LM_CRIT("unexpected state %d\n", r->state);
abort();
}
}
@@ -1296,10 +1294,10 @@ again:
}
}
if (unlikely(req->error!=TCP_REQ_OK)){
- LOG(L_ERR,"ERROR: tcp_read_req: bad request, state=%d, error=%d "
- "buf:\n%.*s\nparsed:\n%.*s\n", req->state, req->error,
- (int)(req->pos-req->buf), req->buf,
- (int)(req->parsed-req->start), req->start);
+ LM_ERR("bad request, state=%d, error=%d buf:\n%.*s\nparsed:\n%.*s\n",
+ req->state, req->error,
+ (int)(req->pos-req->buf), req->buf,
+ (int)(req->parsed-req->start), req->start);
DBG("- received from: port %d\n", con->rcv.src_port);
print_ip("- received from: ip ",&con->rcv.src_ip, "\n");
resp=CONN_ERROR;
@@ -1321,8 +1319,7 @@ again:
}else{
if (cfg_get(tcp, tcp_cfg, accept_no_cl)==0) {
req->error=TCP_REQ_BAD_LEN;
- LOG(L_ERR, "ERROR: tcp_read_req: content length not present or"
- " unparsable\n");
+ LM_ERR("content length not present or unparsable\n");
resp=CONN_ERROR;
goto end_req;
}
@@ -1353,7 +1350,7 @@ again:
init_dst_from_rcv(&dst, &con->rcv);
if (tcp_send(&dst, 0, CRLF, CRLF_LEN) < 0) {
- LOG(L_ERR, "CRLF ping: tcp_send() failed\n");
+ LM_ERR("CRLF ping: tcp_send() failed\n");
}
ret = 0;
} else if (unlikely(req->state==H_STUN_END)) {
@@ -1447,7 +1444,7 @@ void release_tcpconn(struct tcp_connection* c, long state, int unix_sock)
response[1]=state;
if (tsend_stream(unix_sock, (char*)response, sizeof(response), -1)<=0)
- LOG(L_ERR, "ERROR: release_tcpconn: tsend_stream failed\n");
+ LM_ERR("tsend_stream failed\n");
}
@@ -1465,7 +1462,7 @@ static ticks_t tcpconn_read_timeout(ticks_t t, struct timer_ln* tl, void* data)
}
/* if conn->state is ERROR or BAD => force timeout too */
if (unlikely(io_watch_del(&io_w, c->fd, -1, IO_FD_CLOSING)<0)){
- LOG(L_ERR, "ERROR: tcpconn_read_timeout: io_watch_del failed for %p"
+ LM_ERR("io_watch_del failed for %p"
" id %d fd %d, state %d, flags %x, main fd %d\n",
c, c->id, c->fd, c->state, c->flags, c->s);
}
@@ -1514,37 +1511,33 @@ again:
break;
}else if (errno == EINTR) goto again;
else{
- LOG(L_CRIT,"BUG: tcp_receive: handle_io: read_fd: %s \n",
- strerror(errno));
+ LM_CRIT("read_fd: %s \n", strerror(errno));
abort(); /* big error*/
}
}
if (unlikely(n==0)){
- LOG(L_ERR, "WARNING: tcp_receive: handle_io: 0 bytes read\n");
+ LM_ERR("0 bytes read\n");
goto error;
}
if (unlikely(con==0)){
- LOG(L_CRIT, "BUG: tcp_receive: handle_io null pointer\n");
+ LM_CRIT("null pointer\n");
goto error;
}
con->fd=s;
if (unlikely(s==-1)) {
- LOG(L_ERR, "ERROR: tcp_receive: handle_io: read_fd:"
- "no fd read\n");
+ LM_ERR("read_fd: no fd read\n");
goto con_error;
}
con->reader_pid=my_pid();
if (unlikely(con==tcp_conn_lst)){
- LOG(L_CRIT, "BUG: tcp_receive: handle_io: duplicate"
- " connection received: %p, id %d, fd %d, refcnt %d"
+ LM_CRIT("duplicate connection received: %p, id %d, fd %d, refcnt %d"
" state %d (n=%d)\n", con, con->id, con->fd,
atomic_get(&con->refcnt), con->state, n);
goto con_error;
break; /* try to recover */
}
if (unlikely(con->state==S_CONN_BAD)){
- LOG(L_WARN, "WARNING: tcp_receive: handle_io: received an"
- " already bad connection: %p id %d refcnt %d\n",
+ LM_WARN("received an already bad connection: %p id %d refcnt %d\n",
con, con->id, atomic_get(&con->refcnt));
goto con_error;
}
@@ -1584,8 +1577,7 @@ repeat_1st_read:
local_timer_add(&tcp_reader_ltimer, &con->timer,
S_TO_TICKS(TCP_CHILD_TIMEOUT), t);
if (unlikely(io_watch_add(&io_w, s, POLLIN, F_TCPCONN, con)<0)){
- LOG(L_CRIT, "ERROR: tcpconn_receive: handle_io: io_watch_add "
- "failed for %p id %d fd %d, state %d, flags %x,"
+ LM_CRIT("io_watch_add failed for %p id %d fd %d, state %d, flags %x,"
" main fd %d, refcnt %d\n",
con, con->id, con->fd, con->state, con->flags,
con->s, atomic_get(&con->refcnt));
@@ -1599,8 +1591,7 @@ repeat_1st_read:
if (unlikely(con->state==S_CONN_BAD)){
resp=CONN_ERROR;
if (!(con->send_flags.f & SND_F_CON_CLOSE))
- LOG(L_WARN, "WARNING: tcp_receive: handle_io: F_TCPCONN"
- " connection marked as bad: %p id %d refcnt %d\n",
+ LM_WARN("F_TCPCONN connection marked as bad: %p id %d refcnt %d\n",
con, con->id, atomic_get(&con->refcnt));
goto read_error;
}
@@ -1620,8 +1611,7 @@ read_error:
ret=-1; /* some error occured */
if (unlikely(io_watch_del(&io_w, con->fd, idx,
IO_FD_CLOSING) < 0)){
- LOG(L_CRIT, "ERROR: tcpconn_receive: handle_io: "
- "io_watch_del failed for %p id %d fd %d,"
+ LM_CRIT("io_watch_del failed for %p id %d fd %d,"
" state %d, flags %x, main fd %d, refcnt %d\n",
con, con->id, con->fd, con->state,
con->flags, con->s, atomic_get(&con->refcnt));
@@ -1645,12 +1635,12 @@ read_error:
}
break;
case F_NONE:
- LOG(L_CRIT, "BUG: handle_io: empty fd map %p (%d): "
- "{%d, %d, %p}\n", fm, (int)(fm-io_w.fd_hash),
+ LM_CRIT("empty fd map %p (%d): {%d, %d, %p}\n",
+ fm, (int)(fm-io_w.fd_hash),
fm->fd, fm->type, fm->data);
goto error;
default:
- LOG(L_CRIT, "BUG: handle_io: uknown fd type %d\n", fm->type);
+ LM_CRIT("uknown fd type %d\n", fm->type);
goto error;
}
@@ -1690,8 +1680,7 @@ void tcp_receive_loop(int unix_sock)
goto error;
/* add the unix socket */
if (io_watch_add(&io_w, tcpmain_sock, POLLIN, F_TCPMAIN, 0)<0){
- LOG(L_CRIT, "ERROR: tcp_receive_loop: init: failed to add socket "
- " to the fd list\n");
+ LM_CRIT("failed to add socket to the fd list\n");
goto error;
}
@@ -1753,14 +1742,13 @@ void tcp_receive_loop(int unix_sock)
break;
#endif
default:
- LOG(L_CRIT, "BUG: tcp_receive_loop: no support for poll method "
- " %s (%d)\n",
+ LM_CRIT("no support for poll method %s (%d)\n",
poll_method_name(io_w.poll_method), io_w.poll_method);
goto error;
}
error:
destroy_io_wait(&io_w);
- LOG(L_CRIT, "ERROR: tcp_receive_loop: exiting...");
+ LM_CRIT("exiting...");
exit(-1);
}
More information about the sr-dev
mailing list