Skip to content

Commit

Permalink
fallback to malloc if mmap method fails (e.g., on full disk)
Browse files Browse the repository at this point in the history
  • Loading branch information
adsr committed Feb 14, 2020
1 parent 3c8b84d commit dd966bb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ int buffer_open(buffer_t *self, char *path) {
self->is_in_open = 1;
if (st.st_size >= MLBUF_LARGE_FILE_SIZE) {
if (_buffer_open_mmap(self, fd, st.st_size) != MLBUF_OK) {
rc = MLBUF_ERR;
break;
// mmap failed so fallback to normal read
if (_buffer_open_read(self, fd, st.st_size) != MLBUF_OK) {
rc = MLBUF_ERR;
break;
}
}
} else {
if (_buffer_open_read(self, fd, st.st_size) != MLBUF_OK) {
Expand Down

0 comments on commit dd966bb

Please sign in to comment.