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

    r836 r847  
    3636}
    3737
     38#ifdef __OS2__
     39static int handle_mutex_lock(struct tdb_context *tdb, HMTX mutex, int rw, int waitflag)
     40{
     41        ULONG   ulTimeout;
     42        APIRET  rc;
     43
     44        if (mutex == 0) {
     45                printf( "fcntl_lock: sem not initialised\n");
     46                exit(1);
     47        }
     48
     49        if (waitflag == F_SETLKW)
     50                ulTimeout = SEM_INDEFINITE_WAIT;
     51        else
     52                ulTimeout = SEM_IMMEDIATE_RETURN;
     53
     54        switch (rw) {
     55        case F_UNLCK:
     56                rc = DosReleaseMutexSem(mutex);
     57                break;
     58        case F_RDLCK: // we never wait for a read lock, as several want to hold one
     59                rc = DosRequestMutexSem(mutex, SEM_IMMEDIATE_RETURN);
     60                if (rc == ERROR_NOT_OWNER || ERROR_TIMEOUT)
     61                        rc = NO_ERROR;
     62                break;
     63        case F_WRLCK:
     64                rc = DosRequestMutexSem(mutex, ulTimeout);
     65                break;
     66        }
     67
     68        if (rc == NO_ERROR || rc == ERROR_SEM_OWNER_DIED)
     69                return 0;
     70
     71        TDB_LOG((tdb, TDB_DEBUG_TRACE,"handle_mutex_lock: (fd=%d) rw_type=%d waitflag=%d (rc=%d)\n",
     72                tdb->fd, rw, waitflag, rc));
     73
     74        errno = EINVAL;
     75        return -1;
     76}
     77#endif
     78
    3879/* a byte range locking function - return 0 on success
    3980   this functions locks/unlocks 1 byte at the specified offset.
     
    70111        fl.l_pid = 0;
    71112
     113#ifdef __OS2__
     114        TDB_LOG((tdb, TDB_DEBUG_TRACE,"tdb_brlock: (fd=%d) offset=%d rw_type=%d len=%d lock_type=%d\n",
     115                tdb->fd, offset, rw_type, len, lck_type));
     116
     117        if (offset == ACTIVE_LOCK) {
     118                ret = handle_mutex_lock(tdb, tdb->hActiveLock, rw_type, lck_type);
     119        } else {
     120
     121#endif
    72122        do {
    73123                ret = fcntl(tdb->fd,lck_type,&fl);
     
    81131        } while (ret == -1 && errno == EINTR);
    82132
     133#ifdef __OS2__
     134        }
     135#endif
    83136        if (ret == -1) {
    84137                tdb->ecode = TDB_ERR_LOCK;
     
    109162                struct timeval tv;
    110163
     164#ifdef __OS2__
     165                // we need to remove locks, as upgrade doesn't work
     166                tdb_brlock(tdb, offset, F_UNLCK, F_SETLK, 1, len);
     167#endif
    111168                if (tdb_brlock(tdb, offset, F_WRLCK, F_SETLKW, 1, len) == 0) {
    112169                        return 0;
Note: See TracChangeset for help on using the changeset viewer.