BIND 10 #2821: MySQLLeaseManager does not close db if constructor fails

BIND 10 Development do-not-reply at isc.org
Thu Mar 7 11:18:23 UTC 2013


#2821: MySQLLeaseManager does not close db if constructor fails
-------------------------------------+-------------------------------------
            Reporter:  jelte         |                        Owner:  jelte
                Type:  defect        |                       Status:
            Priority:  medium        |  reviewing
           Component:  Unclassified  |                    Milestone:
            Keywords:                |  Sprint-DHCP-20130328
           Sensitive:  0             |                   Resolution:
         Sub-Project:  DNS           |                 CVSS Scoring:
Estimated Difficulty:  0             |              Defect Severity:  N/A
         Total Hours:  0             |  Feature Depending on Ticket:
                                     |          Add Hours to Ticket:  0
                                     |                    Internal?:  0
-------------------------------------+-------------------------------------
Changes (by stephen):

 * owner:  stephen => jelte


Comment:

 Reviewed commit 21dae0aa029e8d549c8ba4d5bffeb10ef341f17d

 I'm not happy with the "release" mechanism - it's somewhat inelegant.  On
 reflection, I think agree with the comment in the commit, that it would be
 better to completely encapsulate the database handle in an RAII class
 (perhaps a subclass of !MySqlLeaseMgr) along the lines of:
 {{{
 class MySqlHolder {
 public:
      MySqlHolder() : mysql_(mysql_init(NULL)) {
          if (mysql_ == NULL) {
              isc_throw(DbOpenError, "unable to initialize MySQL");
          }
      }


     ~MySqlHolder() {
         if (mysql_ != NULL) {
             mysql_close(mysql_);
         }
     }

     operator MYSQL*() const {
         return mysql_;
     }

 private:
     MYSQL* mysql_;
 };
 }}}
 I don't think the changes needed would be extensive.  Could we please
 implement this?

-- 
Ticket URL: <http://bind10.isc.org/ticket/2821#comment:5>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list