<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Consolas",serif;
        color:black;
        mso-fareast-language:EN-US;}
span.EmailStyle23
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Happy to contribute back if I can, where are the current contribution standards and style guides located?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-GB">From:</span></b><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-GB"> sr-dev [mailto:sr-dev-bounces@lists.sip-router.org]
<b>On Behalf Of </b>Daniel-Constantin Mierla<br>
<b>Sent:</b> 09 February 2016 14:37<br>
<b>To:</b> Kamailio (SER) - Development Mailing List <sr-dev@lists.sip-router.org><br>
<b>Subject:</b> Re: [sr-dev] DB Reconnect behaviour in db_unixodbc module<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hello,<span style="font-size:12.0pt;mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<div>
<p class="MsoNormal">On 09/02/16 14:05, Tim Chubb wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="color:#1F497D">Answer own question, re-read c docs and remember how rust my c skills are…</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D">I think the !strncmp was throwing me, to think “if not equal to this or that, then reconnect” rather than !strncmp being short hand for strncmp(…)==0.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D">With that cleared up in my mind I’m still at a loss as to why only have 2 out of 6 status’s deemed worthy of a reconnect attempt.</span><o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:EN-GB">If you think more error codes should be handled in this case, make a pull request on github to be reviewed and it will be accepted if all ok.
 The unixodbc module was developed quite a while ago (like 2005), the initial developer has been inactive for long time, so maybe some error codes were overlooked or not available in the version at that moment. But as usual, we are happy to accept contributions
 to enhance any part of kamailio.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="color:#1F497D"> </span><o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="mso-fareast-language:EN-GB">From:</span></b><span lang="EN-US" style="mso-fareast-language:EN-GB"> sr-dev [<a href="mailto:sr-dev-bounces@lists.sip-router.org">mailto:sr-dev-bounces@lists.sip-router.org</a>]
<b>On Behalf Of </b>Tim Chubb<br>
<b>Sent:</b> 09 February 2016 12:49<br>
<b>To:</b> Kamailio (SER) - Development Mailing List <a href="mailto:sr-dev@lists.sip-router.org">
<sr-dev@lists.sip-router.org></a><br>
<b>Subject:</b> [sr-dev] DB Reconnect behaviour in db_unixodbc module</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Hi<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Can someone explain the reasoning behind not reconnecting when an ODBC error code of ‘08003’ or ‘08S01’ is received back in modules/db_unixodbc/dbase.c?<o:p></o:p></p>
<p class="MsoNormal">Such as on lines 120 and 121?<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">/* Connection broken */<o:p></o:p></p>
<p class="MsoNormal">if( !strncmp((char*)sqlstate,"08003",5) ||<o:p></o:p></p>
<p class="MsoNormal">!strncmp((char*)sqlstate,"08S01",5) ) {<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt">ret = reconnect(_h);<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt">if( !SQL_SUCCEEDED(ret) ) return ret;<o:p></o:p></p>
<p class="MsoNormal">} else {<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt">return ret;<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Those error codes equate to Communication link failure and Connection not open both of which are easily handled by a reconnect?<o:p></o:p></p>
<p class="MsoNormal">As that logic is used in a few places in dbase.c I figure there must be a reason to exclude those errors from a reconnect, but permit other non-connection related errors to trigger a reconnect?  If the intent was to only allow connection
 based error codes to attempt a reconnect then wouldn’t it make more sense to explicitly define the half dozen or so ODBC connection specific error codes  (the 08xxx range denotes connection related errors) and only permit the ones which could be repaired by
 a reconnect?<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">08001 Client unable to establish connection - Can be caused by transient network issue, so a reconnect attempt is valid<o:p></o:p></p>
<p class="MsoNormal">08002 Connection name in use - Reconnect probably wouldnt help here<o:p></o:p></p>
<p class="MsoNormal">08003 Connection not open - Reconnect would reopen connection<o:p></o:p></p>
<p class="MsoNormal">08004 Server rejected the connection - Can be caused by transient network issue such as a reboot, so a reconnect attempt is valid<o:p></o:p></p>
<p class="MsoNormal">08007 Connection failure during transaction  - Can be caused by transient network issue, so a reconnect attempt is valid<o:p></o:p></p>
<p class="MsoNormal">08S01 Communication link failure - Can be caused by transient network issue, so a reconnect attempt is valid<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">ODBC Error code definitions: <a href="https://msdn.microsoft.com/en-us/library/ms714687%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396">
https://msdn.microsoft.com/en-us/library/ms714687%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396</a><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Of those 6 possible connection related errors only 08002 wouldn’t be helped by a reconnect although a new connection could replace the one its attempting to use…<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:EN-GB"><br>
<br>
<br>
<o:p></o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>sr-dev mailing list<o:p></o:p></pre>
<pre><a href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a><o:p></o:p></pre>
<pre><a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:EN-GB"><br>
<br>
<o:p></o:p></span></p>
<pre>-- <o:p></o:p></pre>
<pre>Daniel-Constantin Mierla<o:p></o:p></pre>
<pre><a href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a><o:p></o:p></pre>
<pre>Book: SIP Routing With Kamailio - <a href="http://www.asipto.com">http://www.asipto.com</a><o:p></o:p></pre>
<pre><a href="http://miconda.eu">http://miconda.eu</a><o:p></o:p></pre>
</div>
</body>
</html>