diff options
author | Alex Auvolat <alex@adnab.me> | 2021-03-12 22:06:56 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-03-12 22:06:56 +0100 |
commit | 9b118160a8b668b376d25ac16b097bce050f8b67 (patch) | |
tree | 7f4dbb00314ea1dd8efe083561513d1206e30789 /src/table/gc.rs | |
parent | 831eb35763fdaeecb7b6d6aa13ebd78da14db04e (diff) | |
download | garage-9b118160a8b668b376d25ac16b097bce050f8b67.tar.gz garage-9b118160a8b668b376d25ac16b097bce050f8b67.zip |
Optim & refactor
Diffstat (limited to 'src/table/gc.rs')
-rw-r--r-- | src/table/gc.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/table/gc.rs b/src/table/gc.rs index 594044b8..5b7f1ee7 100644 --- a/src/table/gc.rs +++ b/src/table/gc.rs @@ -116,10 +116,7 @@ where } for (k, vhash) in excluded { - let _ = self - .data - .gc_todo - .compare_and_swap::<_, _, Vec<u8>>(k, Some(vhash), None)?; + self.todo_remove_if_equal(&k[..], vhash)?; } if entries.len() == 0 { @@ -197,15 +194,20 @@ where for (k, vhash) in deletes { self.data.delete_if_equal_hash(&k[..], vhash)?; - let _ = self - .data - .gc_todo - .compare_and_swap::<_, _, Vec<u8>>(k, Some(vhash), None)?; + self.todo_remove_if_equal(&k[..], vhash)?; } Ok(()) } + fn todo_remove_if_equal(&self, key: &[u8], vhash: Hash) -> Result<(), Error> { + let _ = self + .data + .gc_todo + .compare_and_swap::<_, _, Vec<u8>>(key, Some(vhash), None)?; + Ok(()) + } + // ---- RPC HANDLER ---- fn register_handler(self: &Arc<Self>, rpc_server: &mut RpcServer, path: String) { @@ -232,6 +234,7 @@ where GcRPC::DeleteIfEqualHash(items) => { for (key, vhash) in items.iter() { self.data.delete_if_equal_hash(&key[..], *vhash)?; + self.todo_remove_if_equal(&key[..], *vhash)?; } Ok(GcRPC::Ok) } |