On 10/11/2010 12:28 PM, Alex Balashov wrote:
Can this be backported into the 3.1.0 branch? Or is that not the usual custom? It would be very inconvenient to apply this patch to every new installation, but now that I am using it it is important. :-)
It will be backported, just let me know if it works ok now.
Regards, Ramona
On 10/11/2010 06:21 AM, Elena-Ramona Modroiu wrote:
Module: sip-router Branch: master Commit: e6fa8ae004f5d487e1c64471bf282931e4b9e901 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e6fa8ae0...
Author: Elena-Ramona Modroiuramona@asipto.com Committer: Elena-Ramona Modroiuramona@asipto.com Date: Mon Oct 11 12:20:24 2010 +0200
mqueue: return false if queue is empty
- return code -2
- reported by Alex Balashov
modules/mqueue/README | 11 +++++++---- modules/mqueue/doc/mqueue_admin.xml | 8 ++++++-- modules/mqueue/mqueue_api.c | 22 +++++++++++++--------- modules/mqueue/mqueue_mod.c | 7 +++++-- 4 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/modules/mqueue/README b/modules/mqueue/README index 4c439a4..f876b2a 100644 --- a/modules/mqueue/README +++ b/modules/mqueue/README @@ -10,7 +10,7 @@ Elena-Ramona Modroiu
- Copyright � 2010 Elena-Ramona Modroiu (asipto.com)
- Copyright © 2010 Elena-Ramona Modroiu (asipto.com)
Table of Contents
@@ -94,7 +94,7 @@ Chapter 1. Admin Guide
Definition of memory queue
- Default value is "none".
Default value is “none”.
Value must be a list of parameters: attr=value;... The attribute
'name' is mandatory, defining the name of the queue. Optional attribute 'size' @@ -128,8 +128,11 @@ mq_add("myq", "$rU", "call from $fU");
4.2. mq_fetch(queue)
- Take oldest item from que and fill $mqk(queue) and $mqv(queue)
pseudo
- variables. Return true on success.
- Take oldest item from queue and fill $mqk(queue) and $mqv(queue)
pseudo
- variables.
- Return: true on success (1); false on failure (-1) or no item
fetched
(-2).
Example 1.3. mq_fetch usage ...
diff --git a/modules/mqueue/doc/mqueue_admin.xml b/modules/mqueue/doc/mqueue_admin.xml index e02ca38..d1b924a 100644 --- a/modules/mqueue/doc/mqueue_admin.xml +++ b/modules/mqueue/doc/mqueue_admin.xml @@ -118,8 +118,12 @@ mq_add("myq", "$rU", "call from $fU"); <function moreinfo="none">mq_fetch(queue)</function>
</title> <para> - Take oldest item from que and fill $mqk(queue) and $mqv(queue) pseudo - variables. Return true on success. + Take oldest item from queue and fill $mqk(queue) and + $mqv(queue) pseudo variables. + </para> + <para> + Return: true on success (1); false on failure (-1) or + no item fetched (-2). </para> <example> <title><function>mq_fetch</function> usage</title> diff --git a/modules/mqueue/mqueue_api.c b/modules/mqueue/mqueue_api.c index f75f23a..6007ef0 100644 --- a/modules/mqueue/mqueue_api.c +++ b/modules/mqueue/mqueue_api.c @@ -254,17 +254,21 @@ int mq_head_fetch(str *name) return -1; lock_get(&mh->lock);
- if(mh->ifirst!=NULL)
- if(mh->ifirst==NULL) {
mp->item = mh->ifirst;
mh->ifirst = mh->ifirst->next;
if(mh->ifirst==NULL) {
mh->ilast = NULL;
} else {
mh->ifirst->prev = NULL;
}
mh->csize--;
/* empty queue */
lock_release(&mh->lock);
return -2;
}
mp->item = mh->ifirst;
mh->ifirst = mh->ifirst->next;
if(mh->ifirst==NULL) {
mh->ilast = NULL;
} else {
mh->ifirst->prev = NULL; }
mh->csize--;
lock_release(&mh->lock); return 0;
diff --git a/modules/mqueue/mqueue_mod.c b/modules/mqueue/mqueue_mod.c index 922f02e..5a74f58 100644 --- a/modules/mqueue/mqueue_mod.c +++ b/modules/mqueue/mqueue_mod.c @@ -109,8 +109,11 @@ static void mod_destroy(void)
static int w_mq_fetch(struct sip_msg* msg, char* mq, char* str2) {
- if(mq_head_fetch((str*)mq)<0)
return -1;
- int ret;
- ret = mq_head_fetch((str*)mq);
- if(ret<0)
}return ret; return 1;
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev