From a892451cfd0c2efda2ea98451f507130f6fe7f87 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 22 Feb 2008 11:01:51 +1030 Subject: [PATCH] dix: Call DeleteInputDeviceRequest from CloseDownDevices (#14418) The DDX (xfree86 anyway) maintains its own device list in addition to the one in the DIX. CloseDevice will only remove it from the DIX, not the DDX. If the server then restarts (last client disconnects), the DDX devices are still there, will be re-initialised, then the hal devices come in and are added too. This repeats until we run out of device ids. This also requires us to strdup() the default pointer/keyboard in checkCoreInputDevices. --- dix/devices.c | 4 ++-- hw/xfree86/common/xf86Config.c | 12 ++++++------ hw/xfree86/common/xf86Xinput.c | 12 ++++++++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index bdcca5a..964ff89 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -617,12 +617,12 @@ CloseDownDevices(void) for (dev = inputInfo.devices; dev; dev = next) { next = dev->next; - CloseDevice(dev); + DeleteInputDeviceRequest(dev); } for (dev = inputInfo.off_devices; dev; dev = next) { next = dev->next; - CloseDevice(dev); + DeleteInputDeviceRequest(dev); } inputInfo.devices = NULL; inputInfo.off_devices = NULL; diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 605c6b3..11483fc 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -1335,8 +1335,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) /* 5. Built-in default. */ if (!foundPointer) { bzero(&defPtr, sizeof(defPtr)); - defPtr.inp_identifier = ""; - defPtr.inp_driver = "mouse"; + defPtr.inp_identifier = strdup(""); + defPtr.inp_driver = strdup("mouse"); confInput = &defPtr; foundPointer = TRUE; from = X_DEFAULT; @@ -1382,8 +1382,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) if (!found) { xf86Msg(X_INFO, "No default mouse found, adding one\n"); bzero(&defPtr, sizeof(defPtr)); - defPtr.inp_identifier = ""; - defPtr.inp_driver = "mouse"; + defPtr.inp_identifier = strdup(""); + defPtr.inp_driver = strdup("mouse"); confInput = &defPtr; foundPointer = configInput(&Pointer, confInput, from); if (foundPointer) { @@ -1471,8 +1471,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) /* 5. Built-in default. */ if (!foundKeyboard) { bzero(&defKbd, sizeof(defKbd)); - defKbd.inp_identifier = ""; - defKbd.inp_driver = "kbd"; + defKbd.inp_identifier = strdup(""); + defKbd.inp_driver = strdup("kbd"); confInput = &defKbd; foundKeyboard = TRUE; keyboardMsg = "default keyboard configuration"; diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index eafc0e9..d34238e 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -446,11 +446,19 @@ void DeleteInputDeviceRequest(DeviceIntPtr pDev) { LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate; - InputDriverPtr drv = pInfo->drv; - IDevRec *idev = pInfo->conf_idev; + InputDriverPtr drv; + IDevRec *idev; + if (pInfo) /* need to get these before RemoveDevice */ + { + drv = pInfo->drv; + idev = pInfo->conf_idev; + } RemoveDevice(pDev); + if (!pInfo) /* VCP and VCK */ + return; + if(drv->UnInit) drv->UnInit(drv, pInfo, 0); else -- 1.5.3