Skip to content
Snippets Groups Projects
Commit 4bb5ad28 authored by Avi Kivity's avatar Avi Kivity
Browse files

file: close() outside destructor


Once file::~file() is called, virtual functions no longer dispatch to the
derived type (which has since been destroyed) but to the base type, which
is uninteresting.

Move the call to close() from the destructor to fdrop().

Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
parent cc1e31d1
No related branches found
No related tags found
No related merge requests found
......@@ -216,14 +216,6 @@ int fdrop(struct file *fp)
if (__sync_fetch_and_sub(&fp->f_count, 1) != 1)
return 0;
delete fp;
return 1;
}
file::~file()
{
auto fp = this;
/* We are about to free this file structure, but we still do things with it
* so set the refcount to INT_MIN, fhold/fdrop may get called again
* and we don't want to reach this point more than once.
......@@ -232,6 +224,14 @@ file::~file()
fp->f_count = INT_MIN;
fo_close(fp);
delete fp;
return 1;
}
file::~file()
{
auto fp = this;
poll_drain(fp);
if (f_epolls) {
for (auto ep : *f_epolls) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment