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 /* 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> * Kirill Smelkov <kirr@nexedi.com>
* *
* This program is free software: you can Use, Study, Modify and Redistribute * This program is free software: you can Use, Study, Modify and Redistribute
...@@ -87,8 +87,10 @@ RAMH *ramh_open(RAM *ram) ...@@ -87,8 +87,10 @@ RAMH *ramh_open(RAM *ram)
void ram_close(RAM *ram) void ram_close(RAM *ram)
{ {
WARN("TODO ram_close()"); // XXX // TODO assert that
//return ram->ram_ops->close(ram); // - 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 /* 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> * Kirill Smelkov <kirr@nexedi.com>
* *
* This program is free software: you can Use, Study, Modify and Redistribute * This program is free software: you can Use, Study, Modify and Redistribute
...@@ -243,11 +243,12 @@ out: ...@@ -243,11 +243,12 @@ out:
return NULL; return NULL;
} }
static void shmfs_ram_close(RAM *ram0);
static const struct ram_ops shmfs_ram_ops = { static const struct ram_ops shmfs_ram_ops = {
.get_current_maxsize = shmfs_get_current_maxsize, .get_current_maxsize = shmfs_get_current_maxsize,
.ramh_open = shmfs_ramh_open, .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) ...@@ -266,8 +267,11 @@ static RAM *shmfs_ram_new(const char *arg)
return ram; return ram;
}; };
static void shmfs_ram_close(RAM *ram0)
// TODO shmfs_ram_dtor {
SHMFS_RAM *ram = upcast(SHMFS_RAM *, ram0);
free((void*)ram->prefix); ram->prefix = NULL;
}
static const struct ram_type shmfs_ram_type = { static const struct ram_type shmfs_ram_type = {
......
...@@ -94,6 +94,7 @@ RAMH *ramh_open(RAM *ram); ...@@ -94,6 +94,7 @@ RAMH *ramh_open(RAM *ram);
/* ram_close releases resources associated with 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. * NOTE struct RAM itself is not released - it has to be explicitly freed by user.
*/ */
void ram_close(RAM *ram); 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