Commit d91ef8fb authored by Kirill Smelkov's avatar Kirill Smelkov

bigfile: Unstub ram_close

It should release resources associated with RAM. Make it call .ram_close
from RAM ops. Add corresponding .ram_close to ram_shmfs. This fixes
SHMFS_RAM->prefix leak.
parent e8eca379
/* Wendelin.bigfile | Interfaces to work with RAM
* Copyright (C) 2014-2015 Nexedi SA and Contributors.
* Copyright (C) 2014-2019 Nexedi SA and Contributors.
* Kirill Smelkov <kirr@nexedi.com>
*
* This program is free software: you can Use, Study, Modify and Redistribute
......@@ -87,8 +87,10 @@ RAMH *ramh_open(RAM *ram)
void ram_close(RAM *ram)
{
WARN("TODO ram_close()"); // XXX
//return ram->ram_ops->close(ram);
// TODO assert that
// - there are no ramh open left
// - there are no pages on ram->lru_list
return ram->ram_ops->close(ram);
}
......
/* Wendelin.bigfile | shmfs (aka tmpfs) ram backend
* Copyright (C) 2014-2015 Nexedi SA and Contributors.
* Copyright (C) 2014-2019 Nexedi SA and Contributors.
* Kirill Smelkov <kirr@nexedi.com>
*
* This program is free software: you can Use, Study, Modify and Redistribute
......@@ -243,11 +243,12 @@ out:
return NULL;
}
static void shmfs_ram_close(RAM *ram0);
static const struct ram_ops shmfs_ram_ops = {
.get_current_maxsize = shmfs_get_current_maxsize,
.ramh_open = shmfs_ramh_open,
//.close = shmfs_ram_dtor
.close = shmfs_ram_close,
};
......@@ -266,8 +267,11 @@ static RAM *shmfs_ram_new(const char *arg)
return ram;
};
// TODO shmfs_ram_dtor
static void shmfs_ram_close(RAM *ram0)
{
SHMFS_RAM *ram = upcast(SHMFS_RAM *, ram0);
free((void*)ram->prefix); ram->prefix = NULL;
}
static const struct ram_type shmfs_ram_type = {
......
......@@ -94,6 +94,7 @@ RAMH *ramh_open(RAM *ram);
/* ram_close releases resources associated with RAM.
*
* All RAM handles opened on this RAM must be closed.
* NOTE struct RAM itself is not released - it has to be explicitly freed by user.
*/
void ram_close(RAM *ram);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment