diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 4dcd61e6168..8df143a7c02 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -215,13 +215,11 @@ static struct JoyDev *joydevs = NULL; static void find_joydevs(void) { - int i; + int i; - if (have_joydevs!=-1) { - return; - } - - have_joydevs = 0; + if (InterlockedCompareExchange(&have_joydevs, 0, -1) != -1) + /* Someone beat us to it */ + return; for (i=0;i