If the module was unloaded it can be loaded again and the setup has to be done again. We can't rely on setupDone being reinitialized to zero after dlclose and dlopen.
(It's not reinitialized probably because of dlsym being called on modesettingModuleData which keeps reference counter for the library above zero and so prevents it to be ever freed.) Register proper TearDown function and set setupDone variable to zero when being unloaded. diff --git a/src/driver.c b/src/driver.c index 4e2cfa0..fd9e1c2 100644 --- a/src/driver.c +++ b/src/driver.c @@ -137,6 +137,7 @@ static const OptionInfoRec Options[] = { int modesettingEntityIndex = -1; static MODULESETUPPROTO(Setup); +static MODULETEARDOWNPROTO(TearDown); static XF86ModuleVersionInfo VersRec = { "modesetting", @@ -151,7 +152,7 @@ static XF86ModuleVersionInfo VersRec = { {0, 0, 0, 0} }; -_X_EXPORT XF86ModuleData modesettingModuleData = { &VersRec, Setup, NULL }; +_X_EXPORT XF86ModuleData modesettingModuleData = { &VersRec, Setup, TearDown }; static pointer Setup(pointer module, pointer opts, int *errmaj, int *errmin) @@ -168,7 +169,7 @@ Setup(pointer module, pointer opts, int *errmaj, int *errmin) * The return value must be non-NULL on success even though there * is no TearDownProc. */ - return (pointer) 1; + return (pointer) &setupDone; } else { if (errmaj) *errmaj = LDR_ONCEONLY; @@ -176,6 +177,12 @@ Setup(pointer module, pointer opts, int *errmaj, int *errmin) } } +static void +TearDown(pointer p) +{ + *(Bool*)p = 0; +} + static Bool DriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr) { switch(op) { _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel