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

Rwmutex block #39

Closed
wants to merge 72 commits into from
Closed

Rwmutex block #39

wants to merge 72 commits into from

Conversation

flippmoke
Copy link

ZOMG THE CHANGES!

This is a pull requests of a different way of dealing with caching, and reads and writes in GDAL. The biggest part of this change is the addition of a different way to do IReadBlock, IWriteBlock, IRasterIO, etc. There is now a mutex being passed as well as the data, so that the source data might be protected during writing. It also prevents deadlocks by being very picky in the drivers when it locks and when it does not. The downside is obvious. LOTS OF CHANGES, lots to go wrong.

I haven't fully tested everything yet, but wanted to put this here so we can compare against the other ways doing the locking.

… a global way, this converts the cache size limit to per dataset
…with RasterBands that do not have a dataset.
…heMax in various spots in the code. In many situations this should be pulling the size of the non global cache size in the situation where a dataset specific cache size was specified. Added methods to access the RBM from the Dataset and RasterBand as well.
…heMax in various spots in the code. In many situations this should be pulling the size of the non global cache size in the situation where a dataset specific cache size was specified. Added methods to access the RBM from the Dataset and RasterBand as well.
… a global way, this converts the cache size limit to per dataset
…with RasterBands that do not have a dataset.
…heMax in various spots in the code. In many situations this should be pulling the size of the non global cache size in the situation where a dataset specific cache size was specified. Added methods to access the RBM from the Dataset and RasterBand as well.
…heMax in various spots in the code. In many situations this should be pulling the size of the non global cache size in the situation where a dataset specific cache size was specified. Added methods to access the RBM from the Dataset and RasterBand as well.
…eventing a segfault when destroying a mutex that was already NULL.
… a global way, this converts the cache size limit to per dataset
…with RasterBands that do not have a dataset.
…heMax in various spots in the code. In many situations this should be pulling the size of the non global cache size in the situation where a dataset specific cache size was specified. Added methods to access the RBM from the Dataset and RasterBand as well.
@flippmoke
Copy link
Author

For more details on this change please see:

http://trac.osgeo.org/gdal/wiki/rfc47_dataset_caching

…le prior to the adding the lock for it on another thread. This could cause the block to be deleted while another thread was still attempting to operate on the block
…if a block was added to the Band block array prior to being read, it could cause the block to be empty when read via TryGetLockedBlockRef
@@ -1127,6 +1130,11 @@ static void *CPLCreateMutexInternal(int bAlreadyInGlobalLock);
int CPLCreateOrAcquireMutex( void **phMutex, double dfWaitInSeconds )

{
// Check before going into the global lock, otherwise
// we risk using the global lock too often.
if ( NULL != *phMutex )
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write a test to make sure that this isn't occuring http://en.wikipedia.org/wiki/Double-checked_locking

@rouault rouault closed this Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants