Skip to content
Snippets Groups Projects
Commit 7173e55c authored by Roman Khlopkov's avatar Roman Khlopkov 🔜
Browse files

Merge branch 'bugfix-12148' into 'release-5.3'

Bugfix 12148

See merge request !1702
parents 2e6a08c4 a568a0ba
No related branches found
No related tags found
1 merge request!1702Bugfix 12148
Pipeline #41536 passed with stage
in 9 minutes and 57 seconds
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#define DAP_CHAIN_CELL_FILE_SIGNATURE 0xfa340bef153eba48 #define DAP_CHAIN_CELL_FILE_SIGNATURE 0xfa340bef153eba48
#define DAP_CHAIN_CELL_FILE_TYPE_RAW 0 #define DAP_CHAIN_CELL_FILE_TYPE_RAW 0
#define DAP_CHAIN_CELL_FILE_TYPE_COMPRESSED 1 #define DAP_CHAIN_CELL_FILE_TYPE_COMPRESSED 1
#define DAP_MAPPED_VOLUME_LIMIT ( 1 << 28 ) // 256 MB for now, may be should be configurable? #define DAP_MAPPED_VOLUME_LIMIT ( 1 << 20 ) // 256 MB for now, may be should be configurable?
/** /**
* @struct dap_chain_cell_file_header * @struct dap_chain_cell_file_header
*/ */
...@@ -172,6 +172,9 @@ DAP_STATIC_INLINE int s_cell_map_new_volume(dap_chain_cell_t *a_cell, size_t a_f ...@@ -172,6 +172,9 @@ DAP_STATIC_INLINE int s_cell_map_new_volume(dap_chain_cell_t *a_cell, size_t a_f
a_cell->file_storage_path, a_cell->id.uint64, errno); a_cell->file_storage_path, a_cell->id.uint64, errno);
return -1; return -1;
} }
#ifdef DAP_OS_DARWIN
a_cell->cur_vol_start = l_volume_start;
#endif
#endif #endif
a_cell->map_pos = a_cell->map + l_offset; a_cell->map_pos = a_cell->map + l_offset;
a_cell->map_range_bounds = dap_list_append(a_cell->map_range_bounds, a_cell->map); a_cell->map_range_bounds = dap_list_append(a_cell->map_range_bounds, a_cell->map);
...@@ -523,6 +526,16 @@ static int s_cell_file_atom_add(dap_chain_cell_t *a_cell, dap_chain_atom_ptr_t a ...@@ -523,6 +526,16 @@ static int s_cell_file_atom_add(dap_chain_cell_t *a_cell, dap_chain_atom_ptr_t a
debug_if (s_debug_more && a_cell->chain->is_mapped, L_DEBUG, "After writing an atom of size %lu, stream pos of %s is %lu and map shift is %lu", debug_if (s_debug_more && a_cell->chain->is_mapped, L_DEBUG, "After writing an atom of size %lu, stream pos of %s is %lu and map shift is %lu",
a_atom_size, a_cell->file_storage_path, ftell(a_cell->file_storage), a_atom_size, a_cell->file_storage_path, ftell(a_cell->file_storage),
(size_t)(a_cell->map_pos - a_cell->map)); (size_t)(a_cell->map_pos - a_cell->map));
#ifdef DAP_OS_DARWIN
if (a_cell->chain->is_mapped) {
if ( MAP_FAILED == (a_cell->map = mmap(a_cell->map, dap_page_roundup(DAP_MAPPED_VOLUME_LIMIT), PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, fileno(a_cell->file_storage), a_cell->cur_vol_start)) ) {
log_it(L_ERROR, "Chain cell \"%s\" 0x%016"DAP_UINT64_FORMAT_X" cannot be remapped, errno %d",
a_cell->file_storage_path, a_cell->id.uint64, errno);
return -1;
}
}
#endif
return 0; return 0;
} }
...@@ -602,7 +615,7 @@ ssize_t dap_chain_cell_file_append(dap_chain_cell_t *a_cell, const void *a_atom, ...@@ -602,7 +615,7 @@ ssize_t dap_chain_cell_file_append(dap_chain_cell_t *a_cell, const void *a_atom,
++l_count; ++l_count;
l_total_res = a_atom_size + sizeof(uint64_t); l_total_res = a_atom_size + sizeof(uint64_t);
} }
if (l_total_res) { if (l_total_res) {
fflush(a_cell->file_storage); fflush(a_cell->file_storage);
#ifdef DAP_OS_WINDOWS #ifdef DAP_OS_WINDOWS
......
...@@ -38,6 +38,9 @@ typedef struct dap_chain_cell { ...@@ -38,6 +38,9 @@ typedef struct dap_chain_cell {
FILE *file_storage; FILE *file_storage;
uint8_t file_storage_type; uint8_t file_storage_type;
dap_list_t *map_range_bounds; dap_list_t *map_range_bounds;
#ifdef DAP_OS_DARWIN
size_t cur_vol_start;
#endif
pthread_rwlock_t storage_rwlock; pthread_rwlock_t storage_rwlock;
UT_hash_handle hh; UT_hash_handle hh;
} dap_chain_cell_t; } dap_chain_cell_t;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment