From 8f4640bdb9d3988148e09a08d2c7e3bab1d538d6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 9 Jan 2013 12:58:28 +1000 Subject: randr: cleanup provider properly So in the cold plug server shutdown case, we reap the resources before we call CloseScreen handlers, so the config->randr_provider is a dangling pointer when the xf86CrtcCloseScreen handler is called, however in the hot screen unplug case, we can't rely on automatically reaped resources, so we need to clean up the provider in the xf86CrtcCloseScreen case. This patch provides a cleanup callback from the randr provider removal into the DDX so it can cleanup properly, this then gets called by the automatic code for cold plug, or if hot unplug it gets called explicitly. Fixes a number of random server crashes on shutdown Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58174 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=891140 Reviewed-by: Peter Hutterer Signed-off-by: Dave Airlie --- randr/randrstr.h | 6 ++++++ randr/rrprovider.c | 2 ++ 2 files changed, 8 insertions(+) (limited to 'randr') diff --git a/randr/randrstr.h b/randr/randrstr.h index f52d0f284..25174798f 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -232,6 +232,9 @@ typedef Bool (*RRProviderSetOffloadSinkProcPtr)(ScreenPtr pScreen, RRProviderPtr offload_sink); +typedef void (*RRProviderDestroyProcPtr)(ScreenPtr pScreen, + RRProviderPtr provider); + /* These are for 1.0 compatibility */ typedef struct _rrRefresh { @@ -330,6 +333,9 @@ typedef struct _rrScrPriv { Bool discontiguous; RRProviderPtr provider; + + RRProviderDestroyProcPtr rrProviderDestroy; + } rrScrPrivRec, *rrScrPrivPtr; extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec; diff --git a/randr/rrprovider.c b/randr/rrprovider.c index c4ed515d6..b321e6227 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -389,6 +389,8 @@ RRProviderDestroyResource (pointer value, XID pid) { rrScrPriv(pScreen); + if (pScrPriv->rrProviderDestroy) + (*pScrPriv->rrProviderDestroy)(pScreen, provider); pScrPriv->provider = NULL; } free(provider); -- cgit v1.2.3