<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    <div class="moz-cite-prefix">On 09/02/16 14:05, Tim Chubb wrote:<br>
    </div>
    <blockquote
cite="mid:AMSPR07MB264E65754E1382E95703922EFD60@AMSPR07MB264.eurprd07.prod.outlook.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <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]-->
      <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.</span></p>
      </div>
    </blockquote>
    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>
    <blockquote
cite="mid:AMSPR07MB264E65754E1382E95703922EFD60@AMSPR07MB264.eurprd07.prod.outlook.com"
      type="cite">
      <div class="WordSection1">
        <p class="MsoNormal"><span style="color:#1F497D"><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
                  style="mso-fareast-language:EN-GB" lang="EN-US">From:</span></b><span
                style="mso-fareast-language:EN-GB" lang="EN-US"> sr-dev
                [<a class="moz-txt-link-freetext" 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 class="moz-txt-link-rfc2396E" 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<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
            moz-do-not-send="true"
href="https://msdn.microsoft.com/en-us/library/ms714687%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396"><a class="moz-txt-link-freetext" 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></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>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
sr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Book: SIP Routing With Kamailio - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://miconda.eu">http://miconda.eu</a></pre>
  </body>
</html>