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

Implement thread-safe creation of proj mutex (fixes #954) #958

Merged
merged 2 commits into from
Apr 30, 2018

Conversation

rouault
Copy link
Member

@rouault rouault commented Apr 28, 2018

No description provided.

Copy link
Member

@kbevers kbevers left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this. I haven't got enough insight to comment on the implementation but I am wondering if it is possible to create a simple test so we can avoid the original problem in the future? Or is it one of those multithreading problems that only appears in big and complicated settings?

static pthread_once_t sOnceKey = PTHREAD_ONCE_INIT;
if( pthread_once(&sOnceKey, pj_create_lock) != 0 )
{
fprintf(stderr, "pthread_once() failed in pj_acquire_lock().\n");
Copy link
Member

Choose a reason for hiding this comment

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

Please use either proj_log_error or proj_log_debug, depending on which you think suits the purpose best.

Copy link
Member Author

Choose a reason for hiding this comment

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

proj_log_error() and proj_log_debug() require a PJ* object which we don't have here

Copy link
Member Author

Choose a reason for hiding this comment

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

and this error is not supposed to happen in practice. This is mostly so to have a hint of what went wrong in case something (really) bad happen

Copy link
Member

Choose a reason for hiding this comment

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

PJ* object which we don't have here

Right, I totally missed that.

@rouault
Copy link
Member Author

rouault commented Apr 28, 2018

if it is possible to create a simple test so we can avoid the original problem in the future?

src/multistresstest.c should already test this. It is extremly difficult to test that there is no race, by definition of races...

@kbevers
Copy link
Member

kbevers commented Apr 29, 2018

src/multistresstest.c should already test this. It is extremly difficult to test that there is no race, by definition of races...

Yeah, that's what I figured. Just wanted to check if you had an idea to improve the multithreading test.

@kbevers kbevers merged commit 2fdbffc into OSGeo:master Apr 30, 2018
@kbevers kbevers added this to the 5.1.0 milestone May 7, 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