Merge remote-tracking branch 'whot/for-keith'

This commit is contained in:
Keith Packard 2011-07-29 14:58:58 -07:00
commit b8f61c11c9
21 changed files with 95 additions and 54 deletions

View File

@ -251,14 +251,12 @@ wakeup_handler(pointer data, int err, pointer read_mask)
return; return;
action = udev_device_get_action(udev_device); action = udev_device_get_action(udev_device);
if (action) { if (action) {
if (!strcmp(action, "add")) if (!strcmp(action, "add") || !strcmp(action, "change")) {
device_added(udev_device);
else if (!strcmp(action, "remove"))
device_removed(udev_device);
else if (!strcmp(action, "change")) {
device_removed(udev_device); device_removed(udev_device);
device_added(udev_device); device_added(udev_device);
} }
else if (!strcmp(action, "remove"))
device_removed(udev_device);
} }
udev_device_unref(udev_device); udev_device_unref(udev_device);
} }
@ -283,6 +281,9 @@ config_udev_init(void)
if (!udev_monitor) if (!udev_monitor)
return 0; return 0;
udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "input", NULL);
udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "tty", NULL); /* For Wacom serial devices */
if (udev_monitor_enable_receiving(udev_monitor)) { if (udev_monitor_enable_receiving(udev_monitor)) {
ErrorF("config/udev: failed to bind the udev monitor\n"); ErrorF("config/udev: failed to bind the udev monitor\n");
return 0; return 0;
@ -291,11 +292,20 @@ config_udev_init(void)
enumerate = udev_enumerate_new(udev); enumerate = udev_enumerate_new(udev);
if (!enumerate) if (!enumerate)
return 0; return 0;
udev_enumerate_add_match_subsystem(enumerate, "input");
udev_enumerate_add_match_subsystem(enumerate, "tty");
udev_enumerate_scan_devices(enumerate); udev_enumerate_scan_devices(enumerate);
devices = udev_enumerate_get_list_entry(enumerate); devices = udev_enumerate_get_list_entry(enumerate);
udev_list_entry_foreach(device, devices) { udev_list_entry_foreach(device, devices) {
const char *syspath = udev_list_entry_get_name(device); const char *syspath = udev_list_entry_get_name(device);
struct udev_device *udev_device = udev_device_new_from_syspath(udev, syspath); struct udev_device *udev_device = udev_device_new_from_syspath(udev, syspath);
/* Device might be gone by the time we try to open it */
if (!udev_device)
continue;
device_added(udev_device); device_added(udev_device);
udev_device_unref(udev_device); udev_device_unref(udev_device);
} }

View File

@ -1187,11 +1187,7 @@ if test "x$XKB_DFLT_RULES" = x; then
case $host_os in case $host_os in
linux*) linux*)
dnl doesn't take AutoAddDevices into account, but whatever. dnl doesn't take AutoAddDevices into account, but whatever.
if test "x$CONFIG_HAL" = xyes; then
XKB_DFLT_RULES="evdev" XKB_DFLT_RULES="evdev"
else
XKB_DFLT_RULES="base"
fi
;; ;;
*) *)
XKB_DFLT_RULES="base" XKB_DFLT_RULES="base"

View File

@ -347,7 +347,7 @@ int main(int argc, char *argv[], char *envp[])
if (dispatchException & DE_TERMINATE) if (dispatchException & DE_TERMINATE)
{ {
ddxGiveUp(); ddxGiveUp(EXIT_NO_ERROR);
break; break;
} }

View File

@ -4680,8 +4680,8 @@ An Example implementation is miPushPixels() in Xserver/mi/mipushpxl.c.</para>
<title>Shutdown Procedures</title> <title>Shutdown Procedures</title>
<para> <para>
<blockquote><programlisting> <blockquote><programlisting>
void AbortDDX() void AbortDDX(enum ExitCode error)
void ddxGiveUp() void ddxGiveUp(enum ExitCode error)
</programlisting></blockquote> </programlisting></blockquote>
Some hardware may require special work to be done before the server Some hardware may require special work to be done before the server
exits so that it is not left in an intermediate state. As explained exits so that it is not left in an intermediate state. As explained

View File

@ -821,7 +821,7 @@ static void dmxSetDefaultFontPath(char *fp)
/** This function is called in Xserver/os/utils.c from \a AbortServer(). /** This function is called in Xserver/os/utils.c from \a AbortServer().
* We must ensure that backend and console state is restored in the * We must ensure that backend and console state is restored in the
* event the server shutdown wasn't clean. */ * event the server shutdown wasn't clean. */
void AbortDDX(void) void AbortDDX(enum ExitCode error)
{ {
int i; int i;
@ -842,9 +842,9 @@ void ddxBeforeReset(void)
/** This function is called in Xserver/dix/main.c from \a main() when /** This function is called in Xserver/dix/main.c from \a main() when
* dispatchException & DE_TERMINATE (which is the only way to exit the * dispatchException & DE_TERMINATE (which is the only way to exit the
* main loop without an interruption. */ * main loop without an interruption. */
void ddxGiveUp(void) void ddxGiveUp(enum ExitCode error)
{ {
AbortDDX(); AbortDDX(error);
} }
/** This function is called in Xserver/os/osinit.c from \a OsInit(). */ /** This function is called in Xserver/os/osinit.c from \a OsInit(). */

View File

@ -232,7 +232,7 @@ KdProcessSwitch (void)
} }
void void
AbortDDX(void) AbortDDX(enum ExitCode error)
{ {
KdDisableScreens (); KdDisableScreens ();
if (kdOsFuncs) if (kdOsFuncs)
@ -249,9 +249,9 @@ AbortDDX(void)
} }
void void
ddxGiveUp (void) ddxGiveUp (enum ExitCode error)
{ {
AbortDDX (); AbortDDX (error);
} }
Bool kdDumbDriver; Bool kdDumbDriver;

View File

@ -150,7 +150,7 @@ vfbBitsPerPixel(int depth)
} }
void void
ddxGiveUp(void) ddxGiveUp(enum ExitCode error)
{ {
int i; int i;
@ -201,9 +201,9 @@ ddxGiveUp(void)
} }
void void
AbortDDX(void) AbortDDX(enum ExitCode error)
{ {
ddxGiveUp(); ddxGiveUp(error);
} }
#ifdef __APPLE__ #ifdef __APPLE__

View File

@ -1222,6 +1222,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
devs = xnfrealloc(servlayoutp->inputs, devs = xnfrealloc(servlayoutp->inputs,
(count + 1) * sizeof(InputInfoPtr)); (count + 1) * sizeof(InputInfoPtr));
devs[count - 1] = xnfalloc(sizeof(InputInfoRec)); devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
Pointer.fd = -1;
*devs[count - 1] = Pointer; *devs[count - 1] = Pointer;
devs[count - 1]->options = devs[count - 1]->options =
xf86addNewOption(devs[count -1]->options, xf86addNewOption(devs[count -1]->options,
@ -1267,6 +1268,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
devs = xnfrealloc(servlayoutp->inputs, devs = xnfrealloc(servlayoutp->inputs,
(count + 1) * sizeof(InputInfoPtr)); (count + 1) * sizeof(InputInfoPtr));
devs[count - 1] = xnfalloc(sizeof(InputInfoRec)); devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
Pointer.fd = -1;
*devs[count - 1] = Pointer; *devs[count - 1] = Pointer;
devs[count - 1]->options = devs[count - 1]->options =
xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL); xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
@ -1363,6 +1365,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
devs = xnfrealloc(servlayoutp->inputs, devs = xnfrealloc(servlayoutp->inputs,
(count + 1) * sizeof(InputInfoPtr)); (count + 1) * sizeof(InputInfoPtr));
devs[count - 1] = xnfalloc(sizeof(InputInfoRec)); devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
Keyboard.fd = -1;
*devs[count - 1] = Keyboard; *devs[count - 1] = Keyboard;
devs[count - 1]->options = devs[count - 1]->options =
xf86addNewOption(devs[count - 1]->options, xf86addNewOption(devs[count - 1]->options,

View File

@ -749,7 +749,7 @@ DoConfigure(void)
bail: bail:
OsCleanup(TRUE); OsCleanup(TRUE);
AbortDDX(); AbortDDX(EXIT_ERR_CONFIGURE);
fflush(stderr); fflush(stderr);
exit(0); exit(0);
} }

View File

@ -1198,9 +1198,9 @@ xf86LogInit(void)
} }
void void
xf86CloseLog(void) xf86CloseLog(enum ExitCode error)
{ {
LogClose(); LogClose(error);
} }

View File

@ -791,6 +791,21 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
NULL); NULL);
} }
static InputInfoPtr
duplicateDevice(InputInfoPtr pInfo)
{
InputInfoPtr dup = calloc(1, sizeof(InputInfoRec));
if (dup) {
dup->name = strdup(pInfo->name);
dup->driver = strdup(pInfo->driver);
dup->options = xf86OptionListDuplicate(pInfo->options);
/* type_name is a const string */
dup->type_name = pInfo->type_name;
dup->fd = -1;
}
return dup;
}
/* /*
* InitInput -- * InitInput --
* Initialize all supported input devices. * Initialize all supported input devices.
@ -799,7 +814,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
void void
InitInput(int argc, char **argv) InitInput(int argc, char **argv)
{ {
InputInfoPtr* pDev; InputInfoPtr* pInfo;
DeviceIntPtr dev; DeviceIntPtr dev;
xf86Info.vtRequestsPending = FALSE; xf86Info.vtRequestsPending = FALSE;
@ -807,14 +822,21 @@ InitInput(int argc, char **argv)
mieqInit(); mieqInit();
/* Initialize all configured input devices */ /* Initialize all configured input devices */
for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) { for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) {
InputInfoPtr dup;
/* Replace obsolete keyboard driver with kbd */ /* Replace obsolete keyboard driver with kbd */
if (!xf86NameCmp((*pDev)->driver, "keyboard")) { if (!xf86NameCmp((*pInfo)->driver, "keyboard")) {
strcpy((*pDev)->driver, "kbd"); strcpy((*pInfo)->driver, "kbd");
} }
/* Data passed into xf86NewInputDevice will be freed on shutdown.
* Duplicate from xf86ConfigLayout.inputs, otherwise we don't have any
* xorg.conf input devices in the second generation
*/
dup = duplicateDevice(*pInfo);
/* If one fails, the others will too */ /* If one fails, the others will too */
if (xf86NewInputDevice(*pDev, &dev, TRUE) == BadAlloc) if (xf86NewInputDevice(dup, &dev, TRUE) == BadAlloc)
break; break;
} }
@ -880,7 +902,7 @@ OsVendorInit(void)
*/ */
void void
ddxGiveUp(void) ddxGiveUp(enum ExitCode error)
{ {
int i; int i;
@ -907,7 +929,7 @@ ddxGiveUp(void)
if (xorgHWOpenConsole) if (xorgHWOpenConsole)
xf86CloseConsole(); xf86CloseConsole();
xf86CloseLog(); xf86CloseLog(error);
/* If an unexpected signal was caught, dump a core for debugging */ /* If an unexpected signal was caught, dump a core for debugging */
if (xf86Info.caughtSignal) if (xf86Info.caughtSignal)
@ -924,7 +946,7 @@ ddxGiveUp(void)
*/ */
void void
AbortDDX(void) AbortDDX(enum ExitCode error)
{ {
int i; int i;
@ -957,7 +979,7 @@ AbortDDX(void)
* This is needed for an abnormal server exit, since the normal exit stuff * This is needed for an abnormal server exit, since the normal exit stuff
* MUST also be performed (i.e. the vt must be left in a defined state) * MUST also be performed (i.e. the vt must be left in a defined state)
*/ */
ddxGiveUp(); ddxGiveUp(error);
} }
void void

View File

@ -340,7 +340,7 @@ pointer
xf86AddNewOption(pointer head, const char *name, const char *val) xf86AddNewOption(pointer head, const char *name, const char *val)
{ {
/* XXX These should actually be allocated in the parser library. */ /* XXX These should actually be allocated in the parser library. */
char *tmp = strdup(val); char *tmp = val ? strdup(val) : NULL;
char *tmp_name = strdup(name); char *tmp_name = strdup(name);
return xf86addNewOption(head, tmp_name, tmp); return xf86addNewOption(head, tmp_name, tmp);

View File

@ -140,7 +140,7 @@ extern _X_EXPORT pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event);
/* xf86Helper.c */ /* xf86Helper.c */
extern _X_EXPORT void xf86LogInit(void); extern _X_EXPORT void xf86LogInit(void);
extern _X_EXPORT void xf86CloseLog(void); extern _X_EXPORT void xf86CloseLog(enum ExitCode error);
/* xf86Init.c */ /* xf86Init.c */
extern _X_EXPORT Bool xf86LoadModules(char **list, pointer *optlist); extern _X_EXPORT Bool xf86LoadModules(char **list, pointer *optlist);

View File

@ -124,7 +124,7 @@ void DoShowOptions (void) {
} }
bail: bail:
OsCleanup (TRUE); OsCleanup (TRUE);
AbortDDX (); AbortDDX (EXIT_ERR_DRIVERS);
fflush (stderr); fflush (stderr);
exit (0); exit (0);
} }

View File

@ -844,6 +844,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
{ {
OsReleaseSignals(); OsReleaseSignals();
xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name); xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
RemoveDevice(dev, TRUE);
rval = BadMatch; rval = BadMatch;
goto unwind; goto unwind;
} }

View File

@ -114,16 +114,16 @@ CloseInput(void)
/* /*
* DDX - specific abort routine. Called by AbortServer(). * DDX - specific abort routine. Called by AbortServer().
*/ */
void AbortDDX(void) void AbortDDX(enum ExitCode error)
{ {
xnestDoFullGeneration = True; xnestDoFullGeneration = True;
xnestCloseDisplay(); xnestCloseDisplay();
} }
/* Called by GiveUp(). */ /* Called by GiveUp(). */
void ddxGiveUp(void) void ddxGiveUp(enum ExitCode error)
{ {
AbortDDX(); AbortDDX(error);
} }
#ifdef __APPLE__ #ifdef __APPLE__

View File

@ -766,9 +766,9 @@ void ddxUseMsg( void )
* ddxGiveUp -- * ddxGiveUp --
* Device dependent cleanup. Called by dix before normal server death. * Device dependent cleanup. Called by dix before normal server death.
*/ */
void ddxGiveUp( void ) void ddxGiveUp( enum ExitCode error )
{ {
ErrorF( "Quitting Xquartz\n" ); LogClose(error);
} }
@ -779,7 +779,7 @@ void ddxGiveUp( void )
* are closed. * are closed.
*/ */
_X_NORETURN _X_NORETURN
void AbortDDX( void ) { void AbortDDX( enum ExitCode error ) {
ErrorF( " AbortDDX\n" ); ErrorF( " AbortDDX\n" );
OsAbort(); OsAbort();
} }

View File

@ -191,7 +191,7 @@ ddxBeforeReset (void)
/* See Porting Layer Definition - p. 57 */ /* See Porting Layer Definition - p. 57 */
void void
ddxGiveUp (void) ddxGiveUp (enum ExitCode error)
{ {
int i; int i;
@ -228,7 +228,7 @@ ddxGiveUp (void)
g_pszLogFile = LogInit (g_pszLogFile, NULL); g_pszLogFile = LogInit (g_pszLogFile, NULL);
g_fLogInited = TRUE; g_fLogInited = TRUE;
} }
LogClose (); LogClose (error);
/* /*
* At this point we aren't creating any new screens, so * At this point we aren't creating any new screens, so
@ -258,12 +258,12 @@ ddxGiveUp (void)
/* See Porting Layer Definition - p. 57 */ /* See Porting Layer Definition - p. 57 */
void void
AbortDDX (void) AbortDDX (enum ExitCode error)
{ {
#if CYGDEBUG #if CYGDEBUG
winDebug ("AbortDDX\n"); winDebug ("AbortDDX\n");
#endif #endif
ddxGiveUp (); ddxGiveUp (error);
} }
#ifdef __CYGWIN__ #ifdef __CYGWIN__
@ -901,7 +901,7 @@ ddxUseMsg(void)
g_pszLogFile = LogInit (g_pszLogFile, NULL); g_pszLogFile = LogInit (g_pszLogFile, NULL);
g_fLogInited = TRUE; g_fLogInited = TRUE;
} }
LogClose (); LogClose (EXIT_NO_ERROR);
/* Notify user where UseMsg text can be found.*/ /* Notify user where UseMsg text can be found.*/
if (!g_fNoHelpMessageBox) if (!g_fNoHelpMessageBox)

View File

@ -81,7 +81,7 @@ OsVendorFatalError (void)
g_fLogInited = TRUE; g_fLogInited = TRUE;
g_pszLogFile = LogInit (g_pszLogFile, NULL); g_pszLogFile = LogInit (g_pszLogFile, NULL);
} }
LogClose (); LogClose (EXIT_ERR_ABORT);
winMessageBoxF ( winMessageBoxF (
"A fatal error has occurred and " PROJECT_NAME " will now exit.\n" \ "A fatal error has occurred and " PROJECT_NAME " will now exit.\n" \

View File

@ -459,8 +459,15 @@ typedef struct {
/* stuff for FlushCallback */ /* stuff for FlushCallback */
extern _X_EXPORT CallbackListPtr FlushCallback; extern _X_EXPORT CallbackListPtr FlushCallback;
extern _X_EXPORT void AbortDDX(void); enum ExitCode {
extern _X_EXPORT void ddxGiveUp(void); EXIT_NO_ERROR = 0,
EXIT_ERR_ABORT = 1,
EXIT_ERR_CONFIGURE = 2,
EXIT_ERR_DRIVERS = 3,
};
extern _X_EXPORT void AbortDDX(enum ExitCode error);
extern _X_EXPORT void ddxGiveUp(enum ExitCode error);
extern _X_EXPORT int TimeSinceLastInputEvent(void); extern _X_EXPORT int TimeSinceLastInputEvent(void);
/* strcasecmp.c */ /* strcasecmp.c */
@ -508,7 +515,7 @@ typedef enum {
} MessageType; } MessageType;
extern _X_EXPORT const char *LogInit(const char *fname, const char *backup); extern _X_EXPORT const char *LogInit(const char *fname, const char *backup);
extern _X_EXPORT void LogClose(void); extern _X_EXPORT void LogClose(enum ExitCode error);
extern _X_EXPORT Bool LogSetParameter(LogParameter param, int value); extern _X_EXPORT Bool LogSetParameter(LogParameter param, int value);
extern _X_EXPORT void LogVWrite(int verb, const char *f, va_list args) _X_ATTRIBUTE_PRINTF(2,0); extern _X_EXPORT void LogVWrite(int verb, const char *f, va_list args) _X_ATTRIBUTE_PRINTF(2,0);
extern _X_EXPORT void LogWrite(int verb, const char *f, ...) _X_ATTRIBUTE_PRINTF(2,3); extern _X_EXPORT void LogWrite(int verb, const char *f, ...) _X_ATTRIBUTE_PRINTF(2,3);

View File

@ -231,9 +231,11 @@ LogInit(const char *fname, const char *backup)
} }
void void
LogClose(void) LogClose(enum ExitCode error)
{ {
if (logFile) { if (logFile) {
ErrorF("Server terminated %s (%d). Closing log file.\n",
(error == EXIT_NO_ERROR) ? "successfully" : "with error", error);
fclose(logFile); fclose(logFile);
logFile = NULL; logFile = NULL;
} }
@ -411,7 +413,7 @@ AbortServer(void)
CloseWellKnownConnections(); CloseWellKnownConnections();
OsCleanup(TRUE); OsCleanup(TRUE);
CloseDownDevices(); CloseDownDevices();
AbortDDX(); AbortDDX(EXIT_ERR_ABORT);
fflush(stderr); fflush(stderr);
if (CoreDump) if (CoreDump)
OsAbort(); OsAbort();