Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Patch in PR #25 and fix for use after close / double close. #37

Closed
wants to merge 9 commits into from

Conversation

shinji-s
Copy link
Contributor

@shinji-s shinji-s commented Aug 6, 2020

Let's see if CI tests pass or fail.
@shahramn, please let me know what you think.

…>file' in _codes_index_add_file().

Introduce 'index_next' field in grib_file so that an object of the kind can appear simualtaneously both in index->files chain and file_pool.first chain.
Introduce 'dependants' field in grib_file so that a 'grib_file' object derived from another can be chained via the field. File pointer (grib_file->handle) will not be closed unless there is no dependants.
Close 'grib_file's on index->files chain in grib_index_delete().
Remove 'size' member of grib_file_pool as it is not utilized.
Reduced scope of some internal functions to static.
Close 'grib_flie's on index->files link in 'grib_index_delete()'.
Expose 'grib_file_pool_clean(int *err)' to internal tools and remove 'grib_file_close_all()'.
Rename grib_get_file() to grib_get_or_create_file() to describe what the function does more appropriety.
@shinji-s shinji-s changed the title Set 'new_file' to 'field->file' rather than setting 'file' to 'field-… WIP: Patch in PR #25 and fix for use after close / double close. Aug 6, 2020
@shinji-s
Copy link
Contributor Author

shinji-s commented Aug 6, 2020

Ouch. Now locally running the extra tests...

…only once for each 'file_id' value.

Don't assume files[i] gets copiied and nullified while reading index file.
Manage 'id' per grib_index by introducinng 'filed_id_seq' member.
Add 'int * created' arg to grip_open_file() so that we can tell if the 'grib_file' object is newly created.
Have grib_index_add_new_key() use a newly created 'grib_file' object as is or create a duplicate otherwise.
Rename 'next' to 'newkey' for clarity in grib_index_add_new_key().
Initialize grib_file.id with -1.
Remove grib_index_key.count as it is not used.
Rename grib_index_new_key() to grib_index_add_new_key() for clarity.
Release previously allocated object before returning due to memory allocation error.
Introduce LIST_APPEND macro.
Rename 'p' and 'q' to more descriptive ones in 'grib_index_new()'.
Make 'grib_read_field_tree()' static.
@shinji-s
Copy link
Contributor Author

shinji-s commented Aug 7, 2020

Does making the 'file_pool' a per 'grib_index' object make sense? Or should it be per 'grib_contex' object?

@shinji-s
Copy link
Contributor Author

shinji-s commented Aug 7, 2020

I'm beginning to realize this fix was set in wrong direction from the very start. 'grib_file' is serving multiple purposes such as helping file_pool management and file reference tracking in grib_field. They don't have to use the same data structure and they should not for conceptual clarity although the underlining implementation may be shared. But what I have done is to couple them even tighter. I guess I've have to restart from scratch. Therefore I'll keep this PR open for a few days and then close it.

Add assertion on grib_file.id.
@shinji-s
Copy link
Contributor Author

shinji-s commented Aug 9, 2020

Closing per the above coment.

@shinji-s shinji-s closed this Aug 9, 2020
@shinji-s shinji-s deleted the fix_double_close branch November 16, 2020 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant