Browse code

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

Daniel-Constantin Mierla authored on 05/11/2014 12:59:53
Showing 2 changed files
... ...
@@ -480,8 +480,9 @@ int pv_get_mq_size(struct sip_msg *msg, pv_param_t *param,
480 480
 
481 481
 	return pv_get_sintval(msg, param, res, mqs);
482 482
 }
483
-/* Return head->csize for a given queue */
484
-
483
+/**
484
+ * Return head->csize for a given queue
485
+ */
485 486
 int _mq_get_csize(str *name) 
486 487
 {
487 488
 	mq_head_t *mh = mq_head_get(name);
... ...
@@ -158,7 +158,8 @@ static int w_mq_size(struct sip_msg *msg, char *mq, char *str2)
158 158
 	ret = _mq_get_csize(&q);
159 159
 
160 160
 	if(ret < 0)
161
-		LM_ERR("mqueue not found\n");
161
+		LM_ERR("mqueue %.*s not found\n", q.len, q.s);
162
+	if(ret<=0) ret--;
162 163
 
163 164
 	return ret;
164 165
 }