From ae26ca6c286d6508b45c4348adc69d038a997707 Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Sat, 27 Dec 2008 11:23:08 -0700 Subject: [PATCH] dinput: Make find_joydevs re-entrant. --- dlls/dinput/joystick_linuxinput.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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