Index: /trunk/pdns/pdns/recpacketcache.cc
===================================================================
--- /trunk/pdns/pdns/recpacketcache.cc	(revision 1433)
+++ /trunk/pdns/pdns/recpacketcache.cc	(revision 1456)
@@ -48,19 +48,2 @@
 }
 
-
-// needs to take into account: qname, qtype, opcode, rd, qdcount, EDNS size
-bool RecursorPacketCache::Entry::operator<(const struct RecursorPacketCache::Entry &rhs) const
-{
-  const struct dnsheader* 
-    dh=(const struct dnsheader*) d_packet.c_str(), 
-    *rhsdh=(const struct dnsheader*)rhs.d_packet.c_str();
-  if(make_tuple(dh->opcode, dh->rd, dh->qdcount) < 
-     make_tuple(rhsdh->opcode, rhsdh->rd, rhsdh->qdcount))
-    return true;
-
-  uint16_t qtype, rhsqtype;
-  string qname=questionExpand(d_packet.c_str(), d_packet.length(), qtype);
-  string rhsqname=questionExpand(rhs.d_packet.c_str(), rhs.d_packet.length(), rhsqtype);
-
-  return tie(qtype, qname) < tie(rhsqtype, rhsqname);
-}
Index: /trunk/pdns/pdns/recpacketcache.hh
===================================================================
--- /trunk/pdns/pdns/recpacketcache.hh	(revision 1433)
+++ /trunk/pdns/pdns/recpacketcache.hh	(revision 1456)
@@ -4,5 +4,6 @@
 #include <set>
 #include <inttypes.h>
-
+#include "dns.hh"
+#include "namespaces.hh"
 
 class RecursorPacketCache
@@ -21,5 +22,5 @@
     mutable std::string d_packet; // "I know what I am doing"
 
-    bool operator<(const struct Entry& rhs) const;
+    inline bool operator<(const struct Entry& rhs) const;
   };
   typedef std::set<struct Entry> packetCache_t;
@@ -28,3 +29,28 @@
 };
 
+
+// needs to take into account: qname, qtype, opcode, rd, qdcount, EDNS size
+inline bool RecursorPacketCache::Entry::operator<(const struct RecursorPacketCache::Entry &rhs) const
+{
+  const struct dnsheader* 
+    dh=(const struct dnsheader*) d_packet.c_str(), 
+    *rhsdh=(const struct dnsheader*)rhs.d_packet.c_str();
+  if(make_tuple(dh->opcode, dh->rd, dh->qdcount) < 
+     make_tuple(rhsdh->opcode, rhsdh->rd, rhsdh->qdcount))
+    return true;
+
+  if((d_packet.size() > 13 && rhs.d_packet.size() > 13) &&
+     (d_packet[12] && rhs.d_packet[12]) &&
+     (d_packet[13] < rhs.d_packet[13]))
+    return true;
+							 
+  
+  uint16_t qtype, rhsqtype;
+  string qname=questionExpand(d_packet.c_str(), d_packet.length(), qtype);
+  string rhsqname=questionExpand(rhs.d_packet.c_str(), rhs.d_packet.length(), rhsqtype);
+
+  return tie(qtype, qname) < tie(rhsqtype, rhsqname);
+}
+
+
 #endif
