<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/1703/">https://reviewboard.asterisk.org/r/1703/</a>
</td>
</tr>
</table>
<br />
<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>
<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;">SIP realtime, upon peer destruction, tries to clear some values by updating the peer with empty string values. This works if those values are character fields or if the database automagically translates an empty string to a NULL or 0 when confronted with an integer field. PostgreSQL does not do this translation and returns an error (even if called through res_config_odbc). lastms is defined as an integer in both the mysql and postgresql realtime SQL files.
Looking at where lastms is set in chan_sip (handle_response_peerpoke) it is clear that the default value of lastms is 0 and that 0 means unknown, while -1 means unreachable. So, like regseconds, the update for destruction should be passing "0" for a value instead of "". The fields could be changed to character fields, but this would still require us to interpret an empty string as a 0 value. This patch changes the destruction update to pass a value of "0" for lastms.
Other issues in chan_sip include setting the ipaddr and port to the string "(null)" when they are null instead of an empty string which is what is expected (thanks to ast_sockaddr_stringify returning "(null)" for a null sockaddr). This patch checks the values of ast_sockaddr_isnull() and ast_sockaddr_port and passes empty strings when appropriate.
The postgresql realtime.sql file has been updated to set the correct default of '0' for lastms, lengthen the ipaddr field (which was too short for the longest possible IPv6 address), and add the missing defaultuser, fullcontact, regserver, and useragent fields.</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;">Under res_config_pgsql and res_config_odbc, verified that registering and unregistering a peer no longer produces any SQL errors.</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-19172">ASTERISK-19172</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">(353501)</span></li>
<li>/branches/1.8/contrib/realtime/postgresql/realtime.sql <span style="color: grey">(353501)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1703/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>