[prev in list] [next in list] [prev in thread] [next in thread] 

List:       asterisk-dev
Subject:    Re: [asterisk-dev] [Code Review] Dialplan function for manager
From:       "Mark Michelson" <mmichelson () digium ! com>
Date:       2010-07-28 16:09:13
Message-ID: 20100728160913.9645.42458 () hotblack ! digium ! com
[Download RAW message or body]



> On 2010-07-28 10:48:04, Tilghman Lesher wrote:
> > /trunk/main/manager.c, lines 6068-6077
> > <https://reviewboard.asterisk.org/r/421/diff/3/?file=11951#file11951line6068>
> > 
> > btw, there's a good reason to implement this as a callback.  There's a possible \
> > race condition here that could make this function return the wrong value: 
> > 1. Lock container.
> > 2. Store container version.
> > 3. Unlock container.
> > LOOP:
> > 4. Lock container.
> > 5. Compare container version.  If changed, restart loop.  Else get next item in \
> > container. 6. Unlock container.
> > 7. Return item.
> > 8. Increment no_sessions.
> > 9. Goto LOOP.
> > 
> > If the container version changes, which occurs each time that an item is either \
> > added to or removed from the container, then the loop could be restarted, which \
> > isn't a big deal, if you are, for example, comparing values (it just takes \
> > slightly longer), but it's a very big deal if you're incrementing a monotonically \
> > incrementing integer, whose value is the entire point of the function.  Each time \
> > the container is unlocked, there's a potential for an item to be added or removed \
> > from the container at that time.
> 
> Olle E Johansson wrote:
> Does code like this exist anywhere? I need some examples.

One example would be in trunk/main/ccss.c, ast_cc_monitor_count(). This function uses \
ao2_t_callback() to visit each member of a container, and increment a counter under \
the correct circumstances. The code listed here seems to be a similar operation.


- Mark


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/421/#review2483
-----------------------------------------------------------


On 2010-07-28 04:20:49, Olle E Johansson wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/421/
> -----------------------------------------------------------
> 
> (Updated 2010-07-28 04:20:49)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> Implementation of a dialplan function for checking manager accounts. I've made it \
> extensible so that we can add other parameters when needed. Right now it only \
> checks the number of logged in sessions for a manager account. 
> 
> Diffs
> -----
> 
> /trunk/main/manager.c 280055 
> 
> Diff: https://reviewboard.asterisk.org/r/421/diff
> 
> 
> Testing
> -------
> 
> Tested on my Linux system and it reports manager logins properly - 0, 1 and 2 \
> concurrent sessions... 
> 
> Thanks,
> 
> Olle E
> 
> 


-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic