Changeset 4446 for trunk/src


Ignore:
Timestamp:
Oct 6, 2000, 9:49:06 PM (25 years ago)
Author:
hugh
Message:

Updated to latest WINE

Location:
trunk/src/DPlayX
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/DPlayX/dplay.cpp

    r4317 r4446  
    1 // $Id: dplay.cpp,v 1.2 2000-09-24 22:47:36 hugh Exp $
     1// $Id: dplay.cpp,v 1.3 2000-10-06 19:49:03 hugh Exp $
    22/* Direct Play 2,3,4 Implementation
    33 *
     
    3232DEFAULT_DEBUG_CHANNEL(dplay)
    3333
     34#undef debugstr_guid
    3435#define debugstr_guid(a) a
    3536
     
    274275  This->dp2->spData.dwSPVersion = DPSP_MAJORVERSION;
    275276
    276   This->dp2->spData.lpCB = (LPDPSP_SPCALLBACKS)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
    277                                       sizeof( *This->dp2->spData.lpCB ) );
     277  This->dp2->spData.lpCB = (DPSP_SPCALLBACKS*)HeapAlloc( GetProcessHeap(),
     278                                                         HEAP_ZERO_MEMORY,
     279                                                         sizeof( *This->dp2->spData.lpCB ) );
    278280  This->dp2->spData.lpCB->dwSize = sizeof( *This->dp2->spData.lpCB );
    279281  This->dp2->spData.lpCB->dwVersion = DPSP_MAJORVERSION;
     
    634636         wVersion );
    635637
     638  DebugBreak();
     639
    636640  switch( wCommandId )
    637641  {
     
    650654                                                        *lpdwMsgSize );
    651655
    652       FIXME( "Ignoring dwFlags in msg\n" );
     656      FIXME( "Ignoring dwFlags in request msg\n" );
     657
     658#if 0
     659      /* This is just a test. See how large the SPData is and send it */
     660      {
     661        LPVOID lpData;
     662        DWORD  dwDataSize;
     663        HRESULT hr;
     664
     665        hr = IDirectPlaySP_GetSPData( This->dp2->spData.lpISP, &lpData,
     666                                      &dwDataSize, DPSET_REMOTE );
     667
     668        if( FAILED(hr) )
     669        {
     670          ERR( "Unable to get remote SPData %s\n", DPLAYX_HresultToString(hr) );
     671        }
     672
     673      }
     674#endif
    653675
    654676      /* Setup the reply */
     
    660682      lpReply->envelope.wVersion   = DPMSGVER_DP6;
    661683
    662 #if 0
    663       /* FIXME: Need to know the proper contents of the message! */
    664684      lpReply->dpidNewPlayerId = DP_NextObjectId();
    665 #endif
     685
     686      TRACE( "Allocating new playerid 0x%08lx from remote request\n",
     687             lpReply->dpidNewPlayerId );
    666688
    667689      break;
     
    670692    case DPMSGCMD_NEWPLAYERIDREPLY:
    671693    {
    672 
    673       DebugBreak();
    674694
    675695      if( This->dp2->hMsgReceipt )
     
    684704      else
    685705      {
    686         ERR( "No receipt event set\n" );
     706        ERR( "No receipt event set - only expecting in reply mode\n" );
    687707      }
    688708
     
    13161336  BOOL bAnsi )
    13171337{
     1338  HANDLE hr = DP_OK;
    13181339  lpPlayerData lpPData;
    13191340  lpPlayerList lpPList;
     
    13531374    else
    13541375    {
    1355       HRESULT hr = DP_MSG_SendRequestPlayerId( This, dwFlags, lpidPlayer );
     1376      hr = DP_MSG_SendRequestPlayerId( This, dwFlags, lpidPlayer );
    13561377
    13571378      if( FAILED(hr) )
     
    14211442    data.lpISP             = This->dp2->spData.lpISP;
    14221443
    1423     (*This->dp2->spData.lpCB->CreatePlayer)( &data );
     1444    hr = (*This->dp2->spData.lpCB->CreatePlayer)( &data );
     1445  }
     1446
     1447  if( FAILED(hr) )
     1448  {
     1449    ERR( "Failed to create player with sp: %s\n", DPLAYX_HresultToString(hr) );
     1450    return hr;
     1451  }
     1452
     1453  /* Now let the SP know that this player is a member of the system group */
     1454  if( This->dp2->spData.lpCB->AddPlayerToGroup )
     1455  {
     1456    DPSP_ADDPLAYERTOGROUPDATA data;
     1457
     1458    data.idPlayer = *lpidPlayer;
     1459    data.idGroup  = DPID_SYSTEM_GROUP;
     1460    data.lpISP    = This->dp2->spData.lpISP;
     1461
     1462    TRACE( "Calling SP AddPlayerToGroup (sys group)\n" );
     1463
     1464    hr = (*This->dp2->spData.lpCB->AddPlayerToGroup)( &data );
     1465  }
     1466
     1467  if( FAILED(hr) )
     1468  {
     1469    ERR( "Failed to add player to sys groupwith sp: %s\n",
     1470         DPLAYX_HresultToString(hr) );
     1471    return hr;
    14241472  }
    14251473
     
    14471495    /* FIXME: Should size include data w/ message or just message "header" */
    14481496    /* FIXME: Check return code */
    1449     DP_SendEx( This, DPID_SERVERPLAYER, DPID_ALLPLAYERS, 0, &msg, sizeof( msg ),
    1450                0, 0, NULL, NULL, bAnsi );
    1451   }
    1452 
    1453   return DP_OK;
     1497    hr = DP_SendEx( This, DPID_SERVERPLAYER, DPID_ALLPLAYERS, 0, &msg,
     1498                    sizeof( msg ), 0, 0, NULL, NULL, bAnsi );
     1499  }
     1500
     1501  return hr;
    14541502}
    14551503
     
    19471995
    19481996  FIXME( ": not checking for conditions\n" );
     1997
     1998  /* Not sure if this should be pruning but it's convenient */
     1999  NS_PruneSessionCache( lpNSInfo );
    19492000
    19502001  NS_ResetSessionEnumeration( lpNSInfo );
     
    26752726  if( dwFlags & DPOPEN_JOIN )
    26762727  {
    2677     DPID dpidServerId = DPID_SERVERPLAYER;
     2728    DPID dpidServerId = DPID_UNKNOWN;
    26782729
    26792730    /* Create the server player for this interface. This way we can receive
     
    26972748  }
    26982749
     2750  if( FAILED(hr) )
     2751  {
     2752    ERR( "Couldn't create name server/system player: %s\n",
     2753         DPLAYX_HresultToString(hr) );
     2754  }
     2755
    26992756  return hr;
    27002757}
     
    34063463  }
    34073464
    3408   if( (LPVOID)lpEnumCallback==NULL || *(int*)lpEnumCallback==NULL )
     3465  if( lpEnumCallback==NULL || *(DWORD*)lpEnumCallback==0 )
    34093466  {
    34103467     return DPERR_INVALIDPARAMS;
     
    34603517      }
    34613518
    3462       if( RegQueryValueExA( hkServiceProvider, guidDataSubKey,
     3519      if( RegQueryValueExA( hkServiceProvider, (LPSTR)guidDataSubKey,
    34633520                            NULL, &returnTypeGUID, (LPBYTE)returnBuffer,
    34643521                            &sizeOfReturnBuffer ) != ERROR_SUCCESS )
     
    34693526
    34703527      /* FIXME: Check return types to ensure we're interpreting data right */
    3471       lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, (LPCSTR)returnBuffer );
     3528      lpWGUIDString = HEAP_strdupAtoW( GetProcessHeap(), 0, returnBuffer );
    34723529      CLSIDFromString( (LPCOLESTR)lpWGUIDString, &serviceProviderGUID );
    34733530      HeapFree( GetProcessHeap(), 0, lpWGUIDString );
     
    35663623      }
    35673624
    3568       if( RegQueryValueExA( hkServiceProvider, guidDataSubKey,
     3625      if( RegQueryValueExA( hkServiceProvider, (LPSTR)guidDataSubKey,
    35693626                            NULL, &returnTypeGUID, (LPBYTE)returnBuffer,
    35703627                            &sizeOfReturnBuffer ) != ERROR_SUCCESS )
     
    39103967   * The rest will be done in DP_LoadSP
    39113968   */
    3912   This->dp2->spData.lpAddress = (LPDPADDRESS)lpConnection;
     3969  This->dp2->spData.lpAddress = (DPADDRESS*)lpConnection;
    39133970  This->dp2->spData.dwAddressSize = dwAddrSize;
    39143971  This->dp2->spData.lpGuid = &guidSP;
  • trunk/src/DPlayX/dplaysp.cpp

    r4317 r4446  
    1 // $Id: dplaysp.cpp,v 1.2 2000-09-24 22:47:37 hugh Exp $
     1// $Id: dplaysp.cpp,v 1.3 2000-10-06 19:49:04 hugh Exp $
    22/* This contains the implementation of the interface Service
    33 * Providers require to communicate with Direct Play
     
    2828DEFAULT_DEBUG_CHANNEL(dplay);
    2929
     30#undef  debugstr_guid
    3031#define debugstr_guid(a) a
    3132
     
    380381         This, idPlayer, lplpData, lpdwDataSize, dwFlags );
    381382
     383  /* What to do in the case where there is nothing set yet? */
     384
    382385  *lplpData     = This->sp->lpPlayerData;
    383386  *lpdwDataSize = This->sp->dwPlayerDataSize;
     
    451454    }
    452455
     456    case DPMSGCMD_GETNAMETABLE:
     457    case DPMSGCMD_GETNAMETABLEREPLY:
    453458    case DPMSGCMD_NEWPLAYERIDREPLY:
    454459    case DPMSGCMD_REQUESTNEWPLAYERID:
  • trunk/src/DPlayX/dplayx_global.cpp

    r4317 r4446  
    1 // $Id: dplayx_global.cpp,v 1.2 2000-09-24 22:47:37 hugh Exp $
     1// $Id: dplayx_global.cpp,v 1.3 2000-10-06 19:49:05 hugh Exp $
    22/* dplayx.dll global data implementation.
    33 *
     
    3232DEFAULT_DEBUG_CHANNEL(dplay);
    3333
     34#undef  debugstr_guid
    3435#define debugstr_guid(a) a
    3536
  • trunk/src/DPlayX/dplayx_messages.cpp

    r4317 r4446  
    1 // $Id: dplayx_messages.cpp,v 1.2 2000-09-24 22:47:38 hugh Exp $
     1// $Id: dplayx_messages.cpp,v 1.3 2000-10-06 19:49:05 hugh Exp $
    22/* DirectPlay & DirectPlayLobby messaging implementation
    33 *
     
    2626DEFAULT_DEBUG_CHANNEL(dplay)
    2727
     28#undef  debugstr_guid
    2829#define debugstr_guid(a) a
    2930
     
    158159  HRESULT                    hr = DP_OK;
    159160
    160   FIXME( "semi stub\n" );
    161 
    162   DebugBreak();
    163 
    164161  dwMsgSize = This->dp2->spData.dwSPHeaderSize + sizeof( *lpMsgBody );
    165162
     
    195192    This->dp2->hMsgReceipt = CreateEventA( NULL, FALSE, FALSE, NULL );
    196193
     194    TRACE( "Sending request for player id\n" );
     195
    197196    hr = (*This->dp2->spData.lpCB->Send)( &data );
    198197
     
    201200      ERR( "Request for new playerID send failed: %s\n",
    202201           DPLAYX_HresultToString( hr ) );
     202      return DPERR_NOCONNECTION;
    203203    }
    204204  }
     
    208208  {
    209209    ERR( "Wait failed 0x%08lx\n", dwWaitReturn );
     210    hr = DPERR_TIMEOUT;
    210211  }
    211212
     
    214215
    215216  /* Need to examine the data and extract the new player id */
    216   /* I just hope that dplay doesn't return the whole new player! */
     217  if( !FAILED(hr) )
     218  {
     219    LPCDPMSG_NEWPLAYERIDREPLY lpcReply;
     220
     221    lpcReply = (LPCDPMSG_NEWPLAYERIDREPLY)This->dp2->lpMsgReceived;
     222
     223    *lpdpidAllocatedId = lpcReply->dpidNewPlayerId;
     224
     225    TRACE( "Received reply for id = 0x%08lx\n", lpcReply->dpidNewPlayerId );
     226
     227    /* FIXME: I think that the rest of the message has something to do
     228     *        with remote data for the player that perhaps I need to setup.
     229     */
     230#if 0
     231   /* Set the passed service provider data */
     232   IDirectPlaySP_SetSPData( This->dp2->spData.lpISP, data,
     233                            msgsize, DPSET_REMOTE );
     234
     235#endif
     236
     237    HeapFree( GetProcessHeap(), 0, This->dp2->lpMsgReceived );
     238    This->dp2->lpMsgReceived = NULL;
     239  }
    217240
    218241  return hr;
  • trunk/src/DPlayX/dplayx_messages.h

    r4317 r4446  
    1 // $Id: dplayx_messages.h,v 1.2 2000-09-24 22:47:39 hugh Exp $
     1// $Id: dplayx_messages.h,v 1.3 2000-10-06 19:49:06 hugh Exp $
    22
    33#ifndef __WINE_DPLAYX_MESSAGES__
     
    2121#define DPMSGCMD_ENUMSESSIONSREQUEST  2
    2222
    23 #define DPMSGCMD_GETSETNAMETABLE      3 /* Request info from NS about
    24                                            existing players/groups etc. Is
    25                                            also used for reply */
    2623
    2724#define DPMSGCMD_REQUESTNEWPLAYERID   5
     
    3633#define DPMSGCMD_ENUMGROUPS           17
    3734
    38 #define DPMSGCMD_FORWARDCREATEPLAYER  19  /* This may be a get name table req */
     35#define DPMSGCMD_GETNAMETABLE         19
     36
     37#define DPMSGCMD_GETNAMETABLEREPLY    29
    3938
    4039/* This is what DP 6 defines it as. Don't know what it means. All messages
     
    5049 */
    5150
    52 /* Size is 4 bytes */
     51/* Size is 8 bytes */
    5352typedef struct tagDPMSG_SENDENVELOPE
    5453{
     
    128127typedef const DPMSG_REQUESTNEWPLAYERID* LPCDPMSG_REQUESTNEWPLAYERID;
    129128
    130 /* 64 byte - ~18 header ~= 46 bytes msg */
     129/* 48 bytes msg */
    131130typedef struct tagDPMSG_NEWPLAYERIDREPLY
    132131{
    133132  DPMSG_SENDENVELOPE envelope;
    134133
    135 #if 0
    136134  DPID dpidNewPlayerId;
    137 #else
    138   BYTE unknown[38];
     135#if 1
     136  /* Assume that this is data that is tacked on to the end of the message
     137   * that comes from the SP remote data stored that needs to be propagated.
     138   */
     139  BYTE unknown[36];     /* This appears to always be 0 - not sure though */
    139140#endif
    140141
  • trunk/src/DPlayX/dplayx_queue.h

    r4317 r4446  
    1 // $Id: dplayx_queue.h,v 1.2 2000-09-24 22:47:39 hugh Exp $
     1// $Id: dplayx_queue.h,v 1.3 2000-10-06 19:49:06 hugh Exp $
    22/* A queue definition based on sys/queue.h TAILQ definitions
    33 *
     
    7979#define DPQ_FIND_ENTRY( head, elm, field, fieldCompareOperator, fieldToCompare, rc )\
    8080do {                                                           \
    81   (rc) = (head).lpQHFirst; /* NULL head? */                    \
     81  (rc) = DPQ_FIRST(head); /* NULL head? */                     \
    8282                                                               \
    8383  while( rc )                                                  \
     
    100100/* head - pointer to DPQ_HEAD struct
    101101 * elm  - how to find the next element
     102 * field - to be concatenated to rc to compare with fieldToCompare
     103 * fieldToCompare - The value that we're comparing against
     104 * compare_cb - Callback to invoke to determine if comparision should continue.
     105 *              Callback must be defined with DPQ_DECL_COMPARECB.
     106 * rc - Variable to put the return code. Same type as (head).lpQHFirst
     107 */
     108#define DPQ_FIND_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc )\
     109do {                                                           \
     110  (rc) = DPQ_FIRST(head); /* NULL head? */                     \
     111                                                               \
     112  while( rc )                                                  \
     113  {                                                            \
     114      /* What we're searching for? */                          \
     115      if( compare_cb( &((rc)->field), &(fieldToCompare) ) )    \
     116      {                                                        \
     117        break; /* no more */                                   \
     118      }                                                        \
     119                                                               \
     120      /* End of list check */                                  \
     121      if( ( (rc) = (rc)->elm.lpQNext ) == (head).lpQHFirst )   \
     122      {                                                        \
     123        rc = NULL;                                             \
     124        break;                                                 \
     125      }                                                        \
     126  }                                                            \
     127} while(0)
     128
     129/* How to define the method to be passed to DPQ_DELETEQ */
     130#define DPQ_DECL_COMPARECB( name, type ) BOOL name( const type* elem1, const type* elem2 )
     131
     132
     133/* head - pointer to DPQ_HEAD struct
     134 * elm  - how to find the next element
    102135 * field - to be concatenated to rc to compare with fieldToEqual
    103136 * fieldToCompare - The value that we're comparing against
     
    117150} while(0)
    118151
     152/* head - pointer to DPQ_HEAD struct
     153 * elm  - how to find the next element
     154 * field - to be concatenated to rc to compare with fieldToCompare
     155 * fieldToCompare - The value that we're comparing against
     156 * compare_cb - Callback to invoke to determine if comparision should continue.
     157 *              Callback must be defined with DPQ_DECL_COMPARECB.
     158 * rc - Variable to put the return code. Same type as (head).lpQHFirst
     159 */
     160#define DPQ_REMOVE_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc )\
     161do {                                                           \
     162  DPQ_FIND_ENTRY_CB( head, elm, field, compare_cb, fieldToCompare, rc );\
     163                                                               \
     164  /* Was the element found? */                                 \
     165  if( rc )                                                     \
     166  {                                                            \
     167    DPQ_REMOVE( head, rc, elm );                               \
     168  }                                                            \
     169} while(0)
     170
     171
    119172/* Delete the entire queue
    120173 * head - pointer to the head of the queue
     
    123176 * df - a delete function to be called. Declared with DPQ_DECL_DELETECB.
    124177 */
    125 #define DPQ_DELETEQ( head, field, type, df )            \
    126 while( !DPQ_IS_EMPTY(head) )                               \
    127 {                                                       \
    128   type holder = (head).lpQHFirst;                      \
    129   DPQ_REMOVE( head, holder, field );                    \
    130   df( holder );                                \
    131 }
     178#define DPQ_DELETEQ( head, field, type, df )     \
     179do                                               \
     180{                                                \
     181  while( !DPQ_IS_EMPTY(head) )                   \
     182  {                                              \
     183    type holder = DPQ_FIRST(head);               \
     184    DPQ_REMOVE( head, holder, field );           \
     185    df( holder );                                \
     186  }                                              \
     187} while(0)
    132188
    133189/* How to define the method to be passed to DPQ_DELETEQ */
  • trunk/src/DPlayX/dplobby.cpp

    r4317 r4446  
    1 // $Id: dplobby.cpp,v 1.2 2000-09-24 22:47:38 hugh Exp $
     1// $Id: dplobby.cpp,v 1.3 2000-10-06 19:49:05 hugh Exp $
    22/* Direct Play Lobby 2 & 3 Implementation
    33 *
     
    2828DEFAULT_DEBUG_CHANNEL(dplay)
    2929
     30#undef  debugstr_guid
    3031#define debugstr_guid(a) a
    3132
     
    11481149{
    11491150  /* These are the handles for the created process */
    1150   HANDLE hAppStart, hAppDeath, hAppRead;
     1151  HANDLE hAppStart, hAppDeath, hAppRead, hTemp;;
    11511152  SECURITY_ATTRIBUTES s_attrib;
    11521153
     
    11561157
    11571158  /* FIXME: Is there a handle leak here? */
    1158   *lphStart = CreateEventA( &s_attrib, TRUE, FALSE, NULL );
    1159   *lphDeath = CreateEventA( &s_attrib, TRUE, FALSE, NULL );
    1160   *lphRead  = CreateEventA( &s_attrib, TRUE, FALSE, NULL );
     1159  hTemp = CreateEventA( &s_attrib, TRUE, FALSE, NULL );
     1160  *lphStart = ConvertToGlobalHandle( hTemp );
     1161
     1162  hTemp = CreateEventA( &s_attrib, TRUE, FALSE, NULL );
     1163  *lphDeath = ConvertToGlobalHandle( hTemp );
     1164
     1165  hTemp = CreateEventA( &s_attrib, TRUE, FALSE, NULL );
     1166  *lphRead  = ConvertToGlobalHandle( hTemp );
    11611167
    11621168  if( ( !DuplicateHandle( GetCurrentProcess(), *lphStart,
  • trunk/src/DPlayX/makefile

    r4315 r4446  
    1 # $Id: makefile,v 1.10 2000-09-24 22:28:35 hugh Exp $
     1# $Id: makefile,v 1.11 2000-10-06 19:49:06 hugh Exp $
    22
    33#
     
    7070$(PDWIN32_LIB)/user32.lib
    7171$(PDWIN32_LIB)/ole32.lib
     72$(PDWIN32_LIB)/winmm.lib
    7273$(PDWIN32_LIB)/ntdll.lib
    7374$(PDWIN32_LIB)/msvfw32.lib
  • trunk/src/DPlayX/name_server.cpp

    r4317 r4446  
    1 // $Id: name_server.cpp,v 1.2 2000-09-24 22:47:38 hugh Exp $
     1// $Id: name_server.cpp,v 1.3 2000-10-06 19:49:06 hugh Exp $
    22/* DPLAYX.DLL name server implementation
    33 *
     
    2121#include "heap.h"
    2222#include "heapstring.h"
     23#include "mmsystem.h"
    2324
    2425#include "dplayx_global.h"
     
    3233DEFAULT_DEBUG_CHANNEL(dplay);
    3334
     35#undef  debugstr_guid
    3436#define debugstr_guid(a) a
    3537
     
    5456};
    5557typedef struct NSCache NSCache, *lpNSCache;
     58
     59/* Function prototypes */
     60DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData );
    5661
    5762/* Name Server functions
     
    6166{
    6267#if 0
     68  /* FIXME: Remove this method? */
    6369  DPLAYX_SetLocalSession( lpsd );
    6470#endif
     71}
     72
     73DPQ_DECL_COMPARECB( cbUglyPig, GUID )
     74{
     75  return IsEqualGUID( elem1, elem2 );
    6576}
    6677
     
    7788
    7889  /* FIXME: Should check to see if the reply is for an existing session. If
    79    *        so we just update the contents and update the timestamp.
     90   *        so we remove the old and add the new so oldest is at front.
    8091   */
     92
     93  /* See if we can find this session. If we can, remove it as it's a dup */
     94  DPQ_REMOVE_ENTRY_CB( lpCache->first, next, data->guidInstance, cbUglyPig,
     95                     lpMsg->sd.guidInstance, lpCacheNode );
     96
     97  if( lpCacheNode != NULL )
     98  {
     99    TRACE( "Duplicate session entry for %s removed - updated version kept\n",
     100           debugstr_guid( &lpCacheNode->data->guidInstance ) );
     101    cbDeleteNSNodeFromHeap( lpCacheNode );
     102  }
     103
     104  /* Add this to the list */
    81105  lpCacheNode = (lpNSCacheData)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
    82106                                          sizeof( *lpCacheNode ) );
     
    128152  /* Ok. Cheat and don't search for the correct stuff just take the first.
    129153   * FIXME: In the future how are we to know what is _THE_ enum we used?
     154   *        This is going to have to go into dplay somehow. Perhaps it
     155   *        comes back with app server id for the join command! Oh...that
     156   *        must be it. That would make this method obsolete once that's
     157   *        in place.
    130158   */
    131159
     
    171199}
    172200
    173 DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData );
    174201DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData )
    175202{
     203  /* NOTE: This proc doesn't deal with the walking pointer */
     204
    176205  /* FIXME: Memory leak on data (contained ptrs) */
    177206  HeapFree( GetProcessHeap(), 0, elem->data );
     
    259288{
    260289  lpNSCache     lpCache = (lpNSCache)lpNSInfo;
    261   lpNSCacheData lpCacheEntry;
    262 
    263   DWORD dwPresentTime = GetTickCount();
    264 #if defined( HACK_TIMEGETTIME )
    265   DWORD dwPruneTime   = dwPresentTime - 2; /* One iteration with safety */
    266 #else
    267   DWORD dwPruneTime   = dwPresentTime - 10000 /* 10 secs? */;
    268 #endif
    269 
    270   FIXME( ": semi stub\n" );
    271 
    272   /* FIXME: This doesn't handle time roll over correctly */
    273   /* FIXME: Session memory leak on delete */
    274   do
    275   {
    276     DPQ_FIND_ENTRY( lpCache->first, next, dwTime, <=, dwPruneTime, lpCacheEntry );
    277   }
    278   while( lpCacheEntry != NULL );
     290
     291  const DWORD dwPresentTime = timeGetTime();
     292  const DWORD dwPrunePeriod = 60000; /* is 60 secs enough? */
     293  const DWORD dwPruneTime   = dwPresentTime - dwPrunePeriod;
     294
     295  /* This silly little algorithm is based on the fact we keep entries in
     296   * the queue in a time based order. It also assumes that it is not possible
     297   * to wrap around over yourself (which is not unreasonable).
     298   * The if statements verify if the first entry in the queue is less
     299   * than dwPrunePeriod old depending on the "clock" roll over.
     300   */
     301  for( ;; )
     302  {
     303    lpNSCacheData lpFirstData;
     304
     305    if( DPQ_IS_EMPTY(lpCache->first) )
     306    {
     307      /* Nothing to prune */
     308      break;
     309    }
     310
     311    if( dwPruneTime > dwPresentTime ) /* 0 <= dwPresentTime <= dwPrunePeriod */
     312    {
     313      if( ( DPQ_FIRST(lpCache->first)->dwTime <= dwPresentTime ) ||
     314          ( DPQ_FIRST(lpCache->first)->dwTime > dwPruneTime )
     315        )
     316      {
     317        /* Less than dwPrunePeriod old - keep */
     318        break;
     319      }
     320    }
     321    else /* dwPrunePeriod <= dwPresentTime <= max dword */
     322    {
     323      if( ( DPQ_FIRST(lpCache->first)->dwTime <= dwPresentTime ) &&
     324          ( DPQ_FIRST(lpCache->first)->dwTime > dwPruneTime )
     325        )
     326      {
     327        /* Less than dwPrunePeriod old - keep */
     328        break;
     329      }
     330    }
     331
     332    lpFirstData = DPQ_FIRST(lpCache->first);
     333    DPQ_REMOVE( lpCache->first, DPQ_FIRST(lpCache->first), next );
     334    cbDeleteNSNodeFromHeap( lpFirstData );
     335  }
    279336
    280337}
Note: See TracChangeset for help on using the changeset viewer.