Ignore:
Timestamp:
Feb 4, 2014, 4:58:40 PM (12 years ago)
Author:
Silvan Scherrer
Message:

Samba Server 3.6: adjust locking code

File:
1 edited

Legend:

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

    r835 r840  
    9292
    9393#ifdef __OS2__
    94         // YD we must upgrade read locks to write locks (exclusive), otherwise
     94        // YD we must upgrade read locks to write locks (exclusive), as otherwise
    9595        // the owner (us) is not allowed to write to the file (different from unix)
    9696        // if a wider previous lock is in effect, we cannot write lock our segment
    9797        // (e.g. a lock_upgrade locks all the file), so we hope the previous lock
    9898        // is a write lock: do not wait for lock.
    99         int upgradeLockRC = tdb_brlock( tdb, F_WRLCK, off, len, F_SETLK);
     99        // so this is what we try here:
     100        // 1. add a write lock and see if it works
     101        // 2. if the write lock wasn't set, we try to unlock the segment
     102        //    first and add the write lock afterwards
     103        int upgradeLockRC = tdb_brlock(tdb, F_WRLCK, off, len, TDB_LOCK_NOWAIT);
     104        if (upgradeLockRC != 0) {
     105                tdb_brunlock(tdb, F_RDLCK, off, len);
     106                int upgradeLockRC = tdb_brlock(tdb, F_WRLCK, off, len, TDB_LOCK_NOWAIT);
     107        }
    100108        TDB_LOG((tdb, TDB_DEBUG_TRACE,"upgrading lock at %d len=%d "
    101109                "before writing %s (rc=%d).\n", off, len,
Note: See TracChangeset for help on using the changeset viewer.