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.

75 lines
2.0 KiB

  1. /*
  2. * SESSION.C
  3. *
  4. * RSM Service : Sessions
  5. *
  6. * Author: ErvinP
  7. *
  8. * (c) 2001 Microsoft Corporation
  9. *
  10. */
  11. #include <windows.h>
  12. #include <stdlib.h>
  13. #include <wtypes.h>
  14. #include <ntmsapi.h>
  15. #include "internal.h"
  16. #include "resource.h"
  17. #include "debug.h"
  18. SESSION *NewSession(LPCWSTR lpServer,
  19. LPCWSTR lpApplication,
  20. LPCWSTR lpClientName,
  21. LPCWSTR lpUserName)
  22. {
  23. SESSION *newSession;
  24. newSession = GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT, sizeof(SESSION));
  25. if (newSession){
  26. newSession->sig = SESSION_SIG;
  27. InitializeCriticalSection(&newSession->lock);
  28. InitializeListHead(&newSession->operatorRequestList);
  29. InitializeListHead(&newSession->allSessionsListEntry);
  30. WStrNCpy(newSession->serverName, lpServer, NTMS_COMPUTERNAME_LENGTH);
  31. WStrNCpy(newSession->applicationName, lpApplication, NTMS_APPLICATIONNAME_LENGTH);
  32. WStrNCpy(newSession->clientName, lpClientName, NTMS_COMPUTERNAME_LENGTH);
  33. WStrNCpy(newSession->userName, lpUserName, NTMS_USERNAME_LENGTH);
  34. EnterCriticalSection(&g_globalServiceLock);
  35. InsertTailList(&g_allSessionsList, &newSession->allSessionsListEntry);
  36. LeaveCriticalSection(&g_globalServiceLock);
  37. }
  38. else {
  39. ASSERT(newSession);
  40. }
  41. return newSession;
  42. }
  43. VOID FreeSession(SESSION *thisSession)
  44. {
  45. // BUGBUG FINISH - clean up mounts, etc.
  46. ASSERT(IsEmptyList(&s->operatorRequestList));
  47. /*
  48. * Dequeue the session
  49. */
  50. EnterCriticalSection(&g_globalServiceLock);
  51. ASSERT(!IsEmptyList(&thisSession->allSessionsListEntry));
  52. ASSERT(!IsEmptyList(&g_allSessionsList));
  53. RemoveEntryList(&thisSession->allSessionsListEntry);
  54. InitializeListHead(&thisSession->allSessionsListEntry);
  55. LeaveCriticalSection(&g_globalServiceLock);
  56. DeleteCriticalSection(&thisSession->lock);
  57. GlobalFree(thisSession);
  58. }