Module: kamailio
Branch: master
Commit: 80d1f10507190ae1a42c25f0c173188b8326b5b9
URL: https://github.com/kamailio/kamailio/commit/80d1f10507190ae1a42c25f0c173188…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-11-10T14:08:09+01:00
core: qm/fm memory align size can be set with define KSR_MEMORY_ALIGN
- flexibility to be set at compile time via make or compiler parameter
---
Modified: src/core/mem/f_malloc.h
Modified: src/core/mem/q_malloc.h
---
Diff: https://github.com/kamailio/kamailio/commit/80d1f10507190ae1a42c25f0c173188…
Patch: https://github.com/kamailio/kamailio/commit/80d1f10507190ae1a42c25f0c173188…
---
diff --git a/src/core/mem/f_malloc.h b/src/core/mem/f_malloc.h
index c05a243af6f..5a9d28ece42 100644
--- a/src/core/mem/f_malloc.h
+++ b/src/core/mem/f_malloc.h
@@ -46,10 +46,15 @@
* can be 32 bits aligned => malloc should return multiple of long long
* aligned memory
* - malloc() on gnu/linux: multiple of 8 or 16 on 64-bit systems
- * - for simplicity settle for 16 always
+ * - for simplicity settle for 16 by default
* - sizeof(fm_frag) must be multiple of ROUNDTO!
*/
+#ifndef KSR_MEMORY_ALIGN
#define ROUNDTO 16UL
+#else
+#define ROUNDTO KSR_MEMORY_ALIGN
+#endif
+
#define MIN_FRAG_SIZE ROUNDTO
diff --git a/src/core/mem/q_malloc.h b/src/core/mem/q_malloc.h
index b3bfaab3689..5b440688af3 100644
--- a/src/core/mem/q_malloc.h
+++ b/src/core/mem/q_malloc.h
@@ -39,10 +39,14 @@
* can be 32 bits aligned => malloc should return multiple of long long
* aligned memory
* - malloc() on gnu/linux: multiple of 8 or 16 on 64-bit systems
- * - for simplicity settle for 16 always
+ * - for simplicity settle for 16 by default
* - sizeof(qm_frag) and sizeof(qm_frag_end) must be multiple of ROUNDTO!
*/
+#ifndef KSR_MEMORY_ALIGN
#define ROUNDTO 16UL
+#else
+#define ROUNDTO KSR_MEMORY_ALIGN
+#endif
#define MIN_FRAG_SIZE ROUNDTO
### Description
I migrate one of our old project on native to KEMI on app_python3 and get strange behavior - after some time kamailio stops processing requests/replies wit message "ksr_request_route/ksr_reply_route not found or is not callable"
### Troubleshooting
After some research with debug=3 and reading debug logs i found, that some of routes i forgot to rename in calls t_on_reply() and t_on_failure() - because they generates "not found or is not callable" in logs too. Also i check all event routes and found that some event_callbacks point to wrong KEMI functions.
Events of the form (which gave me the idea that it was the wrong names)
DEBUG: 887937087 INVITE app_python3 [python_exec.c:93]: apy_exec(): ksr_onrl_MANAGE not found or is not callable
DEBUG: app_python3 [python_exec.c:93]: apy_exec(): ksr_dialog_event not found or is not callable
presents in logs very rarely (I saw them only after hours of debugging) even after restart.
For me its look like that nonexisted routes completly stops interpretator and block all subsequent processing in the fork and kamailio very rarely has time to log it.
When i use right names of functions it works well and no "ksr_request_route/ksr_reply_route not found or is not callable"
PS: KSR.tm.t_on_branch() with wrong route generates normal exception and nonblock execution
#### Reproduction
Just use wrong names in KSR.tm.t_on_reply()/KSR.tm.t_on_failure() or modparam event_callback in any module (i got it with dispatcher and dialog)
#### Log Messages
Exception that generates by wrong function in KSR.tm.t_on_branch()
ERROR: 63586697 BYE app_python3 [python_support.c:156]: python_handle_exception(): apy_exec: ksr_request_route((null)): Unhandled exception in the Python code:
AttributeError: 'kamailio' object has no attribute 'ksr_br_MANAGE'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/etc/kamailio(a)REGION/python/request_route.py", line 38, in ksr_request_route
if self.ksr_WITHINDLG() == -255:
File "/etc/kamailio(a)REGION/python/ksr_WITHINDLG.py", line 27, in ksr_WITHINDLG
return self.ksr_RELAY()
File "/etc/kamailio(a)REGION/python/ksr_RELAY.py", line 17, in ksr_RELAY
if KSR.tm.t_relay() < 0:
SystemError: <built-in function t_relay> returned a result with an error set
### Possible Solutions
Use rigth names
### Additional Information
version: kamailio 5.7.1 (x86_64/linux) 4238e4
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, MEM_JOIN_FREE, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 4238e4
compiled on 00:00:00 Sep 13 2022 with gcc 11.3.1
version: kamailio 5.6.4 (x86_64/linux)
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 10.2.1
* **Operating System**:
PRETTY_NAME="Oracle Linux Server 9.2"
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3572
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3572(a)github.com>