From: Christian Ehrlicher Date: Mon, 27 Apr 2009 11:41:48 +0000 (+0200) Subject: fix deadlock when dbus-daemon could not start up X-Git-Tag: dbus-1.3.1~254 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a83b7cb80c375c1aaeaa8b4d8114037069e2736c;p=thirdparty%2Fdbus.git fix deadlock when dbus-daemon could not start up windbus:r811: apply patch by Thorvald Natvig to fix endless loop when _dbus_get_autolaunch_shm got called and the dbus-daemon failed to start up. * if launching for some reason fails, set an error message * _dbus_get_autolaunch_shm will abort getting the shared memory after 20 attempts (2 seconds) * _dbus_get_autolaunch_address checks if the return state of WaitForInputIdle before calling _dbus_get_autolaunch_shm. windbus:r812: remove WaitForInputIdle as it doesn't work in non-console mode (cherry picked from commit 363fd736556219bad77c4b217e051b7983dc34e9) --- diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index a4a350578..fd4eebd95 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3027,6 +3027,7 @@ _dbus_get_autolaunch_shm(DBusString *adress) char szUserName[64]; DWORD dwUserNameSize = sizeof(szUserName); char szDBusDaemonAddressInfo[128]; + int i; if( !GetUserName(szUserName, &dwUserNameSize) ) return FALSE; @@ -3034,12 +3035,14 @@ _dbus_get_autolaunch_shm(DBusString *adress) cDBusDaemonAddressInfo, szUserName); // read shm - do { + for(i=0;i<20;++i) { // we know that dbus-daemon is available, so we wait until shm is available sharedMem = OpenFileMapping( FILE_MAP_READ, FALSE, szDBusDaemonAddressInfo ); if( sharedMem == 0 ) Sleep( 100 ); - } while( sharedMem == 0 ); + if ( sharedMem != 0) + break; + } if( sharedMem == 0 ) return FALSE; @@ -3145,19 +3148,16 @@ _dbus_get_autolaunch_address (DBusString *address, _snprintf(dbus_args, sizeof(dbus_args) - 1, "\"%s\" %s", dbus_exe_path, " --session"); // argv[i] = "--config-file=bus\\session.conf"; - printf("create process \"%s\" %s\n", dbus_exe_path, dbus_args); +// printf("create process \"%s\" %s\n", dbus_exe_path, dbus_args); if(CreateProcessA(dbus_exe_path, dbus_args, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) { - retval = TRUE; - - // Wait until started (see _dbus_get_autolaunch_shm()) - WaitForInputIdle(pi.hProcess, INFINITE); retval = _dbus_get_autolaunch_shm( address ); - } else { - retval = FALSE; } + if (retval == FALSE) + dbus_set_error_const (error, DBUS_ERROR_FAILED, "Failed to launch dbus-daemon"); + out: if (retval) _DBUS_ASSERT_ERROR_IS_CLEAR (error);