Vitaliy Margolen : dinput: Make find_joydevs re-entrant.

Alexandre Julliard julliard at winehq.org
Sat Dec 27 13:45:28 CST 2008


Module: wine
Branch: master
Commit: ae26ca6c286d6508b45c4348adc69d038a997707
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ae26ca6c286d6508b45c4348adc69d038a997707

Author: Vitaliy Margolen <wine-patches at kievinfo.com>
Date:   Sat Dec 27 11:23:08 2008 -0700

dinput: Make find_joydevs re-entrant.

---

 dlls/dinput/joystick_linuxinput.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c
index 4dcd61e..8df143a 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;
-
-  if (have_joydevs!=-1) {
-    return;
-  }
+    int i;
 
-  have_joydevs = 0;
+    if (InterlockedCompareExchange(&have_joydevs, 0, -1) != -1)
+        /* Someone beat us to it */
+        return;
 
   for (i=0;i<MAX_JOYDEV;i++) {
     char	buf[MAX_PATH];




More information about the wine-cvs mailing list