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/io.c

    r836 r847  
    9191
    9292#ifdef __OS2__
    93         // YD we must upgrade read locks to write locks (exclusive), otherwise
     93        // YD we must upgrade read locks to write locks (exclusive), as otherwise
    9494        // the owner (us) is not allowed to write to the file (different from unix)
    9595        // if a wider previous lock is in effect, we cannot write lock our segment
    9696        // (e.g. a lock_upgrade locks all the file), so we hope the previous lock
    9797        // is a write lock: do not wait for lock.
    98         int upgradeLockRC = tdb_brlock( tdb, off, F_WRLCK, F_SETLK, 0, len);
     98        // so this is what we try here:
     99        // 1. add a write lock and see if it works
     100        // 2. if the write lock wasn't set, we try to unlock the segment
     101        //    first and add the write lock afterwards
     102        int upgradeLockRC = 0;
     103        upgradeLockRC = tdb_brlock( tdb, off, F_WRLCK, F_SETLK, 0, len);
     104        if (upgradeLockRC != 0) {
     105                tdb_brlock(tdb, off, F_UNLCK, F_SETLK, 0, len);
     106                upgradeLockRC = tdb_brlock(tdb, off, F_WRLCK, F_SETLK, 0, len);
     107        }
    99108        TDB_LOG((tdb, TDB_DEBUG_TRACE,"upgrading lock at %d len=%d "
    100109                "before writing %s (rc=%d).\n", off, len,
    101                  upgradeLockRC ? "was successfull":"failed", upgradeLockRC));
     110                 upgradeLockRC ? "failed":"was successfull", upgradeLockRC));
    102111#endif
    103112
     
    137146
    138147#ifdef __OS2__ // remove our lock, if upgrade succeded
    139                         if (upgradeLockRC == 0)
    140                                 tdb_brlock( tdb, off, F_UNLCK, F_SETLK, 0, len);
     148        if (upgradeLockRC == 0)
     149                tdb_brlock( tdb, off, F_UNLCK, F_SETLK, 0, len);
    141150#endif
    142151
Note: See TracChangeset for help on using the changeset viewer.