Module: kamailio
Branch: master
Commit: 4deb51419ab66931459709fe44acd3e7a0acc18d
URL:
https://github.com/kamailio/kamailio/commit/4deb51419ab66931459709fe44acd3e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-06-03T12:45:05+02:00
core: tcp - log details of the exiting tcp connection on insert failure
---
Modified: src/core/tcp_read.c
---
Diff:
https://github.com/kamailio/kamailio/commit/4deb51419ab66931459709fe44acd3e…
Patch:
https://github.com/kamailio/kamailio/commit/4deb51419ab66931459709fe44acd3e…
---
diff --git a/src/core/tcp_read.c b/src/core/tcp_read.c
index 8147951b21..db6e8b923a 100644
--- a/src/core/tcp_read.c
+++ b/src/core/tcp_read.c
@@ -1720,7 +1720,7 @@ static ticks_t tcpconn_read_timeout(ticks_t t, struct timer_ln* tl,
void* data)
* idx - index in the fd_array (or -1 if not known)
* return: -1 on error, or when we are not interested any more on reads
* from this fd (e.g.: we are closing it )
- * 0 on EAGAIN or when by some other way it is known that no more
+ * 0 on EAGAIN or when by some other way it is known that no more
* io events are queued on the fd (the receive buffer is empty).
* Usefull to detect when there are no more io events queued for
* sigio_rt, epoll_et, kqueue.
@@ -1728,7 +1728,7 @@ static ticks_t tcpconn_read_timeout(ticks_t t, struct timer_ln* tl,
void* data)
* queued -- the receive buffer might still be non-empty)
*/
inline static int handle_io(struct fd_map* fm, short events, int idx)
-{
+{
int ret;
int n;
int read_flags;
@@ -1736,10 +1736,11 @@ inline static int handle_io(struct fd_map* fm, short events, int
idx)
int s;
long resp;
ticks_t t;
-
+ fd_map_t *ee = NULL;
+
/* update the local config */
cfg_update();
-
+
switch(fm->type){
case F_TCPMAIN:
again:
@@ -1803,7 +1804,7 @@ inline static int handle_io(struct fd_map* fm, short events, int
idx)
if (unlikely(read_flags & RD_CONN_REPEAT_READ))
goto repeat_1st_read;
#endif /* USE_TLS */
-
+
/* must be before io_watch_add, io_watch_add might catch some
* already existing events => might call handle_io and
* handle_io might decide to del. the new connection =>
@@ -1816,13 +1817,25 @@ inline static int handle_io(struct fd_map* fm, short events, int
idx)
local_timer_reinit(&con->timer);
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)){
+ if (unlikely(io_watch_add(&io_w, s, POLLIN, F_TCPCONN, con)<0)) {
LM_CRIT("io_watch_add failed for %p id %d fd %d, state %d, flags %x,"
" main fd %d, refcnt %d ([%s]:%u -> [%s]:%u)\n",
con, con->id, con->fd, con->state, con->flags,
con->s, atomic_get(&con->refcnt),
ip_addr2a(&con->rcv.src_ip), con->rcv.src_port,
ip_addr2a(&con->rcv.dst_ip), con->rcv.dst_port);
+ ee = get_fd_map(&io_w, s);
+ if(ee!=0 && ee->type==F_TCPCONN) {
+ tcp_connection_t *ec;
+ ec = (tcp_connection_t*)ee->data;
+ LM_CRIT("existing tcp con %p id %d fd %d, state %d, flags %x,"
+ " main fd %d, refcnt %d ([%s]:%u -> [%s]:%u)\n",
+ ec, ec->id, ec->fd, ec->state, ec->flags,
+ ec->s, atomic_get(&ec->refcnt),
+ ip_addr2a(&ec->rcv.src_ip), ec->rcv.src_port,
+ ip_addr2a(&ec->rcv.dst_ip), ec->rcv.dst_port);
+
+ }
tcpconn_listrm(tcp_conn_lst, con, c_next, c_prev);
local_timer_del(&tcp_reader_ltimer, &con->timer);
goto con_error;