Ignore:
Timestamp:
Feb 14, 2014, 7:01:54 PM (11 years ago)
Author:
Silvan Scherrer
Message:

samba server 3.5: bring 3.5 code base in line with 3.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.5.x/lib/tdb/common/open.c

    r836 r847  
    231231        }
    232232
     233#ifdef __OS2__
     234        if (os2_crtSem(tdb, name, "tdb_open_ex") != 0)
     235                goto fail;
     236#endif
     237
    233238        if ((tdb->fd = open(name, open_flags, mode)) == -1) {
    234239                TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_open_ex: could not open file %s: %s\n",
     
    367372        { int save_errno = errno;
    368373
     374#ifdef __OS2__
     375        DosCloseMutexSem(tdb->hActiveLock);
     376        tdb->hActiveLock = 0;
     377#endif
    369378        if (!tdb)
    370379                return NULL;
     
    434443        }
    435444
     445#ifdef __OS2__
     446        DosCloseMutexSem(tdb->hActiveLock);
     447        tdb->hActiveLock = 0;
     448#endif
     449
    436450#ifdef TDB_TRACE
    437451        close(tdb->tracefd);
     
    500514        tdb_mmap(tdb);
    501515#endif /* fake pread or pwrite */
     516
     517#ifdef __OS2__
     518        DosCloseMutexSem(tdb->hActiveLock);
     519        tdb->hActiveLock = 0;
     520
     521        if (os2_crtSem(tdb, tdb->name, "tdb_reopen") != 0)
     522                goto fail;
     523#endif
    502524
    503525        if (active_lock &&
     
    551573        return 0;
    552574}
     575#ifdef __OS2__
     576int os2_crtSem(struct tdb_context *tdb, const char *name, const char *caller)
     577{
     578        // name could be null, so handle it
     579        if (name == NULL)
     580                return -1;
     581
     582        char    szSem[_MAX_PATH];
     583        char    drive[_MAX_DRIVE], dir[_MAX_DIR];
     584        char    fname[_MAX_FNAME], ext[_MAX_EXT];
     585        APIRET  rc;
     586        // extract path info
     587        _splitpath(name, drive, dir, fname, ext);
     588        sprintf(szSem, "\\SEM32\\TDB_AL_%s%s%s", dir, fname, ext);
     589        rc = DosCreateMutexSem(szSem, &tdb->hActiveLock, 0, FALSE);
     590        if (rc == ERROR_DUPLICATE_NAME)
     591                rc = DosOpenMutexSem(szSem, &tdb->hActiveLock);
     592        if (rc != NO_ERROR) {
     593                TDB_LOG((tdb, TDB_DEBUG_ERROR, "os2_crtSem: cannot create sem32 %s (rc=%d) called from %s\n",
     594                        szSem, rc, caller));
     595                errno = EINVAL;
     596                return -1;
     597        }
     598        return 0;
     599}
     600#endif
Note: See TracChangeset for help on using the changeset viewer.