Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Controlled shutdown of IlmThread pool in all apps in which we use it.
We know that there are some corner cases on Windows when it can be unsafe to exit because the Ilm thread pool (which is used implicitly by OpenEXR) hangs. The exact conditions that cause this are not well understood. Some time back, in PR 3582, we added an explicit shutdown in oiiotool right before we exit, to alleviate the problem. But this doesn't help for other apps like idiff, nor for apps that use libOpenImageIO and aren't aware of the problem, so wouldn't know to do this. This patch changes to a different strategy: In set_exr_threads(), which will always be called any time we use openexr files, use `std::atexit()` to ensure that when the program terminates -- any program using OpenImageIO in cases when openexr was used -- we set the IlmThread global thread pool size to 0 to shut it down cleanly. Hopefully, that will cover even more cases where this OpenEXR bug might be tickled.
- Loading branch information