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.

122 lines
3.6 KiB

  1. //
  2. // GCCHELP.CPP
  3. // GCC helper functions
  4. //
  5. // Copyright Microsoft 1998-
  6. //
  7. // PRECOMP
  8. #include "precomp.h"
  9. #include "gcchelp.h"
  10. void T126_GCCAllocateHandleConfirm(ULONG drawingHandle, ULONG handle_range)
  11. {
  12. g_WaitingForGCCHandles = FALSE;
  13. TRACE_MSG(("T126_GCCAllocateHandleConfirm drawing handle = %d, range = %d", drawingHandle, handle_range));
  14. TRACE_MSG(("GCC Tank 0 has %d GCC handles ", g_GCCPreallocHandles[0].GccHandleCount));
  15. TRACE_MSG(("GCC Tank 1 has %d GCC handles ", g_GCCPreallocHandles[1].GccHandleCount));
  16. ULONG gccHandle;
  17. if(g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount == 0)
  18. {
  19. TRACE_MSG(("Using GCC Tank %d ", g_iGCCHandleIndex));
  20. g_GCCPreallocHandles[g_iGCCHandleIndex].InitialGCCHandle = drawingHandle;
  21. g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount = handle_range;
  22. }
  23. else
  24. {
  25. UINT index = g_iGCCHandleIndex ? 0 : 1;
  26. TRACE_MSG(("T126_GCCAllocateHandleConfirm: Using GCC Tank %d that contains %d handles",
  27. index, g_GCCPreallocHandles[index].GccHandleCount ));
  28. TRACE_MSG(("Filling up GCC Tank %d ", index));
  29. g_GCCPreallocHandles[index].InitialGCCHandle = drawingHandle;
  30. g_GCCPreallocHandles[index].GccHandleCount = handle_range;
  31. }
  32. if(handle_range <= 2)
  33. {
  34. gccHandle = g_GCCPreallocHandles[g_iGCCHandleIndex].InitialGCCHandle + g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount - handle_range;
  35. g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount = g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount - handle_range;
  36. //
  37. // Remove the drawing object from the list of objects to send
  38. //
  39. T126Obj * pT126Obj = (T126Obj*)g_pListOfObjectsThatRequestedHandles->RemoveTail();
  40. if(!pT126Obj)
  41. {
  42. return;
  43. }
  44. pT126Obj->GotGCCHandle(gccHandle);
  45. }
  46. else
  47. {
  48. if(handle_range != PREALLOC_GCC_HANDLES)
  49. {
  50. //
  51. // Resend all objects
  52. //
  53. WBPOSITION pos;
  54. WBPOSITION posObj;
  55. WorkspaceObj* pWorkspace;
  56. ULONG workspaceHandle;
  57. T126Obj* pObj;
  58. pos = g_pListOfWorkspaces->GetHeadPosition();
  59. while(pos)
  60. {
  61. gccHandle = g_GCCPreallocHandles[g_iGCCHandleIndex].InitialGCCHandle + g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount - 2;
  62. if(g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount == 0)
  63. {
  64. //
  65. // Time to switch to the other tank
  66. //
  67. g_iGCCHandleIndex = g_iGCCHandleIndex ? 0 : 1;
  68. }
  69. ASSERT(g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount);
  70. g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount -=2;
  71. workspaceHandle = gccHandle;
  72. pWorkspace = (WorkspaceObj*)g_pListOfWorkspaces->GetNext(pos);
  73. pWorkspace->SetThisObjectHandle(workspaceHandle);
  74. pWorkspace->SetWorkspaceHandle(workspaceHandle);
  75. pWorkspace->SetOwnerID(g_MyMemberID);
  76. pWorkspace->SetViewHandle(workspaceHandle + 1);
  77. posObj = pWorkspace->GetHeadPosition();
  78. while(posObj)
  79. {
  80. pObj = pWorkspace->GetNextObject(posObj);
  81. if(pObj)
  82. {
  83. gccHandle = g_GCCPreallocHandles[g_iGCCHandleIndex].InitialGCCHandle + g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount - 1;
  84. ASSERT(g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount);
  85. g_GCCPreallocHandles[g_iGCCHandleIndex].GccHandleCount--;
  86. pObj->SetThisObjectHandle(gccHandle);
  87. pObj->SetWorkspaceHandle(workspaceHandle);
  88. pObj->SetOwnerID(g_MyMemberID);
  89. }
  90. }
  91. }
  92. }
  93. }
  94. //
  95. // Check if we have enough handles or shoul switch
  96. //
  97. TimeToGetGCCHandles(PREALLOC_GCC_HANDLES);
  98. SetFakeGCCHandle(drawingHandle + 1);
  99. }