From e036a0375dbf547050955ad84baabb84730364e2 Mon Sep 17 00:00:00 2001 From: Pankaj Garg Date: Mon, 28 Aug 2023 09:05:49 -0700 Subject: [PATCH] Handle closing of the program in the same slot as deployment (#33025) --- program-runtime/src/loaded_programs.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/program-runtime/src/loaded_programs.rs b/program-runtime/src/loaded_programs.rs index 49418ca39b..c47b2b5798 100644 --- a/program-runtime/src/loaded_programs.rs +++ b/program-runtime/src/loaded_programs.rs @@ -467,9 +467,11 @@ impl LoadedPrograms { Ordering::Relaxed, ); second_level.remove(entry_index); - } else if existing.is_tombstone() && !entry.is_tombstone() { - // The old entry is tombstone and the new one is not. Let's give the new entry - // a chance. + } else if existing.is_tombstone() != entry.is_tombstone() { + // Either the old entry is tombstone and the new one is not. + // (Let's give the new entry a chance). + // Or, the old entry is not a tombstone and the new one is a tombstone. + // (Remove the old entry, as the tombstone makes it obsolete). second_level.remove(entry_index); } else { self.stats.replacements.fetch_add(1, Ordering::Relaxed);