Browse Source

gossip: Add desctructor to gossip_store

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
1135760a2f
  1. 9
      gossipd/gossip_store.c

9
gossipd/gossip_store.c

@ -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;
}

Loading…
Cancel
Save