Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.9 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1997
  5. //
  6. // File: svrcache.cxx
  7. //
  8. // Contents: Caching code for com interface pointer and schema pointer
  9. //
  10. // History: 28-Apr-97 SophiaC Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include <iis.hxx>
  14. BOOL SERVER_CACHE::Insert(SERVER_CACHE_ITEM * item)
  15. // returns TRUE if succeed
  16. {
  17. ASSERT(NULL != item);
  18. CLock lock;
  19. #ifdef DBG
  20. SERVER_CACHE_ITEM * item2;
  21. Cache.Reset();
  22. while (NULL != (item2 = Cache.Next()))
  23. {
  24. if ((0 == _wcsicmp(item->ServerName, item2->ServerName)) &&
  25. (item->dwThreadId == item2->dwThreadId))
  26. {
  27. ASSERT(!"item already exists");
  28. }
  29. }
  30. #endif
  31. item->key = Cache.Insert(item);
  32. return item->key != -1;
  33. }
  34. SERVER_CACHE_ITEM * SERVER_CACHE::Delete(LPWSTR ServerName, DWORD dwThreadId)
  35. // returns item found
  36. {
  37. SERVER_CACHE_ITEM * item;
  38. CLock lock;
  39. Cache.Reset();
  40. while (NULL != (item = Cache.Next()))
  41. {
  42. if ((0 == _wcsicmp(ServerName, item->ServerName)) &&
  43. (dwThreadId == item->dwThreadId))
  44. {
  45. Cache.Delete(item->key);
  46. if (item->ServerName) {
  47. delete item->ServerName;
  48. }
  49. return item;
  50. }
  51. }
  52. return NULL;
  53. }
  54. SERVER_CACHE_ITEM * SERVER_CACHE::Find(LPWSTR ServerName, DWORD dwThreadId)
  55. // returns pointer to the item found
  56. {
  57. SERVER_CACHE_ITEM * item;
  58. CLock lock;
  59. Cache.Reset();
  60. while (NULL != (item = Cache.Next()))
  61. {
  62. if ((0 == _wcsicmp(ServerName, item->ServerName)) &&
  63. (dwThreadId == item->dwThreadId))
  64. {
  65. return item;
  66. }
  67. }
  68. return NULL;
  69. }