Ignore:
Timestamp:
Feb 14, 2014, 3:12:09 PM (12 years ago)
Author:
Silvan Scherrer
Message:

samba server 3.6: adding mutex again for locks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/lib/tdb/common/open.c

    r834 r846  
    292292                goto internal;
    293293        }
     294
     295#ifdef __OS2__
     296        if (os2_crtSem(tdb, name, "tdb_open_ex") != 0)
     297                goto fail;
     298#endif
    294299
    295300        if ((tdb->fd = open(name, open_flags, mode)) == -1) {
     
    470475        { int save_errno = errno;
    471476
     477#ifdef __OS2__
     478        DosCloseMutexSem(tdb->hActiveLock);
     479        tdb->hActiveLock = 0;
     480#endif
    472481        if (!tdb)
    473482                return NULL;
     
    538547        }
    539548
     549#ifdef __OS2__
     550        DosCloseMutexSem(tdb->hActiveLock);
     551        tdb->hActiveLock = 0;
     552#endif
     553
    540554#ifdef TDB_TRACE
    541555        close(tdb->tracefd);
     
    605619#endif /* fake pread or pwrite */
    606620
     621#ifdef __OS2__
     622        DosCloseMutexSem(tdb->hActiveLock);
     623        tdb->hActiveLock = 0;
     624
     625        if (os2_crtSem(tdb, tdb->name, "tdb_reopen") != 0)
     626                goto fail;
     627#endif
    607628        /* We may still think we hold the active lock. */
    608629        tdb->num_lockrecs = 0;
     
    658679        return 0;
    659680}
     681#ifdef __OS2__
     682int os2_crtSem(struct tdb_context *tdb, const char *name, const char *caller)
     683{
     684        // name could be null, so handle it
     685        if (name == NULL)
     686                return -1;
     687
     688        char    szSem[_MAX_PATH];
     689        char    drive[_MAX_DRIVE], dir[_MAX_DIR];
     690        char    fname[_MAX_FNAME], ext[_MAX_EXT];
     691        APIRET  rc;
     692        // extract path info
     693        _splitpath(name, drive, dir, fname, ext);
     694        sprintf(szSem, "\\SEM32\\TDB_AL_%s%s%s", dir, fname, ext);
     695        rc = DosCreateMutexSem(szSem, &tdb->hActiveLock, 0, FALSE);
     696        if (rc == ERROR_DUPLICATE_NAME)
     697                rc = DosOpenMutexSem(szSem, &tdb->hActiveLock);
     698        if (rc != NO_ERROR) {
     699                TDB_LOG((tdb, TDB_DEBUG_ERROR, "os2_crtSem: cannot create sem32 %s (rc=%d) called from %s\n",
     700                        szSem, rc, caller));
     701                errno = EINVAL;
     702                return -1;
     703        }
     704        return 0;
     705}
     706#endif
Note: See TracChangeset for help on using the changeset viewer.