Changeset 752 for trunk/server/lib/tdb


Ignore:
Timestamp:
Nov 29, 2012, 2:06:31 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.9 2nd part

Location:
trunk/server
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/lib/tdb/common/io.c

    r745 r752  
    5454        }
    5555
     56        /* Unmap, update size, remap */
     57        if (tdb_munmap(tdb) == -1) {
     58                tdb->ecode = TDB_ERR_IO;
     59                return -1;
     60        }
     61        tdb->map_size = st.st_size;
     62        tdb_mmap(tdb);
     63
    5664        if (st.st_size < (size_t)len) {
    5765                if (!probe) {
     
    6472        }
    6573
    66         /* Unmap, update size, remap */
    67         if (tdb_munmap(tdb) == -1) {
    68                 tdb->ecode = TDB_ERR_IO;
    69                 return -1;
    70         }
    71         tdb->map_size = st.st_size;
    72         tdb_mmap(tdb);
    7374        return 0;
    7475}
  • trunk/server/lib/tdb/common/lock.c

    r745 r752  
    103103
    104104        errno = EINVAL;
    105         TDB_LOG(( tdb, TDB_DEBUG_ERROR, "_mutex_brlock pid %X, failed (fd=%d) at offset %d rw_type=%d lck_type=%d len=%d, rc=%d\n",
     105        TDB_LOG(( tdb, TDB_DEBUG_ERROR, "_mutex_brlock pid %d, failed (fd=%d) at offset %d rw_type=%d lck_type=%d len=%d, rc=%d\n",
    106106                 getpid(), tdb->fd, offset, rw_type, waitflag, (int)len, rc));
    107107        tdb->ecode = TDB_ERR_LOCK;
     
    125125        off_t       offStart;
    126126        off_t       cbRange;
    127         FILELOCK    lockArea = {0}, unlockArea = {0};
    128 
    129         TDB_LOG((tdb, TDB_DEBUG_TRACE, "fcntl_lock in pid %X, fd %d, lck_type %s, rw_type %s, offset %d, len %d\n",
     127        FILELOCK    lockArea = {0}, unlockArea = {0}, unlockArea1 = {0};
     128
     129        TDB_LOG((tdb, TDB_DEBUG_TRACE, "fcntl_lock in pid %d, fd %d, lck_type %s, rw_type %s, offset %d, len %d\n",
    130130                getpid(), tdb->fd, lock_type(waitflag), read_type(rw), off, len));
    131131       
     
    144144                        unlockArea.lOffset = off;
    145145                        unlockArea.lRange  = len ? len : tdb->header.hash_size *4; //was LONG_MAX
     146                        unlockArea1.lOffset = off;
     147                        unlockArea1.lRange  = len ? len : LONG_MAX;
    146148                        break;
    147149                case F_RDLCK:
     
    158160        }
    159161               
     162// why DosSetFileLocks() in the F_UNLCK case with len == 0, fails is really a question
     163// to overcome that i do 2 unlock with 2 different length (nasty workaround imho)
    160164        rc = DosSetFileLocks(tdb->fd, &unlockArea, &lockArea, SEM_IMMEDIATE_RETURN, fAccess);
     165        if (rc != NO_ERROR && rw == F_UNLCK && len == 0)
     166        rc = DosSetFileLocks(tdb->fd, &unlockArea1, &lockArea, SEM_IMMEDIATE_RETURN, fAccess);
    161167
    162168        if (rc != NO_ERROR && waitflag) {
     
    164170                do {
    165171                        rc = DosSetFileLocks(tdb->fd, &unlockArea, &lockArea, 100, fAccess);
     172                        if (rc != NO_ERROR && rw == F_UNLCK && len == 0)
     173                        rc = DosSetFileLocks(tdb->fd, &unlockArea1, &lockArea, 100, fAccess);
    166174                        count--;
    167175                } while( count>0 && rc !=NO_ERROR);
     
    169177        }
    170178
    171         TDB_LOG(( tdb, TDB_DEBUG_TRACE, "fcntl_lock out pid %X, fd %d, lck_type %s, rw_type %s, offset %d, len %d, rc=%d\n",
     179        TDB_LOG(( tdb, TDB_DEBUG_TRACE, "fcntl_lock out pid %d, fd %d, lck_type %s, rw_type %s, offset %d, len %d, rc=%d\n",
    172180                getpid(), tdb->fd, lock_type(waitflag), read_type(rw), off, len, rc));
    173181
  • trunk/server/lib/tdb/common/open.c

    r745 r752  
    328328            (!tdb->read_only) ) {
    329329#endif
    330                 open_flags |= O_CREAT;
    331                 if (ftruncate(tdb->fd, 0) == -1) {
     330                int ret;
     331                ret = tdb_brlock(tdb, F_WRLCK, FREELIST_TOP, 0,
     332                                TDB_LOCK_WAIT);
     333                if (ret == -1) {
    332334                        TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
    333                                  "failed to truncate %s: %s\n",
    334                                  name, strerror(errno)));
    335                         goto fail; /* errno set by ftruncate */
     335                                "tdb_brlock failed for %s: %s\n",
     336                                name, strerror(errno)));
     337                        goto fail;
     338                }
     339                ret = tdb_new_database(tdb, hash_size);
     340                if (ret == -1) {
     341                        TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
     342                                "tdb_new_database failed for %s: %s\n",
     343                                name, strerror(errno)));
     344                        tdb_unlockall(tdb);
     345                        goto fail;
     346                }
     347                ret = tdb_brunlock(tdb, F_WRLCK, FREELIST_TOP, 0);
     348                if (ret == -1) {
     349                        TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
     350                                "tdb_unlockall failed for %s: %s\n",
     351                                name, strerror(errno)));
     352                        goto fail;
     353                }
     354                ret = lseek(tdb->fd, 0, SEEK_SET);
     355                if (ret == -1) {
     356                        TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
     357                                "lseek failed for %s: %s\n",
     358                                name, strerror(errno)));
     359                        goto fail;
    336360                }
    337361        }
     
    412436                        goto fail;
    413437                }
     438
    414439#endif
    415440        }
     
    543568        }
    544569        SAFE_FREE(tdb->lockrecs);
     570
    545571#ifdef __OS2__
    546572        DosCloseMutexSem( tdb->hGlobalLock);
     
    551577        tdb->hTransactionLock = 0;
    552578#endif
    553 
    554579        /* Remove from contexts list */
    555580        for (i = &tdbs; *i; i = &(*i)->next) {
Note: See TracChangeset for help on using the changeset viewer.