<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/1840/">https://reviewboard.asterisk.org/r/1840/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On April 5th, 2012, 2:56 p.m., <b>Matt Jordan</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/1840/diff/1/?file=26989#file26989line87" style="color: black; font-weight: bold; text-decoration: underline;">/trunk/main/udptl.c</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static int udptldebug;         /*!< Are we debugging? */</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">87</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="k">static</span> <span class="kt">int</span> <span class="n">udptldebug</span><span class="p">;</span>         <span class="cm">/*!< Are we debugging? */</span></pre></td>
<th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">85</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="k">static</span> <span class="kt">int</span> <span class="n">udptldebug</span><span class="p">;</span>         <span class="cm">/*!< Are we debugging? */</span></pre></td>
</tr>
<tr>
<th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">88</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="k">static</span> <span class="k">struct</span> <span class="n">ast_sockaddr</span> <span class="n">udptldebugaddr</span><span class="p">;</span> <span class="cm">/*!< Debug packets to/from this host */</span></pre></td>
<th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">86</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="k">static</span> <span class="k">struct</span> <span class="n">ast_sockaddr</span> <span class="n">udptldebugaddr</span><span class="p">;</span> <span class="cm">/*!< Debug packets to/from this host */</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This is a bit picky and possibly not worth the effort, but the debug settings should theoretically probably be contained in udptl_global_options as well.
When a CLI command is used to turn debug on/off, its operating on a separate thread then whatever is going to actually use the debug flags. This puts us in a condition where the udptldebug flag could be enabled, but we have not yet fully initialized udptldebugaddr.
One way of doing this would be to obtain a reference to the current config object in the CLI command, lock it, update the values, and unlock it. Since these values change on a thread other then a reload, we'd have to lock the config object anytime we wanted to read values from it as well (or at least the debug values).
Alternatively, we could do a clone and swap - grab the config object in the CLI command, make a copy of it, populate it with the new debug values, and swap it with the new one. That'd be a lot less locking and less impact on the rest of the code.</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I would much rather handle non-config-related state in a separate object. In my opinion, config-holding objects should only be written to by the config code (which will generally be protected by a module-level "reload lock"). If we only have one non-config-related thing that needs to be protected by a lock, making every use of the config object require locking seems like making the default case too complex.
I also don't like clone/copy functions very much since you have to know how to copy every single type stored in the struct and it is always a pain to keep up with. People add fields and forget to update the copy/clone functions, etc. I really don't want to require anyone working with config stuff to have to go down that route if at all possible.</pre>
<br />
<p>- Terry</p>
<br />
<p>On April 2nd, 2012, 2:06 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 and Matt Jordan.</div>
<div>By Terry Wilson.</div>
<p style="color: grey;"><i>Updated April 2, 2012, 2:06 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;">This patch builds off of https://reviewboard.asterisk.org/r/1455/.
The differences are:
1) Uses the global ao2 object API to store config values and to make reloads thread-safe
2) Uses ast_parse_arg() where appropriate
3) Updates ast_parse_arg to be able to set defaults to the min/max range value on range errors
4) Adds CLI command 'udptl show config'</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;">1) Used the new 'udptl show config' command to verify that settings looked right on load/reload.
2) Did testing with 'memory show summary config.c/udptl.c' with loads/reloads to verify there are no leaks
3) Loaded with no config file to verify that default values were used</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/trunk/include/asterisk/config.h <span style="color: grey">(360980)</span></li>
<li>/trunk/main/config.c <span style="color: grey">(360980)</span></li>
<li>/trunk/main/udptl.c <span style="color: grey">(360980)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1840/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>