Ticket #5061: mysql_connection.cc.diff

File mysql_connection.cc.diff, 1.4 KB (added by parisioa, 3 years ago)

The patch we applied to add this configuration option.

  • third-party-src/src/lib/dhcpsrv/mysql_connection.cc

    diff --git a/third-party-src/src/lib/dhcpsrv/mysql_connection.cc b/third-party-src/src/lib/dhcpsrv/mysql_connection.cc
    index 06162bd..cc343fc 100644
    a b MySqlConnection::openDatabase() { 
    6565        // No host.  Fine, we'll use "localhost"
    6666    }
    6767
     68    unsigned int port = 0;
     69    string sport;
     70    try {
     71        sport = getParameter("port");
     72    } catch (...) {
     73        // No port parameter, we are going to use the default port.
     74        sport = "";
     75    }
     76
     77    if (sport.size() > 0) {
     78        // port was given, so try to convert it to an integer.
     79
     80        try {
     81            port = boost::lexical_cast<unsigned int>(sport);
     82        } catch (...) {
     83        }
     84    }
     85
    6886    const char* user = NULL;
    6987    string suser;
    7088    try {
    MySqlConnection::openDatabase() { 
    172190    // because no row matching the WHERE clause was found, or because a
    173191    // row was found but no data was altered.
    174192    MYSQL* status = mysql_real_connect(mysql_, host, user, password, name,
    175                                        0, NULL, CLIENT_FOUND_ROWS);
     193                                       port, NULL, CLIENT_FOUND_ROWS);
    176194    if (status != mysql_) {
    177195        isc_throw(DbOpenError, mysql_error(mysql_));
    178196    }