<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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        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;}
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;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle20
        {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 lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Answer own question, re-read c docs and remember how rust my c skills are…<o:p></o:p></span></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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></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.<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="mso-fareast-language:EN-GB">From:</span></b><span lang="EN-US" style="mso-fareast-language:EN-GB"> sr-dev [mailto:sr-dev-bounces@lists.sip-router.org]
<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 <sr-dev@lists.sip-router.org><br>
<b>Subject:</b> [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">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>
</div>
</body>
</html>