mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-08-28 07:28:58 +00:00
avoid repetitive garbage collection if no files have been deleted since
the last try.
This commit is contained in:
parent
a9f0729f2c
commit
8785bee644
@ -146,10 +146,12 @@ static struct protected_mem_t {
|
|||||||
struct file coffee_files[COFFEE_MAX_OPEN_FILES];
|
struct file coffee_files[COFFEE_MAX_OPEN_FILES];
|
||||||
struct file_desc coffee_fd_set[COFFEE_FD_SET_SIZE];
|
struct file_desc coffee_fd_set[COFFEE_FD_SET_SIZE];
|
||||||
coffee_page_t next_free;
|
coffee_page_t next_free;
|
||||||
|
char gc_wait;
|
||||||
} protected_mem;
|
} protected_mem;
|
||||||
static struct file *coffee_files = protected_mem.coffee_files;
|
static struct file *coffee_files = protected_mem.coffee_files;
|
||||||
static struct file_desc *coffee_fd_set = protected_mem.coffee_fd_set;
|
static struct file_desc *coffee_fd_set = protected_mem.coffee_fd_set;
|
||||||
static coffee_page_t *next_free = &protected_mem.next_free;
|
static coffee_page_t *next_free = &protected_mem.next_free;
|
||||||
|
static char *gc_wait = &protected_mem.gc_wait;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
@ -499,6 +501,8 @@ remove_by_page(coffee_page_t page, int remove_log, int close_fds)
|
|||||||
hdr.flags |= HDR_FLAG_OBSOLETE;
|
hdr.flags |= HDR_FLAG_OBSOLETE;
|
||||||
write_header(&hdr, page);
|
write_header(&hdr, page);
|
||||||
|
|
||||||
|
*gc_wait = 0;
|
||||||
|
|
||||||
/* Close all file descriptors that reference the removed file. */
|
/* Close all file descriptors that reference the removed file. */
|
||||||
if(close_fds) {
|
if(close_fds) {
|
||||||
for(i = 0; i < COFFEE_FD_SET_SIZE; i++) {
|
for(i = 0; i < COFFEE_FD_SET_SIZE; i++) {
|
||||||
@ -541,10 +545,14 @@ reserve(const char *name, coffee_page_t pages, int allow_duplicates)
|
|||||||
|
|
||||||
page = find_contiguous_pages(pages);
|
page = find_contiguous_pages(pages);
|
||||||
if(page == INVALID_PAGE) {
|
if(page == INVALID_PAGE) {
|
||||||
|
if(*gc_wait) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
cfs_garbage_collect();
|
cfs_garbage_collect();
|
||||||
page = find_contiguous_pages(pages);
|
page = find_contiguous_pages(pages);
|
||||||
if(page == INVALID_PAGE) {
|
if(page == INVALID_PAGE) {
|
||||||
watchdog_start();
|
watchdog_start();
|
||||||
|
gc_wait = 1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -561,7 +569,6 @@ reserve(const char *name, coffee_page_t pages, int allow_duplicates)
|
|||||||
|
|
||||||
file = load_file(name, &hdr, page);
|
file = load_file(name, &hdr, page);
|
||||||
file->end = 0;
|
file->end = 0;
|
||||||
|
|
||||||
watchdog_start();
|
watchdog_start();
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
Loading…
Reference in New Issue
Block a user