[asterisk-dev] reference count on ast_netsock objects

Frédérick Lefebvre fred.lefebvre at gmail.com
Sat Jul 1 07:22:41 MST 2006


Hi All,

I'm not sure if this question is stricly related to the ast_netsock  
library or the chan_iax2 but here it goes.
netsock provides the ast_netsock_unref function to decrease the  
reference counter on ast_netsock structures.  But nothing is provided  
to increase the reference count, so that the only time it is  
increased is when ast_netsock_bindaddr (called from  
ast_netsock_bind), add a ast_netsock to the the ast_netsock_list it  
received in parameter.
chan_iax2 never instantiate itself an ast_netsock object but receives  
pointers to ast_netsock objects from other functions.  For example,  
in set_config, it gets a pointer from ast_netsock_bind which as just  
instantiate a ast_netsock structure.  And a couple of lines later, it  
calls ast_netsock_unref to decrease the reference count, even through,
1- It's not really dereferencing the pointer.
      This point is meaningless, since in practice the pointer will  
either be
      overwriten or go out of scope
2- It never incremented the reference count in the first place.

I'm concerned about point '2'.  Did I miss something in my analysis  
or does the reference count on ast_netsock objects quickly become  
irrelevant?

Thank's for your help!

Fred



More information about the asterisk-dev mailing list