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

    r834 r840  
    3434
    3535static int fcntl_lock(struct tdb_context *tdb,
    36                       int rw, off_t off, off_t len, bool waitflag)
     36                      int rw, tdb_off_t off, size_t len, bool waitflag)
    3737{
    3838        struct flock fl;
     
    4848        fl.l_pid = 0;
    4949
     50#ifdef __OS2__
     51        int cmd = 0;
     52        if (waitflag)
     53                cmd = F_SETLKW;
     54        else
     55                cmd = F_SETLK;
     56
     57        int rc = fcntl(tdb->fd, cmd, &fl);
     58        // if the first lock doesn't work and it's a complete lock,
     59        // we split it in 2 parts. first hash size*4 and then the rest
     60        if (rc != 0 && off == FREELIST_TOP && len == 0) {
     61                fl.l_len = tdb->header.hash_size * 4;
     62                rc = fcntl(tdb->fd, cmd, &fl);
     63                if (rc == 0) {
     64                        fl.l_start = off + tdb->header.hash_size * 4;
     65                        fl.l_len = LONG_MAX;
     66                        rc = fcntl(tdb->fd, cmd, &fl);
     67                }
     68        }
     69        return rc;
     70#else
    5071        if (waitflag)
    5172                return fcntl(tdb->fd, F_SETLKW, &fl);
    5273        else
    5374                return fcntl(tdb->fd, F_SETLK, &fl);
    54 }
    55 
    56 static int fcntl_unlock(struct tdb_context *tdb, int rw, off_t off, off_t len)
     75#endif
     76}
     77
     78static int fcntl_unlock(struct tdb_context *tdb, int rw, tdb_off_t off, size_t len)
    5779{
    5880        struct flock fl;
     
    248270        while (count--) {
    249271                struct timeval tv;
     272#ifdef __OS2__
     273                // we need to remove locks, as upgrade doesn't work
     274                tdb_brunlock(tdb, F_RDLCK, FREELIST_TOP, 0);
     275#endif
    250276                if (tdb_brlock(tdb, F_WRLCK, FREELIST_TOP, 0,
    251277                               TDB_LOCK_WAIT|TDB_LOCK_PROBE) == 0) {
Note: See TracChangeset for help on using the changeset viewer.