Changeset 834 for trunk/server/lib/tdb/common/io.c
- Timestamp:
- Nov 25, 2013, 4:35:16 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/lib/tdb/common/io.c
r752 r834 94 94 // YD we must upgrade read locks to write locks (exclusive), otherwise 95 95 // the owner (us) is not allowed to write to the file (different from unix) 96 TDB_LOG((tdb, TDB_DEBUG_TRACE,"unlocking at %d len=%d before writing.\n", off, len));97 tdb_brunlock( tdb, F_RDLCK, off, len);98 96 // if a wider previous lock is in effect, we cannot write lock our segment 99 97 // (e.g. a lock_upgrade locks all the file), so we hope the previous lock 100 98 // is a write lock: do not wait for lock. 101 tdb_brlock( tdb, F_WRLCK, off, len, F_SETLK); 99 int upgradeLockRC = tdb_brlock( tdb, F_WRLCK, off, len, F_SETLK); 100 TDB_LOG((tdb, TDB_DEBUG_TRACE,"upgrading lock at %d len=%d " 101 "before writing %s (rc=%d).\n", off, len, 102 upgradeLockRC ? "was successfull":"failed", upgradeLockRC)); 102 103 #endif 103 104 104 if (tdb->map_ptr) { 105 105 memcpy(off + (char *)tdb->map_ptr, buf, len); … … 127 127 "write %d bytes at %d in two attempts\n", 128 128 len, off)); 129 #ifdef __OS2__ // remove our lock 130 tdb_brunlock( tdb, F_WRLCK, off, len); 129 #ifdef __OS2__ // remove our lock, if upgrade succeded 130 if (upgradeLockRC == 0) 131 tdb_brunlock( tdb, F_WRLCK, off, len); 131 132 #endif 132 133 return -1; 133 134 } 134 135 } 135 #ifdef __OS2__ // remove our lock 136 tdb_brunlock( tdb, F_WRLCK, off, len); 136 #ifdef __OS2__ // remove our lock, if upgrade succeded 137 if (upgradeLockRC == 0) 138 tdb_brunlock( tdb, F_WRLCK, off, len); 137 139 #endif 138 140 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.