Module: kamailio
Branch: master
Commit: d114d11724dc4157e7e5809504531d26da6bcc57
URL:
https://github.com/kamailio/kamailio/commit/d114d11724dc4157e7e5809504531d2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-04-23T10:36:35+02:00
core: tcp - set a global shortcut to tcp connection for event route
---
Modified: src/core/tcp_conn.h
Modified: src/core/tcp_main.c
---
Diff:
https://github.com/kamailio/kamailio/commit/d114d11724dc4157e7e5809504531d2…
Patch:
https://github.com/kamailio/kamailio/commit/d114d11724dc4157e7e5809504531d2…
---
diff --git a/src/core/tcp_conn.h b/src/core/tcp_conn.h
index 5b579b2ffb9..57dff5a291b 100644
--- a/src/core/tcp_conn.h
+++ b/src/core/tcp_conn.h
@@ -434,4 +434,6 @@ typedef struct ws_event_info
int id;
} ws_event_info_t;
+tcp_connection_t *ksr_tcpcon_evcb_get(void);
+
#endif
diff --git a/src/core/tcp_main.c b/src/core/tcp_main.c
index 957a9b97c0f..2456459cfa2 100644
--- a/src/core/tcp_main.c
+++ b/src/core/tcp_main.c
@@ -3670,6 +3670,12 @@ int _tcpconn_write_nb(
return n;
}
+static tcp_connection_t *_ksr_tcpcon_evcb = NULL;
+
+tcp_connection_t *ksr_tcpcon_evcb_get(void)
+{
+ return _ksr_tcpcon_evcb;
+}
static int tcp_emit_closed_event(struct tcp_connection *con)
{
@@ -3692,7 +3698,9 @@ static int tcp_emit_closed_event(struct tcp_connection *con)
tev.id = con->id;
tev.con = con;
evp.data = (void *)(&tev);
+ _ksr_tcpcon_evcb = con;
ret = sr_event_exec(SREV_TCP_CLOSED, &evp);
+ _ksr_tcpcon_evcb = NULL;
} else {
LM_DBG("no callback registering for handling TCP closed event\n");
}