Commit 994ee3f2 by Yuly Novikov Committed by Commit Bot

Remove static sNativeLib from FunctionsEGLDL

It should be safe to never dlclose native EGL, since we want to do it only when process exits, in which case fd is closed and library destructor is called. BUG=angleproject:1459 Change-Id: I8d3e5b323164d2f6473a083973f4d0adc9e655aa Reviewed-on: https://chromium-review.googlesource.com/786051Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
parent 0250fd4a
...@@ -12,25 +12,17 @@ ...@@ -12,25 +12,17 @@
namespace rx namespace rx
{ {
namespace
DynamicLib::DynamicLib() : handle(nullptr)
{
}
DynamicLib::~DynamicLib()
{ {
if (handle) // In ideal world, we would want this to be a member of FunctionsEGLDL,
{ // and call dlclose() on it in ~FunctionsEGLDL().
dlclose(handle); // However, some GL implementations are broken and don't allow multiple
handle = nullptr; // load/unload cycles, but only static linking with them.
} // That's why we dlopen() this handle once and never dlclose() it.
} // This is consistent with Chromium's CleanupNativeLibraries() code,
// referencing crbug.com/250813 and http://www.xfree86.org/4.3.0/DRI11.html
// Due to a bug in Mesa (or maybe libdl) it's not possible to close and re-open libEGL.so void *nativeEGLHandle;
// an arbitrary number of times. End2end tests would die after a couple hundred tests. } // anonymous namespace
// So we use a static object with a destructor to close the library when the program exits.
// TODO(fjhenigman) File a bug and put a link here.
DynamicLib FunctionsEGLDL::sNativeLib;
FunctionsEGLDL::FunctionsEGLDL() : mGetProcAddressPtr(nullptr) FunctionsEGLDL::FunctionsEGLDL() : mGetProcAddressPtr(nullptr)
{ {
...@@ -42,17 +34,17 @@ FunctionsEGLDL::~FunctionsEGLDL() ...@@ -42,17 +34,17 @@ FunctionsEGLDL::~FunctionsEGLDL()
egl::Error FunctionsEGLDL::initialize(EGLNativeDisplayType nativeDisplay, const char *libName) egl::Error FunctionsEGLDL::initialize(EGLNativeDisplayType nativeDisplay, const char *libName)
{ {
if (!sNativeLib.handle) if (!nativeEGLHandle)
{ {
sNativeLib.handle = dlopen(libName, RTLD_NOW); nativeEGLHandle = dlopen(libName, RTLD_NOW);
if (!sNativeLib.handle) if (!nativeEGLHandle)
{ {
return egl::EglNotInitialized() << "Could not dlopen native EGL: " << dlerror(); return egl::EglNotInitialized() << "Could not dlopen native EGL: " << dlerror();
} }
} }
mGetProcAddressPtr = mGetProcAddressPtr =
reinterpret_cast<PFNEGLGETPROCADDRESSPROC>(dlsym(sNativeLib.handle, "eglGetProcAddress")); reinterpret_cast<PFNEGLGETPROCADDRESSPROC>(dlsym(nativeEGLHandle, "eglGetProcAddress"));
if (!mGetProcAddressPtr) if (!mGetProcAddressPtr)
{ {
return egl::EglNotInitialized() << "Could not find eglGetProcAddress"; return egl::EglNotInitialized() << "Could not find eglGetProcAddress";
...@@ -68,7 +60,7 @@ void *FunctionsEGLDL::getProcAddress(const char *name) const ...@@ -68,7 +60,7 @@ void *FunctionsEGLDL::getProcAddress(const char *name) const
{ {
return f; return f;
} }
return dlsym(sNativeLib.handle, name); return dlsym(nativeEGLHandle, name);
} }
} // namespace rx } // namespace rx
...@@ -14,16 +14,6 @@ ...@@ -14,16 +14,6 @@
namespace rx namespace rx
{ {
class DynamicLib final
{
public:
void *handle;
DynamicLib();
~DynamicLib();
};
class FunctionsEGLDL : public FunctionsEGL class FunctionsEGLDL : public FunctionsEGL
{ {
public: public:
...@@ -35,7 +25,6 @@ class FunctionsEGLDL : public FunctionsEGL ...@@ -35,7 +25,6 @@ class FunctionsEGLDL : public FunctionsEGL
private: private:
PFNEGLGETPROCADDRESSPROC mGetProcAddressPtr; PFNEGLGETPROCADDRESSPROC mGetProcAddressPtr;
static DynamicLib sNativeLib;
}; };
} // namespace rx } // namespace rx
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment