Module: kamailio
Branch: master
Commit: a705e601d9924118ed6d79b21e92fd2af0267a05
URL: 
https://github.com/kamailio/kamailio/commit/a705e601d9924118ed6d79b21e92fd2af0267a05

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-02-18T13:14:16+01:00

tm: made TM_DELAYED_REPLY modparam delayed_reply

- GH #4140

---

Modified: src/modules/tm/t_funcs.c
Modified: src/modules/tm/tm.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/a705e601d9924118ed6d79b21e92fd2af0267a05.diff
Patch: 
https://github.com/kamailio/kamailio/commit/a705e601d9924118ed6d79b21e92fd2af0267a05.patch

---

diff --git a/src/modules/tm/t_funcs.c b/src/modules/tm/t_funcs.c
index 55510742b39..dd14f83a15c 100644
--- a/src/modules/tm/t_funcs.c
+++ b/src/modules/tm/t_funcs.c
@@ -43,7 +43,7 @@
 
 /* if defined t_relay* error reply generation will be delayed till script
  * end (this allows the script writer to send its own error reply) */
-#define TM_DELAYED_REPLY
+extern int _tm_delayed_reply;
 
 #ifdef USE_DNS_FAILOVER
 extern int **failover_reply_codes;
@@ -232,9 +232,7 @@ int t_relay_to(
        unsigned short port;
        str host;
        short comp;
-#ifndef TM_DELAYED_REPLY
        int reply_ret;
-#endif
 
        ret = 0;
 
@@ -354,26 +352,25 @@ int t_relay_to(
                                ret = -4;
                                goto done;
                        }
-#ifdef TM_DELAYED_REPLY
-                       /* current error in tm_error */
-                       tm_error = ser_error;
-                       set_kr(REQ_ERR_DELAYED);
-                       LM_DBG("%d error reply generation delayed \n", 
ser_error);
-#else
-
-                       reply_ret = kill_transaction(t, ser_error);
-                       if(reply_ret > 0) {
-                               /* we have taken care of all -- do nothing in
-                               script */
-                               LM_DBG("generation of a stateful reply "
-                                          "on error succeeded\n");
-                               /*ret=0; -- we don't want to stop the script */
+                       if(_tm_delayed_reply != 0) {
+                               /* current error in tm_error */
+                               tm_error = ser_error;
+                               set_kr(REQ_ERR_DELAYED);
+                               LM_DBG("%d error reply generation delayed \n", 
ser_error);
                        } else {
-                               LM_DBG("generation of a stateful reply "
-                                          "on error failed\n");
-                               t_release_transaction(t);
+                               reply_ret = kill_transaction(t, ser_error);
+                               if(reply_ret > 0) {
+                                       /* we have taken care of all -- do 
nothing in
+                                          script */
+                                       LM_DBG("generation of a stateful reply "
+                                                  "on error succeeded\n");
+                                       /*ret=0; -- we don't want to stop the 
script */
+                               } else {
+                                       LM_DBG("generation of a stateful reply "
+                                                  "on error failed\n");
+                                       t_release_transaction(t);
+                               }
                        }
-#endif /* TM_DELAYED_REPLY */
                } else {
                        t_release_transaction(t); /* kill it  silently */
                }
diff --git a/src/modules/tm/tm.c b/src/modules/tm/tm.c
index b10200dab4e..d6f7423b3c1 100644
--- a/src/modules/tm/tm.c
+++ b/src/modules/tm/tm.c
@@ -229,6 +229,7 @@ int tm_remap_503_500 = 1;
 str _tm_event_callback_lres_sent = {NULL, 0};
 int _tm_reply_408_code = 408;
 str _tm_reply_408_reason = str_init("Request Timeout");
+int _tm_delayed_reply = 1;
 
 #ifdef USE_DNS_FAILOVER
 str failover_reply_codes_str = {NULL, 0};
@@ -528,6 +529,7 @@ static param_export_t params[] = {
 #endif
        {"reply_408_code", PARAM_INT, &_tm_reply_408_code},
        {"reply_408_reason", PARAM_STR, &_tm_reply_408_reason},
+       {"delayed_reply", PARAM_INT, &_tm_delayed_reply},
        {0, 0, 0}
 };
 

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to