[sr-dev] git:4.2: mqueue: fix mq_size() not to return 0

Daniel-Constantin Mierla miconda at gmail.com
Wed Nov 5 14:08:44 CET 2014


Module: sip-router
Branch: 4.2
Commit: 281c668b5e3a0ef9f7edde2bbea6b81201bd00b0
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=281c668b5e3a0ef9f7edde2bbea6b81201bd00b0

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Wed Nov  5 13:59:53 2014 +0100

mqueue: fix mq_size() not to return 0

- return 0 for a config function is considered 'exit' by interpreter
- if size of the queue is 0, the function return -1
- for other error cases, the return code was decremented by 1

(cherry picked from commit bde57b53386e792651b5ac86ea32d16ab721a07c)

---

 modules/mqueue/mqueue_api.c |    5 +++--
 modules/mqueue/mqueue_mod.c |    3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/mqueue/mqueue_api.c b/modules/mqueue/mqueue_api.c
index 68baaf4..93d6b86 100644
--- a/modules/mqueue/mqueue_api.c
+++ b/modules/mqueue/mqueue_api.c
@@ -480,8 +480,9 @@ int pv_get_mq_size(struct sip_msg *msg, pv_param_t *param,
 
 	return pv_get_sintval(msg, param, res, mqs);
 }
-/* Return head->csize for a given queue */
-
+/**
+ * Return head->csize for a given queue
+ */
 int _mq_get_csize(str *name) 
 {
 	mq_head_t *mh = mq_head_get(name);
diff --git a/modules/mqueue/mqueue_mod.c b/modules/mqueue/mqueue_mod.c
index 10bdea6..6ea71aa 100644
--- a/modules/mqueue/mqueue_mod.c
+++ b/modules/mqueue/mqueue_mod.c
@@ -158,7 +158,8 @@ static int w_mq_size(struct sip_msg *msg, char *mq, char *str2)
 	ret = _mq_get_csize(&q);
 
 	if(ret < 0)
-		LM_ERR("mqueue not found\n");
+		LM_ERR("mqueue %.*s not found\n", q.len, q.s);
+	if(ret<=0) ret--;
 
 	return ret;
 }




More information about the sr-dev mailing list