chan_sip: Simplify dialog/peer references, improve REF_DEBUG output.

* Replace functions for ref/undef of dialogs and peers with macro's
  to call ao2_t_bump/ao2_t_cleanup.
* Enable passthough of REF_DEBUG caller information to sip_alloc and
  find_call.

ASTERISK-24882 #close 
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4189/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433115 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Corey Farrell
2015-03-19 09:53:37 +00:00
parent 7fddae99dd
commit 958bc84caf
3 changed files with 35 additions and 84 deletions

View File

@@ -29,13 +29,16 @@
* functions so we keep track of the refcounts.
* To simplify the code, we allow a NULL to be passed to dialog_unref().
*/
#define dialog_ref(arg1,arg2) dialog_ref_debug((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define dialog_unref(arg1,arg2) dialog_unref_debug((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
struct sip_pvt *dialog_ref_debug(struct sip_pvt *p, const char *tag, char *file, int line, const char *func);
struct sip_pvt *dialog_unref_debug(struct sip_pvt *p, const char *tag, char *file, int line, const char *func);
#define dialog_ref(dialog, tag) ao2_t_bump(dialog, tag)
#define dialog_unref(dialog, tag) ({ ao2_t_cleanup(dialog, tag); (NULL); })
struct sip_pvt *__sip_alloc(ast_string_field callid, struct ast_sockaddr *sin,
int useglobal_nat, const int intended_method, struct sip_request *req, struct ast_callid *logger_callid,
const char *file, int line, const char *func);
#define sip_alloc(callid, addr, useglobal_nat, intended_method, req, logger_callid) \
__sip_alloc(callid, addr, useglobal_nat, intended_method, req, logger_callid, __FILE__, __LINE__, __PRETTY_FUNCTION__)
struct sip_pvt *sip_alloc(ast_string_field callid, struct ast_sockaddr *sin,
int useglobal_nat, const int intended_method, struct sip_request *req, struct ast_callid *logger_callid);
void sip_scheddestroy_final(struct sip_pvt *p, int ms);
void sip_scheddestroy(struct sip_pvt *p, int ms);
int sip_cancel_destroy(struct sip_pvt *p);

View File

@@ -1869,14 +1869,7 @@ void sip_auth_headers(enum sip_auth_type code, char **header, char **respheader)
const char *sip_get_header(const struct sip_request *req, const char *name);
const char *sip_get_transport(enum ast_transport t);
#ifdef REF_DEBUG
#define sip_ref_peer(arg1,arg2) _ref_peer((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define sip_unref_peer(arg1,arg2) _unref_peer((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
struct sip_peer *_ref_peer(struct sip_peer *peer, char *tag, char *file, int line, const char *func);
void *_unref_peer(struct sip_peer *peer, char *tag, char *file, int line, const char *func);
#else
struct sip_peer *sip_ref_peer(struct sip_peer *peer, char *tag);
void *sip_unref_peer(struct sip_peer *peer, char *tag);
#endif /* REF_DEBUG */
#define sip_ref_peer(peer, tag) ao2_t_bump(peer, tag)
#define sip_unref_peer(peer, tag) ({ ao2_t_cleanup(peer, tag); (NULL); })
#endif