From ramona@asipto.com Mon Oct 11 13:23:36 2010 From: Elena-Ramona Modroiu To: sr-dev@lists.kamailio.org Subject: Re: [sr-dev] git:master: mqueue: return false if queue is empty Date: Mon, 11 Oct 2010 13:23:33 +0200 Message-ID: <4CB2F3B5.3030508@asipto.com> In-Reply-To: <4CB2E6D7.4070001@evaristesys.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1220993826==" --===============1220993826== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20 > usual custom? It would be very inconvenient to apply this patch to=20 > 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: =20 >> http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=3Dcommit;h=3De6= fa8ae004f5d487e1c64471bf282931e4b9e901=20 >> >> >> Author: Elena-Ramona Modroiu >> Committer: Elena-Ramona Modroiu >> 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 =EF=BF=BD 2010 Elena-Ramona Modroiu (asipto.com) >> + Copyright =C2=A9 2010 Elena-Ramona Modroiu (asipto.com) >> =20 >> __________________________________________________________________ >> >> Table of Contents >> @@ -94,7 +94,7 @@ Chapter 1. Admin Guide >> >> Definition of memory queue >> >> - Default value is "none". >> + Default value is =E2=80=9Cnone=E2=80=9D. >> >> Value must be a list of parameters: attr=3Dvalue;... The attribute=20 >> 'name' >> is mandatory, defining the name of the queue. Optional attribute=20 >> '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)=20 >> pseudo >> - variables. Return true on success. >> + Take oldest item from queue and fill $mqk(queue) and $mqv(queue)=20 >> pseudo >> + variables. >> + >> + Return: true on success (1); false on failure (-1) or no item=20 >> fetched >> + (-2). >> >> Example 1.3. mq_fetch usage >> ... >> diff --git a/modules/mqueue/doc/mqueue_admin.xml=20 >> 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"); >> mq_fetch(queue) >> >> >> - Take oldest item from que and fill $mqk(queue) and=20 >> $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). >> >> >> <function>mq_fetch</function> usage >> 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!=3DNULL) >> + if(mh->ifirst=3D=3DNULL) >> { >> - mp->item =3D mh->ifirst; >> - mh->ifirst =3D mh->ifirst->next; >> - if(mh->ifirst=3D=3DNULL) { >> - mh->ilast =3D NULL; >> - } else { >> - mh->ifirst->prev =3D NULL; >> - } >> - mh->csize--; >> + /* empty queue */ >> + lock_release(&mh->lock); >> + return -2; >> + } >> + >> + mp->item =3D mh->ifirst; >> + mh->ifirst =3D mh->ifirst->next; >> + if(mh->ifirst=3D=3DNULL) { >> + mh->ilast =3D NULL; >> + } else { >> + mh->ifirst->prev =3D 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 =3D mq_head_fetch((str*)mq); >> + if(ret<0) >> + return ret; >> return 1; >> } >> >> >> >> >> >> >> _______________________________________________ >> sr-dev mailing list >> sr-dev(a)lists.sip-router.org >> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev > > --===============1220993826==--