[asterisk-dev] [Code Review] [patch] Improve debug of ast_hangup

schmidts reviewboard at asterisk.org
Fri Dec 23 08:43:07 CST 2011


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


i have walked about this review and i think it would be the easiest way to use a common flag for debuging like DEV_MODE.

then the patch would look like this:

Index: include/asterisk/channel.h
===================================================================
--- include/asterisk/channel.h	(Revision 348991)
+++ include/asterisk/channel.h	(Arbeitskopie)
@@ -1421,8 +1421,15 @@
  * \param chan channel to hang up
  * \return Returns 0 on success, -1 on failure.
  */
-int ast_hangup(struct ast_channel *chan);
+#ifdef AST_DEVMODE
+#define ast_hangup(chan)	__ast_hangup_debug(chan,__PRETTY_FUNCTION__,__FILE__,__LINE__)
+#else
+#define ast_hangup(chan)	__ast_hangup(chan)
+#endif
 
+int __ast_hangup_debug(struct ast_channel *chan, const char *func, const char *file, const int line);
+int __ast_hangup(struct ast_channel *chan);
+
 /*!
  * \brief Softly hangup up a channel
  *
Index: main/channel.c
===================================================================
--- main/channel.c	(Revision 348991)
+++ main/channel.c	(Arbeitskopie)
@@ -2771,8 +2771,19 @@
 	}
 }
 
+
+/*! \brief Debug output whom started Hangup on a channel */
+int __ast_hangup_debug(struct ast_channel *chan, const char *func, const char *file, const int line)
+{
+
+	if (!chan->masq) {
+		ast_debug(1, "Starting hangup process  on channel '%s' - called by %s() in %s, line %d\n", chan->name, func, file, line);
+	}
+	return __ast_hangup(chan);
+}
+
 /*! \brief Hangup a channel */
-int ast_hangup(struct ast_channel *chan)
+int __ast_hangup(struct ast_channel *chan)
 {
 	char extra_str[64]; /* used for cel logging below */

still very easy but it really could help to find some issues easier.

- schmidts


On April 7, 2011, 6:21 a.m., Olle E Johansson wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1164/
> -----------------------------------------------------------
> 
> (Updated April 7, 2011, 6:21 a.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> In many cases when I develop crazy code, I get weird hangups. It may only happen to me, but it does happen. I need to know when a hangup process is initiated and by whom. This small patch is a first step towards that goal.
> 
> 
> This addresses bug 19080.
>     https://issues.asterisk.org/jira/browse/19080
> 
> 
> Diffs
> -----
> 
>   /trunk/include/asterisk/channel.h 313005 
>   /trunk/main/channel.c 313005 
> 
> Diff: https://reviewboard.asterisk.org/r/1164/diff
> 
> 
> Testing
> -------
> 
> Tested in various versions of Asterisk. Seems to give me the output I need.
> 
> 
> Thanks,
> 
> Olle E
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20111223/4ac2d7e3/attachment.htm>


More information about the asterisk-dev mailing list