|
@@ -275,7 +275,7 @@ again:
|
|
(*flags & RD_CONN_FORCE_EOF))){
|
|
(*flags & RD_CONN_FORCE_EOF))){
|
|
c->state=S_CONN_EOF;
|
|
c->state=S_CONN_EOF;
|
|
*flags|=RD_CONN_EOF;
|
|
*flags|=RD_CONN_EOF;
|
|
- DBG("EOF on %p, FD %d\n", c, fd);
|
|
|
|
|
|
+ LM_DBG("EOF on %p, FD %d\n", c, fd);
|
|
}else{
|
|
}else{
|
|
if (unlikely(c->state==S_CONN_CONNECT || c->state==S_CONN_ACCEPT)){
|
|
if (unlikely(c->state==S_CONN_CONNECT || c->state==S_CONN_ACCEPT)){
|
|
TCP_STATS_ESTABLISHED(c->state);
|
|
TCP_STATS_ESTABLISHED(c->state);
|
|
@@ -329,7 +329,7 @@ int tcp_read(struct tcp_connection *c, int* flags)
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
#ifdef EXTRA_DEBUG
|
|
#ifdef EXTRA_DEBUG
|
|
- DBG("tcp_read: read %d bytes:\n%.*s\n", bytes_read, bytes_read, r->pos);
|
|
|
|
|
|
+ LM_DBG("read %d bytes:\n%.*s\n", bytes_read, bytes_read, r->pos);
|
|
#endif
|
|
#endif
|
|
r->pos+=bytes_read;
|
|
r->pos+=bytes_read;
|
|
return bytes_read;
|
|
return bytes_read;
|
|
@@ -507,8 +507,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
|
|
p++;
|
|
p++;
|
|
goto skip;
|
|
goto skip;
|
|
} else {
|
|
} else {
|
|
- DBG("tcp_read_headers: ERROR: no clen, p=%X\n",
|
|
|
|
- *p);
|
|
|
|
|
|
+ LM_DBG("ERROR: no clen, p=%X\n", *p);
|
|
r->error=TCP_REQ_BAD_LEN;
|
|
r->error=TCP_REQ_BAD_LEN;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -580,8 +579,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
|
|
p++;
|
|
p++;
|
|
goto skip;
|
|
goto skip;
|
|
} else {
|
|
} else {
|
|
- DBG("tcp_read_headers: ERROR: no clen, p=%X\n",
|
|
|
|
- *p);
|
|
|
|
|
|
+ LM_DBG("ERROR: no clen, p=%X\n", *p);
|
|
r->error=TCP_REQ_BAD_LEN;
|
|
r->error=TCP_REQ_BAD_LEN;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -628,7 +626,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
|
|
/* body will used as pointer to the last used byte */
|
|
/* body will used as pointer to the last used byte */
|
|
r->body=p;
|
|
r->body=p;
|
|
r->content_len = 0;
|
|
r->content_len = 0;
|
|
- DBG("stun msg detected\n");
|
|
|
|
|
|
+ LM_DBG("stun msg detected\n");
|
|
} else {
|
|
} else {
|
|
r->state=H_SKIP;
|
|
r->state=H_SKIP;
|
|
}
|
|
}
|
|
@@ -1286,10 +1284,10 @@ again:
|
|
bytes=tcp_read_headers(con, read_flags);
|
|
bytes=tcp_read_headers(con, read_flags);
|
|
#ifdef EXTRA_DEBUG
|
|
#ifdef EXTRA_DEBUG
|
|
/* if timeout state=0; goto end__req; */
|
|
/* if timeout state=0; goto end__req; */
|
|
- DBG("read= %d bytes, parsed=%d, state=%d, error=%d\n",
|
|
|
|
|
|
+ LM_DBG("read= %d bytes, parsed=%d, state=%d, error=%d\n",
|
|
bytes, (int)(req->parsed-req->start), req->state,
|
|
bytes, (int)(req->parsed-req->start), req->state,
|
|
req->error );
|
|
req->error );
|
|
- DBG("tcp_read_req: last char=0x%02X, parsed msg=\n%.*s\n",
|
|
|
|
|
|
+ LM_DBG("last char=0x%02X, parsed msg=\n%.*s\n",
|
|
*(req->parsed-1), (int)(req->parsed-req->start),
|
|
*(req->parsed-1), (int)(req->parsed-req->start),
|
|
req->start);
|
|
req->start);
|
|
#endif
|
|
#endif
|
|
@@ -1307,7 +1305,7 @@ again:
|
|
*/
|
|
*/
|
|
if (unlikely((con->state==S_CONN_EOF) &&
|
|
if (unlikely((con->state==S_CONN_EOF) &&
|
|
(! TCP_REQ_COMPLETE(req)))) {
|
|
(! TCP_REQ_COMPLETE(req)))) {
|
|
- DBG( "tcp_read_req: EOF\n");
|
|
|
|
|
|
+ LM_DBG("EOF\n");
|
|
resp=CONN_EOF;
|
|
resp=CONN_EOF;
|
|
goto end_req;
|
|
goto end_req;
|
|
}
|
|
}
|
|
@@ -1317,23 +1315,23 @@ again:
|
|
req->state, req->error,
|
|
req->state, req->error,
|
|
(int)(req->pos-req->buf), req->buf,
|
|
(int)(req->pos-req->buf), req->buf,
|
|
(int)(req->parsed-req->start), req->start);
|
|
(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");
|
|
|
|
|
|
+ LM_DBG("received from: port %d\n", con->rcv.src_port);
|
|
|
|
+ print_ip("received from: ip", &con->rcv.src_ip, "\n");
|
|
resp=CONN_ERROR;
|
|
resp=CONN_ERROR;
|
|
goto end_req;
|
|
goto end_req;
|
|
}
|
|
}
|
|
if (likely(TCP_REQ_COMPLETE(req))){
|
|
if (likely(TCP_REQ_COMPLETE(req))){
|
|
#ifdef EXTRA_DEBUG
|
|
#ifdef EXTRA_DEBUG
|
|
- DBG("tcp_read_req: end of header part\n");
|
|
|
|
- DBG("- received from: port %d\n", con->rcv.src_port);
|
|
|
|
- print_ip("- received from: ip ", &con->rcv.src_ip, "\n");
|
|
|
|
- DBG("tcp_read_req: headers:\n%.*s.\n",
|
|
|
|
|
|
+ LM_DBG("end of header part\n");
|
|
|
|
+ LM_DBG("received from: port %d\n", con->rcv.src_port);
|
|
|
|
+ print_ip("received from: ip", &con->rcv.src_ip, "\n");
|
|
|
|
+ LM_DBG("headers:\n%.*s.\n",
|
|
(int)(req->body-req->start), req->start);
|
|
(int)(req->body-req->start), req->start);
|
|
#endif
|
|
#endif
|
|
if (likely(TCP_REQ_HAS_CLEN(req))){
|
|
if (likely(TCP_REQ_HAS_CLEN(req))){
|
|
- DBG("tcp_read_req: content-length= %d\n", req->content_len);
|
|
|
|
|
|
+ LM_DBG("content-length=%d\n", req->content_len);
|
|
#ifdef EXTRA_DEBUG
|
|
#ifdef EXTRA_DEBUG
|
|
- DBG("tcp_read_req: body:\n%.*s\n", req->content_len,req->body);
|
|
|
|
|
|
+ LM_DBG("body:\n%.*s\n", req->content_len,req->body);
|
|
#endif
|
|
#endif
|
|
}else{
|
|
}else{
|
|
if (cfg_get(tcp, tcp_cfg, accept_no_cl)==0) {
|
|
if (cfg_get(tcp, tcp_cfg, accept_no_cl)==0) {
|
|
@@ -1346,7 +1344,7 @@ again:
|
|
/* if we are here everything is nice and ok*/
|
|
/* if we are here everything is nice and ok*/
|
|
resp=CONN_RELEASE;
|
|
resp=CONN_RELEASE;
|
|
#ifdef EXTRA_DEBUG
|
|
#ifdef EXTRA_DEBUG
|
|
- DBG("receiving msg(%p, %d, )\n",
|
|
|
|
|
|
+ LM_DBG("receiving msg(%p, %d)\n",
|
|
req->start, (int)(req->parsed-req->start));
|
|
req->start, (int)(req->parsed-req->start));
|
|
#endif
|
|
#endif
|
|
/* rcv.bind_address should always be !=0 */
|
|
/* rcv.bind_address should always be !=0 */
|
|
@@ -1425,13 +1423,12 @@ again:
|
|
memmove(req->buf, req->parsed, size);
|
|
memmove(req->buf, req->parsed, size);
|
|
req->parsed=req->buf; /* fix req->parsed after using it */
|
|
req->parsed=req->buf; /* fix req->parsed after using it */
|
|
#ifdef EXTRA_DEBUG
|
|
#ifdef EXTRA_DEBUG
|
|
- DBG("tcp_read_req: preparing for new request, kept %ld"
|
|
|
|
- " bytes\n", size);
|
|
|
|
|
|
+ LM_DBG("preparing for new request, kept %ld bytes\n", size);
|
|
#endif
|
|
#endif
|
|
/*if we still have some unparsed bytes, try to parse them too*/
|
|
/*if we still have some unparsed bytes, try to parse them too*/
|
|
goto again;
|
|
goto again;
|
|
} else if (unlikely(con->state==S_CONN_EOF)){
|
|
} else if (unlikely(con->state==S_CONN_EOF)){
|
|
- DBG( "tcp_read_req: EOF after reading complete request\n");
|
|
|
|
|
|
+ LM_DBG("EOF after reading complete request\n");
|
|
resp=CONN_EOF;
|
|
resp=CONN_EOF;
|
|
}
|
|
}
|
|
req->parsed=req->buf; /* fix req->parsed */
|
|
req->parsed=req->buf; /* fix req->parsed */
|
|
@@ -1449,9 +1446,9 @@ void release_tcpconn(struct tcp_connection* c, long state, int unix_sock)
|
|
{
|
|
{
|
|
long response[2];
|
|
long response[2];
|
|
|
|
|
|
- DBG( "releasing con %p, state %ld, fd=%d, id=%d\n",
|
|
|
|
|
|
+ LM_DBG("releasing con %p, state %ld, fd=%d, id=%d\n",
|
|
c, state, c->fd, c->id);
|
|
c, state, c->fd, c->id);
|
|
- DBG(" extra_data %p\n", c->extra_data);
|
|
|
|
|
|
+ LM_DBG("extra_data %p\n", c->extra_data);
|
|
/* release req & signal the parent */
|
|
/* release req & signal the parent */
|
|
c->reader_pid=0; /* reset it */
|
|
c->reader_pid=0; /* reset it */
|
|
if (c->fd!=-1){
|
|
if (c->fd!=-1){
|
|
@@ -1523,7 +1520,7 @@ inline static int handle_io(struct fd_map* fm, short events, int idx)
|
|
case F_TCPMAIN:
|
|
case F_TCPMAIN:
|
|
again:
|
|
again:
|
|
ret=n=receive_fd(fm->fd, &con, sizeof(con), &s, 0);
|
|
ret=n=receive_fd(fm->fd, &con, sizeof(con), &s, 0);
|
|
- DBG("received n=%d con=%p, fd=%d\n", n, con, s);
|
|
|
|
|
|
+ LM_DBG("received n=%d con=%p, fd=%d\n", n, con, s);
|
|
if (unlikely(n<0)){
|
|
if (unlikely(n<0)){
|
|
if (errno == EWOULDBLOCK || errno == EAGAIN){
|
|
if (errno == EWOULDBLOCK || errno == EAGAIN){
|
|
ret=0;
|
|
ret=0;
|