[sr-dev] git:master:22512d9f: xhttp_prom: convert to memory logging helper

Henning Westerholt hw at skalatan.de
Sat Jan 25 19:21:15 CET 2020


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

Author: Henning Westerholt <hw at skalatan.de>
Committer: Henning Westerholt <hw at skalatan.de>
Date: 2020-01-25T18:55:37+01:00

xhttp_prom: convert to memory logging helper

---

Modified: src/modules/xhttp_prom/prom_metric.c
Modified: src/modules/xhttp_prom/xhttp_prom.c

---

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

---

diff --git a/src/modules/xhttp_prom/prom_metric.c b/src/modules/xhttp_prom/prom_metric.c
index 89c904acad..3349932a2c 100644
--- a/src/modules/xhttp_prom/prom_metric.c
+++ b/src/modules/xhttp_prom/prom_metric.c
@@ -414,7 +414,7 @@ static prom_lvalue_t* prom_metric_lvalue_create(prom_metric_t *p_m, str *l1, str
 	prom_lvalue_t *plv = NULL;
 	plv = (prom_lvalue_t*)shm_malloc(sizeof(*plv));
 	if (plv == NULL) {
-		LM_ERR("shm out of memory\n");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 	memset(plv, 0, sizeof(*plv));
@@ -684,7 +684,7 @@ static int prom_lb_node_add(prom_lb_t *m_lb, char *s, int len, int shared_mem)
 		/* Shared memory */
 		lb_node = (prom_lb_node_t*)shm_malloc(sizeof(*lb_node));
 		if (lb_node == NULL) {
-			LM_ERR("shm out of memory\n");
+			SHM_MEM_ERROR;
 			goto error;
 		}
 		memset(lb_node, 0, sizeof(*lb_node));
@@ -693,7 +693,7 @@ static int prom_lb_node_add(prom_lb_t *m_lb, char *s, int len, int shared_mem)
 		/* Pkg memory */
 		lb_node = (prom_lb_node_t*)pkg_malloc(sizeof(*lb_node));
 		if (lb_node == NULL) {
-			LM_ERR("pkg out of memory\n");
+			PKG_MEM_ERROR;
 			goto error;
 		}
 		memset(lb_node, 0, sizeof(*lb_node));
@@ -706,7 +706,7 @@ static int prom_lb_node_add(prom_lb_t *m_lb, char *s, int len, int shared_mem)
 		/* We left space for zero at the end. */
 		lb_node->n.s = (char*)shm_malloc(len + 1);
 		if (lb_node->n.s == NULL) {
-			LM_ERR("shm out of memory\n");
+			SHM_MEM_ERROR;
 			goto error;
 		}
 		memcpy(lb_node->n.s, s, len);
@@ -717,7 +717,7 @@ static int prom_lb_node_add(prom_lb_t *m_lb, char *s, int len, int shared_mem)
 		/* We left space for zero at the end. */
 		lb_node->n.s = (char*)shm_malloc(len + 1);
 		if (lb_node->n.s == NULL) {
-			LM_ERR("shm out of memory\n");
+			SHM_MEM_ERROR;
 			goto error;
 		}
 		memcpy(lb_node->n.s, s, len);
@@ -766,7 +766,7 @@ static prom_lb_t* prom_lb_create(str *lb_str, int shared_mem)
 		/* Shared memory */
 		m_lb = (prom_lb_t*)shm_malloc(sizeof(*m_lb));
 		if (m_lb == NULL) {
-			LM_ERR("shm out of memory\n");
+			SHM_MEM_ERROR;
 			goto error;
 		}
 		memset(m_lb, 0, sizeof(*m_lb));
@@ -775,7 +775,7 @@ static prom_lb_t* prom_lb_create(str *lb_str, int shared_mem)
 		/* Pkg memory */
 		m_lb = (prom_lb_t*)pkg_malloc(sizeof(*m_lb));
 		if (m_lb == NULL) {
-			LM_ERR("pkg out of memory\n");
+			PKG_MEM_ERROR;
 			goto error;
 		}
 		memset(m_lb, 0, sizeof(*m_lb));
@@ -871,7 +871,7 @@ int prom_counter_create(char *spec)
 	}
 	m_cnt = (prom_metric_t*)shm_malloc(sizeof(prom_metric_t));
 	if (m_cnt == NULL) {
-		LM_ERR("shm out of memory\n");
+		SHM_MEM_ERROR;
 		goto error;
 	}
 	memset(m_cnt, 0, sizeof(*m_cnt));
@@ -969,7 +969,7 @@ int prom_gauge_create(char *spec)
 	}
 	m_gg = (prom_metric_t*)shm_malloc(sizeof(prom_metric_t));
 	if (m_gg == NULL) {
-		LM_ERR("shm out of memory\n");
+		SHM_MEM_ERROR;
 		goto error;
 	}
 	memset(m_gg, 0, sizeof(*m_gg));
diff --git a/src/modules/xhttp_prom/xhttp_prom.c b/src/modules/xhttp_prom/xhttp_prom.c
index 13c8920277..4e28dc742d 100644
--- a/src/modules/xhttp_prom/xhttp_prom.c
+++ b/src/modules/xhttp_prom/xhttp_prom.c
@@ -315,7 +315,7 @@ static int init_xhttp_prom_reply(prom_ctx_t *ctx)
 	reply->reason = XHTTP_PROM_REASON_OK;
 	reply->buf.s = pkg_malloc(buf_size);
 	if (!reply->buf.s) {
-		LM_ERR("oom\n");
+		PKG_MEM_ERROR;
 		prom_fault(ctx, 500, "Internal Server Error (No memory left)");
 		return -1;
 	}
@@ -1231,7 +1231,7 @@ static int double_parse_str(str *s_number, double *pnumber)
 	int len = s_number->len;
 	s = pkg_malloc(len + 1);
 	if (!s) {
-		LM_ERR("Out of pkg memory\n");
+		PKG_MEM_ERROR;
 		goto error;
 	}
 	memcpy(s, s_number->s, len);




More information about the sr-dev mailing list