libutil/file-system: make AutoDelete not copyable and movable
Such a RAII structure should NEVER be copyable or movable, otherwise: ``` AutoDelete x; x = AutoDelete(p, false); ``` will trigger the immediate deletion of `p`! This fixes an annoying bug where the state record for cgroups was deleted immediately as soon as it was created. Change-Id: I2bfbc0815706700a0a75b79d1059cc552119b2c9 Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
@@ -330,7 +330,7 @@ void AutoDestroyCgroup::cleansePreviousInstancesAndRecordOurself(
|
||||
}
|
||||
|
||||
writeFile(cgroupFile, std::get<std::filesystem::path>(cgroup_).string());
|
||||
stateRecord = AutoDelete(cgroupFile, false);
|
||||
stateRecord.reset(cgroupFile, false);
|
||||
}
|
||||
|
||||
void AutoDestroyCgroup::adoptProcess(int pid)
|
||||
|
||||
@@ -273,6 +273,8 @@ class AutoDelete
|
||||
bool del;
|
||||
bool recursive;
|
||||
public:
|
||||
KJ_DISALLOW_COPY_AND_MOVE(AutoDelete);
|
||||
|
||||
AutoDelete();
|
||||
AutoDelete(const Path & p, bool recursive = true);
|
||||
~AutoDelete();
|
||||
|
||||
Reference in New Issue
Block a user