mem: Delay deleting of incoming packets by one call.
[gem5.git] / src / mem / tport.cc
index db2c72bbc64016fe5e037d0160b60163550a331d..1ce3b4dc2e7b83cc11f2653db1f504ed6a2e0cad 100644 (file)
@@ -53,7 +53,6 @@ SimpleTimingPort::SimpleTimingPort(const std::string& _name,
 void
 SimpleTimingPort::recvFunctional(PacketPtr pkt)
 {
-    assert(pkt->isRequest());
     if (!queue.checkFunctional(pkt)) {
         // do an atomic access and throw away the returned latency
         recvAtomic(pkt);
@@ -61,10 +60,13 @@ SimpleTimingPort::recvFunctional(PacketPtr pkt)
 }
 
 bool
-SimpleTimingPort::recvTiming(PacketPtr pkt)
+SimpleTimingPort::recvTimingReq(PacketPtr pkt)
 {
-    // the port is a slave and should hence only get timing requests
-    assert(pkt->isRequest());
+    /// @todo temporary hack to deal with memory corruption issue until
+    /// 4-phase transactions are complete. Remove me later
+    for (int x = 0; x < pendingDelete.size(); x++)
+        delete pendingDelete[x];
+    pendingDelete.clear();
 
     if (pkt->memInhibitAsserted()) {
         // snooper will supply based on copy of packet
@@ -82,7 +84,10 @@ SimpleTimingPort::recvTiming(PacketPtr pkt)
         assert(pkt->isResponse());
         queue.schedSendTiming(pkt, curTick() + latency);
     } else {
-        delete pkt;
+        /// @todo nominally we should just delete the packet here.
+        /// Until 4-phase stuff we can't because the sending
+        /// cache is still relying on it
+        pendingDelete.push_back(pkt);
     }
 
     return true;