Ignore:
Timestamp:
Apr 26, 2001, 3:22:49 PM (24 years ago)
Author:
sandervl
Message:

added mailslot implemenation, named pipe fixes + FreeLibraryAndExitThread

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/HandleManager.cpp

    r5019 r5587  
    1 /* $Id: HandleManager.cpp,v 1.62 2001-01-23 18:31:25 sandervl Exp $ */
     1/* $Id: HandleManager.cpp,v 1.63 2001-04-26 13:22:42 sandervl Exp $ */
    22
    33/*
     
    6262#include "HMNPipe.h"
    6363#include "HMStd.h"
     64#include "HMMailslot.h"
     65
    6466#include <vmutex.h>
    6567#include <win\thread.h>
     
    142144  HMDeviceHandler        *pHMThread;
    143145  HMDeviceHandler        *pHMNamedPipe;
     146  HMDeviceHandler        *pHMMailslot;
    144147
    145148  ULONG         ulHandleLast;                   /* index of last used handle */
     
    422425    HMGlobals.pHMThread     = new HMDeviceThreadClass("\\\\THREAD\\");
    423426    HMGlobals.pHMNamedPipe  = new HMDeviceNamedPipeClass("\\\\PIPE\\");
     427    HMGlobals.pHMMailslot   = new HMMailslotClass("\\MAILSLOT\\");
    424428  }
    425429  return (NO_ERROR);
     
    463467  if(HMGlobals.pHMNamedPipe)
    464468    delete HMGlobals.pHMNamedPipe;
     469  if(HMGlobals.pHMMailslot)
     470    delete HMGlobals.pHMMailslot;
    465471  if(HMGlobals.pHMDisk)
    466472    delete HMGlobals.pHMDisk;
     
    41984204                                       nDefaultTimeOut,lpSecurityAttributes);
    41994205
    4200   if (rc == 0)     /* oops, creation failed within the device handler */
     4206  if (rc == -1)     /* oops, creation failed within the device handler */
    42014207  {
    42024208      TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;
    4203   return 0;                                           /* signal error */
     4209      return 0;                                           /* signal error */
    42044210  }
    42054211
     
    45344540  return TRUE;
    45354541}
     4542
     4543/*****************************************************************************
     4544 * Name      : HMCreateMailslotA
     4545 * Purpose   :
     4546 * Parameters:
     4547 * Variables :
     4548 * Result    :
     4549 * Remark    :
     4550 * Status    :
     4551 *
     4552 * Author    : SvL
     4553 *****************************************************************************/
     4554HANDLE HMCreateMailslotA(LPCSTR lpName, DWORD nMaxMessageSize,
     4555                         DWORD lReadTimeout,
     4556                         LPSECURITY_ATTRIBUTES lpSecurityAttributes)
     4557{
     4558  int             iIndex;                     /* index into the handle table */
     4559  int             iIndexNew;                  /* index into the handle table */
     4560  HMMailslotClass *pDeviceHandler;            /* device handler for this handle */
     4561  PHMHANDLEDATA   pHMHandleData;
     4562  BOOL            rc;                                     /* API return code */
     4563
     4564  SetLastError(ERROR_SUCCESS);
     4565
     4566  pDeviceHandler = (HMMailslotClass *)HMGlobals.pHMMailslot;         /* device is predefined */
     4567
     4568  iIndexNew = _HMHandleGetFree();                         /* get free handle */
     4569  if (-1 == iIndexNew)                            /* oops, no free handles ! */
     4570  {
     4571    SetLastError(ERROR_NOT_ENOUGH_MEMORY);      /* use this as error message */
     4572    return 0;
     4573  }
     4574
     4575  /* initialize the complete HMHANDLEDATA structure */
     4576  pHMHandleData = &TabWin32Handles[iIndexNew].hmHandleData;
     4577  pHMHandleData->dwType     = FILE_TYPE_UNKNOWN;
     4578  pHMHandleData->dwAccess   = 0;
     4579  pHMHandleData->dwShare    = 0;
     4580  pHMHandleData->dwCreation = 0;
     4581  pHMHandleData->dwFlags    = 0;
     4582  pHMHandleData->lpHandlerData = NULL;
     4583
     4584  /* we've got to mark the handle as occupied here, since another device */
     4585  /* could be created within the device handler -> deadlock */
     4586
     4587  /* write appropriate entry into the handle table if open succeeded */
     4588  TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = iIndexNew;
     4589  TabWin32Handles[iIndexNew].pDeviceHandler         = pDeviceHandler;
     4590
     4591  /* call the device handler */
     4592
     4593  rc = pDeviceHandler->CreateMailslotA(&TabWin32Handles[iIndexNew].hmHandleData,
     4594                                       lpName, nMaxMessageSize,
     4595                                       lReadTimeout, lpSecurityAttributes);
     4596
     4597  if (rc == FALSE)     /* oops, creation failed within the device handler */
     4598  {
     4599      TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;
     4600      return 0;                                           /* signal error */
     4601  }
     4602
     4603  return iIndexNew;
     4604}
     4605/*****************************************************************************
     4606 * Name      : HMGetMailslotInfo
     4607 * Purpose   :
     4608 * Parameters:
     4609 * Variables :
     4610 * Result    :
     4611 * Remark    :
     4612 * Status    :
     4613 *
     4614 * Author    : SvL
     4615 *****************************************************************************/
     4616BOOL HMGetMailslotInfo(HANDLE  hMailslot,
     4617                       LPDWORD lpMaxMessageSize,
     4618                       LPDWORD lpNextSize,
     4619                       LPDWORD lpMessageCount,
     4620                       LPDWORD lpReadTimeout)
     4621{
     4622  int       iIndex;                           /* index into the handle table */
     4623  BOOL      lpResult;                /* result from the device handler's API */
     4624  PHMHANDLE pHMHandle;       /* pointer to the handle structure in the table */
     4625
     4626  SetLastError(ERROR_SUCCESS);
     4627                                                          /* validate handle */
     4628  iIndex = _HMHandleQuery(hMailslot);              /* get the index */
     4629  if (-1 == iIndex)                                               /* error ? */
     4630  {
     4631    SetLastError(ERROR_INVALID_HANDLE);       /* set win32 error information */
     4632    return FALSE;                                         /* signal failure */
     4633  }
     4634
     4635  pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
     4636  lpResult = pHMHandle->pDeviceHandler->GetMailslotInfo(&TabWin32Handles[iIndex].hmHandleData,
     4637                                                        lpMaxMessageSize,
     4638                                                        lpNextSize,
     4639                                                        lpMessageCount,
     4640                                                        lpReadTimeout);
     4641  return (lpResult);                                  /* deliver return code */
     4642}
     4643/*****************************************************************************
     4644 * Name      : HMSetMailslotInfo
     4645 * Purpose   :
     4646 * Parameters:
     4647 * Variables :
     4648 * Result    :
     4649 * Remark    :
     4650 * Status    :
     4651 *
     4652 * Author    : SvL
     4653 *****************************************************************************/
     4654BOOL HMSetMailslotInfo(HANDLE hMailslot,
     4655                       DWORD  dwReadTimeout)
     4656{
     4657  int       iIndex;                           /* index into the handle table */
     4658  BOOL      lpResult;                /* result from the device handler's API */
     4659  PHMHANDLE pHMHandle;       /* pointer to the handle structure in the table */
     4660
     4661  SetLastError(ERROR_SUCCESS);
     4662                                                          /* validate handle */
     4663  iIndex = _HMHandleQuery(hMailslot);              /* get the index */
     4664  if (-1 == iIndex)                                               /* error ? */
     4665  {
     4666    SetLastError(ERROR_INVALID_HANDLE);       /* set win32 error information */
     4667    return FALSE;                                         /* signal failure */
     4668  }
     4669
     4670  pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
     4671  lpResult = pHMHandle->pDeviceHandler->SetMailslotInfo(&TabWin32Handles[iIndex].hmHandleData,
     4672                                                       dwReadTimeout);
     4673
     4674  return (lpResult);                                  /* deliver return code */
     4675}
Note: See TracChangeset for help on using the changeset viewer.