Changeset 752 for trunk/server/lib/tdb
- Timestamp:
- Nov 29, 2012, 2:06:31 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 746,748
- Property svn:mergeinfo changed
-
trunk/server/lib/tdb/common/io.c
r745 r752 54 54 } 55 55 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 56 64 if (st.st_size < (size_t)len) { 57 65 if (!probe) { … … 64 72 } 65 73 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);73 74 return 0; 74 75 } -
trunk/server/lib/tdb/common/lock.c
r745 r752 103 103 104 104 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", 106 106 getpid(), tdb->fd, offset, rw_type, waitflag, (int)len, rc)); 107 107 tdb->ecode = TDB_ERR_LOCK; … … 125 125 off_t offStart; 126 126 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", 130 130 getpid(), tdb->fd, lock_type(waitflag), read_type(rw), off, len)); 131 131 … … 144 144 unlockArea.lOffset = off; 145 145 unlockArea.lRange = len ? len : tdb->header.hash_size *4; //was LONG_MAX 146 unlockArea1.lOffset = off; 147 unlockArea1.lRange = len ? len : LONG_MAX; 146 148 break; 147 149 case F_RDLCK: … … 158 160 } 159 161 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) 160 164 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); 161 167 162 168 if (rc != NO_ERROR && waitflag) { … … 164 170 do { 165 171 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); 166 174 count--; 167 175 } while( count>0 && rc !=NO_ERROR); … … 169 177 } 170 178 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", 172 180 getpid(), tdb->fd, lock_type(waitflag), read_type(rw), off, len, rc)); 173 181 -
trunk/server/lib/tdb/common/open.c
r745 r752 328 328 (!tdb->read_only) ) { 329 329 #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) { 332 334 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; 336 360 } 337 361 } … … 412 436 goto fail; 413 437 } 438 414 439 #endif 415 440 } … … 543 568 } 544 569 SAFE_FREE(tdb->lockrecs); 570 545 571 #ifdef __OS2__ 546 572 DosCloseMutexSem( tdb->hGlobalLock); … … 551 577 tdb->hTransactionLock = 0; 552 578 #endif 553 554 579 /* Remove from contexts list */ 555 580 for (i = &tdbs; *i; i = &(*i)->next) {
Note:
See TracChangeset
for help on using the changeset viewer.