mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-09 17:14:28 +01:00
gossip: Add desctructor to gossip_store
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
8de6d9a7e2
commit
1135760a2f
@@ -16,6 +16,13 @@ struct gossip_store {
|
||||
__off_t replaysize;
|
||||
};
|
||||
|
||||
static void gossip_store_destroy(struct gossip_store *gs)
|
||||
{
|
||||
if (gs->read_fd != -1)
|
||||
close(gs->read_fd);
|
||||
close(gs->write_fd);
|
||||
}
|
||||
|
||||
struct gossip_store *gossip_store_new(const tal_t *ctx)
|
||||
{
|
||||
struct gossip_store *gs = tal(ctx, struct gossip_store);
|
||||
@@ -23,6 +30,8 @@ struct gossip_store *gossip_store_new(const tal_t *ctx)
|
||||
gs->read_fd = open(GOSSIP_STORE_FILENAME, O_RDONLY);
|
||||
gs->replaysize = lseek(gs->write_fd, 0, SEEK_END);
|
||||
|
||||
tal_add_destructor(gs, gossip_store_destroy);
|
||||
|
||||
return gs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user