Ignore:
Timestamp:
May 28, 2001, 9:47:12 AM (24 years ago)
Author:
umoeller
Message:

Misc changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/semaphores.c

    r77 r78  
    169169 *      I have created, this returns an APIRET.
    170170 *
    171  *@@added V0.9.12 (2001-05-27) [umoeller]
    172171 */
    173172
     
    187186 *@@ UnlockGlobal:
    188187 *
    189  *@@added V0.9.12 (2001-05-27) [umoeller]
    190188 */
    191189
     
    258256 *          was set to NULLHANDLE.
    259257 *
    260  *      --  ERROR_SEM_BUSY: couldn't delete one
    261  *          of the member semaphores because they
    262  *          were held by some other thread.
    263  */
    264 
    265 APIRET semDeleteRWMutex(PHRW phrw)
     258 *      --  ERROR_SEM_BUSY: semaphore is currently
     259 *          requested.
     260 */
     261
     262APIRET semDeleteRWMutex(PHRW phrw)      // in/out: rwsem handle
    266263{
    267264    APIRET  arc = NO_ERROR;
     
    274271           )
    275272        {
    276             if (    (!(arc = DosCloseEventSem(pMutex->hevWriterDone)))
    277                  && (!(arc = DosCloseEventSem(pMutex->hevReadersDone)))
     273            if (    (pMutex->cReaders)
     274                 || (pMutex->cWriters)
    278275               )
     276                arc = ERROR_SEM_BUSY;
     277            else
    279278            {
    280                 ULONG cItems = pMutex->cReaderThreads;
    281                 TREE **papNodes = treeBuildArray(pMutex->ReaderThreadsTree,
    282                                                  &cItems);
    283                 if (papNodes)
     279                if (    (!(arc = DosCloseEventSem(pMutex->hevWriterDone)))
     280                     && (!(arc = DosCloseEventSem(pMutex->hevReadersDone)))
     281                   )
    284282                {
    285                     ULONG ul;
    286                     for (ul = 0; ul < cItems; ul++)
    287                         free(papNodes[ul]);
    288 
    289                     free(papNodes);
     283                    ULONG cItems = pMutex->cReaderThreads;
     284                    TREE **papNodes = treeBuildArray(pMutex->ReaderThreadsTree,
     285                                                     &cItems);
     286                    if (papNodes)
     287                    {
     288                        ULONG ul;
     289                        for (ul = 0; ul < cItems; ul++)
     290                            free(papNodes[ul]);
     291
     292                        free(papNodes);
     293                    }
     294
     295                    free(pMutex);
     296                    *phrw = NULLHANDLE;
    290297                }
    291 
    292                 free(pMutex);
    293                 *phrw = NULLHANDLE;
    294298            }
    295299        }
Note: See TracChangeset for help on using the changeset viewer.