mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
Kernel: Fix SharedBuffer reference counting on fork
We need to not only add a record for a reference, but we need to copy the reference count on fork as well, because the code in the fork assumes that it has the same amount of references, still. Also, once all references are dropped when a process is disowned, delete the shared buffer. Fixes #4076
This commit is contained in:
parent
018eff802b
commit
68abd1cb29
3 changed files with 22 additions and 9 deletions
|
@ -36,8 +36,9 @@ namespace Kernel {
|
|||
class SharedBuffer {
|
||||
private:
|
||||
struct Reference {
|
||||
Reference(ProcessID pid)
|
||||
Reference(ProcessID pid, unsigned count = 0)
|
||||
: pid(pid)
|
||||
, count(count)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -69,7 +70,7 @@ public:
|
|||
void share_with(ProcessID peer_pid);
|
||||
void share_globally() { m_global = true; }
|
||||
void deref_for_process(Process& process);
|
||||
void disown(ProcessID pid);
|
||||
bool disown(ProcessID pid);
|
||||
static void share_all_shared_buffers(Process& from_process, Process& with_process);
|
||||
size_t size() const { return m_vmobject->size(); }
|
||||
void destroy_if_unused();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue