Browse Source

[3689] Changed AllocEngine::allocateLeases6 to not reset context hostname

src/lib/dhcpsrv/alloc_engine.cc
    AllocEngine::allocateLeases6() - now only sets context host name
    if findReservation() is called.  This was stomping on the value
    already in the context.
Thomas Markwalder 10 years ago
parent
commit
ac6651e0ee
1 changed files with 11 additions and 7 deletions
  1. 11 7
      src/lib/dhcpsrv/alloc_engine.cc

+ 11 - 7
src/lib/dhcpsrv/alloc_engine.cc

@@ -349,16 +349,20 @@ AllocEngine::allocateLeases6(ClientContext6& ctx, bool find_reservation) {
             isc_throw(InvalidOperation, "DUID is mandatory for IPv6 lease allocation");
         }
 
+        /// @todo This is ONLY used for unit tests and really should be taken out
+        /// Currently production code passes in find_reservation as false
         if (find_reservation) {
+            std::cout << "***** TKM findReservation being called from allocateLeases6"
+                        << std::endl;
             findReservation(ctx);
-        }
 
-        // Let's check whether there's a hostname specified in the reservation
-        if (ctx.host_) {
-            std::string hostname = ctx.host_->getHostname();
-            // If there is, let's use it
-            if (!hostname.empty()) {
-                ctx.hostname_ = hostname;
+            // Let's check whether there's a hostname specified in the reservation
+            if (ctx.host_) {
+                std::string hostname = ctx.host_->getHostname();
+                // If there is, let's use it
+                if (!hostname.empty()) {
+                    ctx.hostname_ = hostname;
+                }
             }
         }