Skip to content

Commit

Permalink
lib-index: If mmap() fails, include the attempted size in the error.
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Nov 18, 2016
1 parent ac27e84 commit 6ade0d7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/lib-index/mail-cache.c
Expand Up @@ -480,7 +480,8 @@ int mail_cache_map(struct mail_cache *cache, size_t offset, size_t size,
if (cache->mmap_base == MAP_FAILED) {
cache->mmap_base = NULL;
cache->mmap_length = 0;
mail_cache_set_syscall_error(cache, "mmap()");
mail_cache_set_syscall_error(cache, t_strdup_printf(
"mmap(size=%"PRIuSIZE_T")", cache->mmap_length));
return -1;
}
*data_r = offset > cache->mmap_length ? NULL :
Expand Down
3 changes: 2 additions & 1 deletion src/lib-index/mail-index-map-read.c
Expand Up @@ -47,7 +47,8 @@ static int mail_index_mmap(struct mail_index_map *map, uoff_t file_size)
MAP_PRIVATE, index->fd, 0);
if (rec_map->mmap_base == MAP_FAILED) {
rec_map->mmap_base = NULL;
mail_index_set_syscall_error(index, "mmap()");
mail_index_set_syscall_error(index, t_strdup_printf(
"mmap(size=%"PRIuSIZE_T")", file_size));
return -1;
}
rec_map->mmap_size = file_size;
Expand Down
3 changes: 2 additions & 1 deletion src/lib-index/mail-transaction-log-file.c
Expand Up @@ -1616,7 +1616,8 @@ mail_transaction_log_file_mmap(struct mail_transaction_log_file *file)
if (file->mmap_base == MAP_FAILED) {
file->mmap_base = NULL;
file->mmap_size = 0;
log_file_set_syscall_error(file, "mmap()");
log_file_set_syscall_error(file, t_strdup_printf(
"mmap(size=%"PRIuSIZE_T")", file->mmap_size));
return -1;
}

Expand Down

0 comments on commit 6ade0d7

Please sign in to comment.