Module: kamailio
Branch: master
Commit: b0dea316a2aa471cf92f122e3432a6549cf0ff5c
URL:
https://github.com/kamailio/kamailio/commit/b0dea316a2aa471cf92f122e3432a65…
Author: Stefan Mititelu <stefan.mititelu(a)1and1.ro>
Committer: Stefan Mititelu <stefan.mititelu(a)1and1.ro>
Date: 2016-05-31T11:33:56+03:00
mem: Add on-error log messages for q_/f_ functions
Log some errors in case some memory API functions fail.
---
Modified: mem/f_malloc.c
Modified: mem/q_malloc.c
---
Diff:
https://github.com/kamailio/kamailio/commit/b0dea316a2aa471cf92f122e3432a65…
Patch:
https://github.com/kamailio/kamailio/commit/b0dea316a2aa471cf92f122e3432a65…
---
diff --git a/mem/f_malloc.c b/mem/f_malloc.c
index 6afe7f7..5679721 100644
--- a/mem/f_malloc.c
+++ b/mem/f_malloc.c
@@ -336,6 +336,7 @@ struct fm_block* fm_malloc_init(char* address, unsigned long size, int
type)
if (size < init_overhead)
{
/* not enough mem to create our control structures !!!*/
+ LOG(L_ERR, "fm_malloc_init(%lu); No memory left to create control
structures!\n", size);
return 0;
}
end=start+size;
@@ -409,6 +410,8 @@ struct fm_frag* fm_search_defrag(struct fm_block* qm, unsigned long
size)
frag = nxt;
}
+ LOG(L_ERR, "fm_search_defrag(%p, %lu); Free fragment not found!\n", qm,
size);
+
return 0;
}
@@ -488,6 +491,12 @@ void* fm_malloc(void* qmp, unsigned long size)
if(frag) goto finish;
+#ifdef DBG_F_MALLOC
+ LOG(L_ERR, "fm_malloc(%p, %lu) called from %s: %s(%d), module: %s; Free
fragment not found!\n", qm, size, file, func, line, mname);
+#else
+ LOG(L_ERR, "fm_malloc(%p, %lu); Free fragment not found!\n", qm,
size);
+#endif
+
return 0;
found:
@@ -715,6 +724,12 @@ void* fm_realloc(void* qmp, void* p, unsigned long size)
if (ptr){
/* copy, need by libssl */
memcpy(ptr, p, orig_size);
+ } else {
+#ifdef DBG_F_MALLOC
+ LOG(L_ERR, "fm_realloc(%p, %lu) called from %s: %s(%d), module: %s; fm_malloc()
failed!\n", qm, size, file, func, line, mname);
+#else
+ LOG(L_ERR, "fm_realloc(%p, %lu); fm_malloc() failed!\n", qm, size);
+#endif
}
#ifdef DBG_F_MALLOC
fm_free(qm, p, file, func, line, mname);
diff --git a/mem/q_malloc.c b/mem/q_malloc.c
index 36cc15a..31c3ab5 100644
--- a/mem/q_malloc.c
+++ b/mem/q_malloc.c
@@ -202,6 +202,7 @@ struct qm_block* qm_malloc_init(char* address, unsigned long size, int
type)
if (size < init_overhead)
{
/* not enough mem to create our control structures !!!*/
+ LOG(L_ERR, "qm_malloc_init(%lu); No memory left to create control
structures!\n", size);
return 0;
}
end=start+size;
@@ -285,6 +286,7 @@ static inline struct qm_frag* qm_find_free(struct qm_block* qm,
/*try in a bigger bucket*/
}
/* not found */
+ LOG(L_ERR, "qm_find_free(%p, %lu); Free fragment not found!\n", qm, size);
return 0;
}
@@ -413,6 +415,13 @@ void* qm_malloc(void* qmp, unsigned long size)
#endif
return (char*)f+sizeof(struct qm_frag);
}
+
+#ifdef DBG_QM_MALLOC
+ LOG(L_ERR, "qm_malloc(%p, %lu) called from %s: %s(%d), module: %s; Free fragment
not found!\n", qm, size, file, func, line, mname);
+#else
+ LOG(L_ERR, "qm_malloc(%p, %lu); Free fragment not found!\n", qm, size);
+#endif
+
return 0;
}
@@ -653,6 +662,12 @@ void* qm_realloc(void* qmp, void* p, unsigned long size)
if (ptr){
/* copy, need by libssl */
memcpy(ptr, p, orig_size);
+ } else {
+#ifdef DBG_QM_MALLOC
+ LOG(L_ERR, "qm_realloc(%p, %lu) called from %s: %s(%d), module: %s; qm_malloc()
failed!\n", qm, size, file, func, line, mname);
+#else
+ LOG(L_ERR, "qm_realloc(%p, %lu); qm_malloc() failed!\n", qm, size);
+#endif
}
#ifdef DBG_QM_MALLOC
qm_free(qm, p, file, func, line, mname);