[Asterisk-Users] Is a BUG ? Hints and incominglimit

Paradise Dove pardove at gmail.com
Sat Dec 3 00:07:36 MST 2005


hi,
This is the new update_call_counter() which works fine for me:

/*! \brief  update_call_counter: Handle call_limit for SIP users
 * Note: This is going to be replaced by app_groupcount
 * Thought: For realtime, we should propably update storage with inuse
counter... */
static int update_call_counter(struct sip_pvt *fup, int event)
{
    char name[256];
    int *inuse, *call_limit;
    int outgoing = ast_test_flag(fup, SIP_OUTGOING);
    struct sip_user *u = NULL;
    struct sip_peer *p = NULL;

    if (option_debug > 2)
        ast_log(LOG_DEBUG, "Updating call counter for %s call\n",
outgoing ? "outgoing" : "incoming");
    /* Test if we need to check call limits, in order to avoid
       realtime lookups if we do not need it */
    if (!ast_test_flag(fup, SIP_CALL_LIMIT))
        return 0;

    ast_copy_string(name, fup->username, sizeof(name));

    /* Check the list of users */
    // paradise dove
    p = find_peer(name, NULL, 1);
    if (p) {
        inuse = &p->inUse;
        call_limit = &p->call_limit;
    } else if (!u) {
        /* Try to find user */
        u = find_user(name, 1);
        if (u) {
          inuse = &u->inUse;
          call_limit = &u->call_limit;
        } else {
            if (option_debug > 1)
                ast_log(LOG_DEBUG, "%s is not a local user, no call
limit\n", name);
            return 0;
        }
    }
    switch(event) {
        /* incoming and outgoing affects the inUse counter */
        case DEC_CALL_LIMIT:
            if ( *inuse > 0 ) {
                (*inuse)--;
            } else {
                *inuse = 0;
            }
            if (option_debug > 1 || sipdebug) {
                ast_log(LOG_DEBUG, "Call %s %s '%s' removed from call
limit %d\n", outgoing ? "to" : "from", u ? "user":"peer"
            }
            break;
        case INC_CALL_LIMIT:
            if (*call_limit > 0 ) {
                if (*inuse >= *call_limit) {
                    ast_log(LOG_ERROR, "Call %s %s '%s' rejected due
to usage limit of %d\n", outgoing ? "to" : "from", u ? "u
                    // paradise dove
                    if (p)
                        ASTOBJ_UNREF(p,sip_destroy_peer);
                    else if (u)
                        ASTOBJ_UNREF(u,sip_destroy_user);
                    return -1;
                }
            }
            (*inuse)++;
            if (option_debug > 1 || sipdebug) {
                ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of
%d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *in
            }
            break;
        default:
            ast_log(LOG_ERROR, "update_call_counter(%s, %d) called
with no event!\n", name, event);
    }
    // paradise dove
    if (p)
        ASTOBJ_UNREF(p,sip_destroy_peer);
    else if (u)
        ASTOBJ_UNREF(u,sip_destroy_user);
    return 0;
}

Paradise Dove


On 12/2/05, Alvaro Parres <aparres at gmail.com> wrote:
> Could you send it patch please.
>
>
>
>
> On 11/30/05, Paradise Dove <pardove at gmail.com> wrote:
> >
> > btw, i've patched this part of code and now its working fine for me.
> > i'm going to upload it.
> >
> > Paradise Dove
> >
> > On 11/30/05, Kevin Hanson <tuxpert at comcast.net> wrote:
> > > Paradise Dove wrote:
> > >
> > > >>Yes with version 1.2. I have tried already with call-limit and the
> same.
> > > >>
> > > >>
> > > >i agree with you, it seems to be a bug which i've submited before (bug
> > > >#5281) but it's now closed by bug marshals!!!!!
> > > >
> > > >
> > > >
> > > It's not closed.  It's suspended waiting input from you:
> > >
> > > "Closing until the appropriate debug/trace output can be provided."
> > >
> > > On 10/30 you said you were still trying to get the debug output.
> > >
> > > Cheers,
> > > Kevin
> > > _______________________________________________
> > > --Bandwidth and Colocation provided by Easynews.com --
> > >
> > > Asterisk-Users mailing list
> > > To UNSUBSCRIBE or update options visit:
> > >
> http://lists.digium.com/mailman/listinfo/asterisk-users
> > >
> > _______________________________________________
> > --Bandwidth and Colocation provided by Easynews.com --
> >
> > Asterisk-Users mailing list
> > To UNSUBSCRIBE or update options visit:
> >
> http://lists.digium.com/mailman/listinfo/asterisk-users
> >
>
>
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> Asterisk-Users mailing list
> To UNSUBSCRIBE or update options visit:
>
> http://lists.digium.com/mailman/listinfo/asterisk-users
>
>
>



More information about the asterisk-users mailing list