]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2143]: MySQL DHCP benchmark now works with -Ofast
authorTomek Mrugalski <tomasz@isc.org>
Thu, 30 Aug 2012 08:41:02 +0000 (10:41 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Thu, 30 Aug 2012 08:41:02 +0000 (10:41 +0200)
tests/tools/dhcp-ubench/Makefile
tests/tools/dhcp-ubench/mysql_ubench.cc
tests/tools/dhcp-ubench/mysql_ubench.h

index 4be8fe773b79d6b27fe15cf127a8488b0e8f9834..dbcfadd072b9189c3d255203bae7ccde714b5dec 100644 (file)
@@ -1,5 +1,5 @@
 # Linux switches
-CFLAGS=-g -O0 -Wall -pedantic -Wextra
+CFLAGS=-g -Ofast -Wall -pedantic -Wextra
 
 # Mac OS: We don't use pedantic as Mac OS version of MySQL (5.5.24) does use long long (not part of ISO C++)
 #CFLAGS=-g -O0 -Wall -Wextra -I/opt/local/include
index a3076597c4ebd198c49e9d9e32c5a2d0229a7cb8..b2f58c2e72bd9b66b0b4fe577db4bf570615e8b7 100644 (file)
@@ -34,6 +34,15 @@ MySQL_uBenchmark::MySQL_uBenchmark(const string& hostname, const string& user,
 
 }
 
+void MySQL_uBenchmark::stmt_failure(MYSQL_STMT * stmt, const char* operation) {
+    stringstream tmp;
+    tmp << "Error " << mysql_stmt_errno(stmt) << " during " << operation
+        << ": " << mysql_stmt_error(stmt);
+    throw tmp.str();
+}
+
+
+
 void MySQL_uBenchmark::failure(const char* operation) {
     stringstream tmp;
     tmp << "Error " << mysql_errno(conn_) << " during " << operation
@@ -408,6 +417,7 @@ void MySQL_uBenchmark::searchLease4Test() {
             // 4th parameter: Client-id
             response[3].buffer_type = MYSQL_TYPE_STRING;
             response[3].buffer = &client_id;
+            response[3].buffer_length = sizeof(client_id);
 
             // 5th parameter: valid-lifetime
             response[4].buffer_type = MYSQL_TYPE_LONG;
@@ -444,11 +454,24 @@ void MySQL_uBenchmark::searchLease4Test() {
             }
             int num_rows = 0;
 
-            if (!mysql_stmt_fetch(stmt)) {
+            int result = mysql_stmt_fetch(stmt);
+            switch (result) {
+            case 0: {
                 if (lease_addr != addr) {
                     failure("Returned data is bogus!");
                 }
                 num_rows++;
+                break;
+            }
+            case MYSQL_NO_DATA:
+            {
+                // that's ok. We randomized non-existing address
+                break;
+
+            }
+            default: {
+                stmt_failure(stmt, "RETRIEVE (mysql_stmt_fetch())");
+            }
             }
 
             // we could call mysql_stmt_fetch again to check that there are no
index c9fcc7c39a382ef8d3d7c5ebf6ddc53036b14666..be12fd6fd12d40b38d78fc80c703ffd62ee942dc 100644 (file)
@@ -80,8 +80,25 @@ protected:
     /// Compared to its base version in uBenchmark class, this one logs additional
     /// MySQL specific information using mysql_errno() and mysql_error() functions.
     /// The outcome is the same: exception is thrown.
+    ///
+    /// @param operation brief description of the operation that caused error
+    ///
+    /// @sa stmt_failure()
     void failure(const char* operation);
 
+    /// @brief Used to report compiled statement failures.
+    ///
+    /// Compared to its base version in uBenchmark class, this one logs additional
+    /// MySQL specific information using mysql_stmt_errno() and mysql_stmt_error()
+    /// functions that are used for compiled statements error reporting.
+    ///
+    /// @param stmt MySQL compiled statement structure
+    /// @param operation brief description of the operation that caused error
+    ///
+    /// @sa failure()
+    void stmt_failure(MYSQL_STMT * stmt, const char* operation);
+
+
     /// Handle to MySQL database connection.
     MYSQL* conn_;
 };