Alessandro Pignotti : dplayx: Implement proper interface locking for DP_EnumSession.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Apr 3 06:48:38 CDT 2007


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

Author: Alessandro Pignotti <alex.pigna at inventati.org>
Date:   Fri Mar 30 15:00:06 2007 +0200

dplayx: Implement proper interface locking for DP_EnumSession.

---

 dlls/dplayx/dplay.c        |    6 +++++-
 dlls/dplayx/dplay_global.h |    1 +
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c
index d446f51..650adfd 100644
--- a/dlls/dplayx/dplay.c
+++ b/dlls/dplayx/dplay.c
@@ -272,6 +272,7 @@ static BOOL DP_CreateDirectPlay2( LPVOID lpDP )
   This->dp2->bConnectionOpen = FALSE;
 
   This->dp2->hEnumSessionThread = INVALID_HANDLE_VALUE;
+  This->dp2->dwEnumSessionLock = 0;
 
   This->dp2->bHostInterface = FALSE;
 
@@ -2273,7 +2274,6 @@ static HRESULT WINAPI DP_IF_EnumSessions
     return hr;
   }
 
-  /* FIXME: Interface locking sucks in this method */
   if( ( dwFlags & DPENUMSESSIONS_ASYNC ) )
   {
     /* Enumerate everything presently in the local session cache */
@@ -2281,11 +2281,14 @@ static HRESULT WINAPI DP_IF_EnumSessions
                                    This->dp2->lpNameServerData, dwTimeout,
                                    lpContext );
 
+    if( This->dp2->dwEnumSessionLock != 0 )
+      return DPERR_CONNECTING;
 
     /* See if we've already created a thread to service this interface */
     if( This->dp2->hEnumSessionThread == INVALID_HANDLE_VALUE )
     {
       DWORD dwThreadId;
+      This->dp2->dwEnumSessionLock++;
 
       /* Send the first enum request inline since the user may cancel a dialog
        * if one is presented. Also, may also have a connecting return code.
@@ -2326,6 +2329,7 @@ static HRESULT WINAPI DP_IF_EnumSessions
                                                       0,
                                                       &dwThreadId );
       }
+      This->dp2->dwEnumSessionLock--;
     }
   }
   else
diff --git a/dlls/dplayx/dplay_global.h b/dlls/dplayx/dplay_global.h
index 0c02486..095374d 100644
--- a/dlls/dplayx/dplay_global.h
+++ b/dlls/dplayx/dplay_global.h
@@ -164,6 +164,7 @@ typedef struct tagDirectPlay2Data
   /* For async EnumSessions requests */
   HANDLE hEnumSessionThread;
   HANDLE hKillEnumSessionThreadEvent;
+  DWORD  dwEnumSessionLock;
 
   LPVOID lpNameServerData; /* DPlay interface doesn't know contents */
 




More information about the wine-cvs mailing list