BUG FIX: creation of a new column would fail because of a case not
handled when a high number of elements per line would imply less than one line per memory page
This commit is contained in:
@ -703,7 +703,7 @@ static int get_formatted_elt_names_length(const char* elements_names)
|
|||||||
|
|
||||||
static index_t get_line_count_per_page(OBIType_t data_type, index_t nb_elements_per_line)
|
static index_t get_line_count_per_page(OBIType_t data_type, index_t nb_elements_per_line)
|
||||||
{
|
{
|
||||||
return getpagesize() / (obi_sizeof(data_type) * nb_elements_per_line);
|
return getpagesize() / obi_sizeof(data_type) / nb_elements_per_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -919,6 +919,8 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
|
|||||||
|
|
||||||
// The initial line count should be between the minimum (corresponding to the page size) and the maximum allowed
|
// The initial line count should be between the minimum (corresponding to the page size) and the maximum allowed
|
||||||
minimum_line_count = get_line_count_per_page(stored_data_type, nb_elements_per_line);
|
minimum_line_count = get_line_count_per_page(stored_data_type, nb_elements_per_line);
|
||||||
|
if (minimum_line_count == 0) // Happens if high number of elements per line
|
||||||
|
minimum_line_count = 1;
|
||||||
if (nb_lines > MAXIMUM_LINE_COUNT)
|
if (nb_lines > MAXIMUM_LINE_COUNT)
|
||||||
{
|
{
|
||||||
obidebug(1, "\nCan't create column because of line count greater than the maximum allowed (%d)", MAXIMUM_LINE_COUNT);
|
obidebug(1, "\nCan't create column because of line count greater than the maximum allowed (%d)", MAXIMUM_LINE_COUNT);
|
||||||
@ -1023,7 +1025,8 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
|
|||||||
if (new_column->data == MAP_FAILED)
|
if (new_column->data == MAP_FAILED)
|
||||||
{
|
{
|
||||||
obi_set_errno(OBICOL_UNKNOWN_ERROR);
|
obi_set_errno(OBICOL_UNKNOWN_ERROR);
|
||||||
obidebug(1, "\nError mmapping the data of a column");
|
obidebug(1, "\nError mmapping the data of a column.\nArguments: data_size=%lu, column_file_descriptor=%d, header_size=%lu",
|
||||||
|
data_size, column_file_descriptor, header_size);
|
||||||
munmap(new_column->header, header_size);
|
munmap(new_column->header, header_size);
|
||||||
close(column_file_descriptor);
|
close(column_file_descriptor);
|
||||||
free(new_column);
|
free(new_column);
|
||||||
|
Reference in New Issue
Block a user