mirror of
https://github.com/urbit/ares.git
synced 2024-12-25 06:12:24 +03:00
pma: implement bt_state_close to a sufficient degree
This commit is contained in:
parent
a3f23f1f9d
commit
3eb0b3a5d5
@ -1514,6 +1514,20 @@ _nlist_new(BT_state *state)
|
|||||||
return BT_SUCC;
|
return BT_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_nlist_delete(BT_state *state)
|
||||||
|
{
|
||||||
|
BT_nlistnode *head, *prev;
|
||||||
|
head = prev = state->nlist;
|
||||||
|
while (head->next) {
|
||||||
|
prev = head;
|
||||||
|
head = head->next;
|
||||||
|
free(prev);
|
||||||
|
}
|
||||||
|
state->nlist = 0;
|
||||||
|
return BT_SUCC;
|
||||||
|
}
|
||||||
|
|
||||||
static BT_nlistnode *
|
static BT_nlistnode *
|
||||||
_nlist_read_prev(BT_nlistnode *head, BT_nlistnode *curr)
|
_nlist_read_prev(BT_nlistnode *head, BT_nlistnode *curr)
|
||||||
{
|
{
|
||||||
@ -2469,14 +2483,19 @@ int
|
|||||||
bt_state_close(BT_state *state)
|
bt_state_close(BT_state *state)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
if (state->data_fd != -1) CLOSE_FD(state->data_fd);
|
bt_sync(state);
|
||||||
|
|
||||||
_mlist_delete(state);
|
_mlist_delete(state);
|
||||||
_flist_delete(state);
|
_flist_delete(state);
|
||||||
|
_nlist_delete(state);
|
||||||
|
|
||||||
/* ;;: wip delete the file because we haven't implemented persistence yet */
|
if ((rc = munmap(state->map, BT_ADDRSIZE)) != 0) {
|
||||||
if (!SUCC(rc = remove(state->path)))
|
rc = errno;
|
||||||
return rc;
|
return rc;
|
||||||
|
}
|
||||||
|
if (state->data_fd != -1) CLOSE_FD(state->data_fd);
|
||||||
|
|
||||||
|
ZERO(state, sizeof *state);
|
||||||
|
|
||||||
return BT_SUCC;
|
return BT_SUCC;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user