[prev in list] [next in list] [prev in thread] [next in thread]
List: asterisk-dev
Subject: Re: [asterisk-dev] [Code Review] Add update callback to dnsmgr since chan_sip peers need to be re-li
From: "Mark Michelson" <reviewboard () asterisk ! org>
Date: 2012-01-30 18:01:44
Message-ID: 20120130180144.5866.52955 () hotblack ! digium ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1691/#review5353
-----------------------------------------------------------
Ship it!
Looking good!
- Mark
On Jan. 27, 2012, 3:51 p.m., Terry Wilson wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1691/
> -----------------------------------------------------------
>
> (Updated Jan. 27, 2012, 3:51 p.m.)
>
>
> Review request for Asterisk Developers.
>
>
> Summary
> -------
>
> Asterisk's dnsmgr currently takes a pointer to an ast_sockaddr and updates it \
> anytime an address resolves to something different. There are a couple of issues \
> with this. First, the ast_sockaddr is usually the address of an ast_sockaddr inside \
> a refcounted struct and we never bump the refcount of those structs when using \
> dnsmgr. This makes it possible that a refresh could happen after the destructor for \
> that object is called (despite ast_dnsmgr_release being called in that destructor). \
> Second, the module using dnsmgr cannot be aware of an address changing without \
> polling for it in the code. If an action needs to be taken on address update (like \
> re-linking a SIP peer in the peers_by_ip table), then polling for this change \
> negates many of the benefits of having dnsmgr in the first place.
> This patch adds an update callback that is called if a pointer to a callback \
> function is provided to ast_dnsmgr_lookup(). It also moves calls to \
> ast_dnsmgr_release outside of the destructor functions and into cleanup functions \
> that are called when we no longer need the objects and increments the refcount of \
> the objects using dnsmgr since those objects are stored on the ast_dnsmgr_entry \
> struct. A helper function for returning the proper default SIP port (non-tls vs \
> tls) is also added and used.
> The current implementation in the patch is backward compatible with code that \
> doesn't use the update callback. Seeing as this is only two calls in chan_iax2, it \
> might be better to just update chan_iax2 and insist on using the update callback. \
> This would allow us to stop passing in the ast_sockaddr pointer altogether. I'll \
> update the documentation of the dnsmgr functions (and CHANGES) after we decide on \
> the aforementioned point.
> This patch also builds on the registry fixes suggested Timo Teräs in issue \
> ASTERISK-19106 re: the port number being 0 after a dnsmgr update.
>
> This addresses bug ASTERISK-19106.
> https://issues.asterisk.org/jira/browse/ASTERISK-19106
>
>
> Diffs
> -----
>
> /branches/1.8/channels/chan_sip.c 352551
> /branches/1.8/include/asterisk/dnsmgr.h 352519
> /branches/1.8/main/dnsmgr.c 352519
>
> Diff: https://reviewboard.asterisk.org/r/1691/diff
>
>
> Testing
> -------
>
> I have tested registration via register => x@peer and via peers defined with \
> callbackextension by having the host=invalid.address and selectively defining \
> invalid.address in /etc/hosts with and without dnsmgr enabled. Timo Teräs in \
> ASTERISK-19106 also reports that it fixes the issues he was experiencing.
>
> Thanks,
>
> Terry
>
>
[Attachment #5 (text/html)]
<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;"> <tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/1691/">https://reviewboard.asterisk.org/r/1691/</a>
</td>
</tr>
</table>
<br />
<p>Ship it!</p>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Looking good!</pre> <br \
/>
<p>- Mark</p>
<br />
<p>On January 27th, 2012, 3:51 p.m., Terry Wilson wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;"> <tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By Terry Wilson.</div>
<p style="color: grey;"><i>Updated Jan. 27, 2012, 3:51 p.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">Asterisk's dnsmgr currently takes a pointer to an ast_sockaddr and \
updates it anytime an address resolves to something different. There are a couple of \
issues with this. First, the ast_sockaddr is usually the address of an ast_sockaddr \
inside a refcounted struct and we never bump the refcount of those structs when using \
dnsmgr. This makes it possible that a refresh could happen after the destructor for \
that object is called (despite ast_dnsmgr_release being called in that destructor). \
Second, the module using dnsmgr cannot be aware of an address changing without \
polling for it in the code. If an action needs to be taken on address update (like \
re-linking a SIP peer in the peers_by_ip table), then polling for this change negates \
many of the benefits of having dnsmgr in the first place.
This patch adds an update callback that is called if a pointer to a callback function \
is provided to ast_dnsmgr_lookup(). It also moves calls to ast_dnsmgr_release outside \
of the destructor functions and into cleanup functions that are called when we no \
longer need the objects and increments the refcount of the objects using dnsmgr since \
those objects are stored on the ast_dnsmgr_entry struct. A helper function for \
returning the proper default SIP port (non-tls vs tls) is also added and used.
The current implementation in the patch is backward compatible with code that \
doesn't use the update callback. Seeing as this is only two calls in chan_iax2, \
it might be better to just update chan_iax2 and insist on using the update callback. \
This would allow us to stop passing in the ast_sockaddr pointer altogether. I'll \
update the documentation of the dnsmgr functions (and CHANGES) after we decide on the \
aforementioned point.
This patch also builds on the registry fixes suggested Timo Teräs in issue \
ASTERISK-19106 re: the port number being 0 after a dnsmgr update.</pre> </td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">I have tested registration via register => x@peer and via peers \
defined with callbackextension by having the host=invalid.address and selectively \
defining invalid.address in /etc/hosts with and without dnsmgr enabled. Timo Teräs \
in ASTERISK-19106 also reports that it fixes the issues he was experiencing.</pre> \
</td> </tr>
</table>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-19106">ASTERISK-19106</a>
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/1.8/channels/chan_sip.c <span style="color: grey">(352551)</span></li>
<li>/branches/1.8/include/asterisk/dnsmgr.h <span style="color: \
grey">(352519)</span></li>
<li>/branches/1.8/main/dnsmgr.c <span style="color: grey">(352519)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1691/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
--
_____________________________________________________________________
-- 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