Changeset 866
- Timestamp:
- May 22, 2014, 12:01:24 PM (11 years ago)
- Location:
- trunk/server/lib/tdb/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/lib/tdb/common/io.c
r857 r866 110 110 upgradeLockRC = tdb_brlock(tdb, F_WRLCK, off, len, TDB_LOCK_NOWAIT); 111 111 } 112 // no need to log a successful upgrade 113 if (upgradeLockRC != 0) 112 114 TDB_LOG((tdb, TDB_DEBUG_TRACE,"upgrading lock at %d len=%d " 113 115 "before writing %s (rc=%d).\n", off, len, -
trunk/server/lib/tdb/common/open.c
r865 r866 304 304 305 305 #ifdef __OS2__ 306 if (os2_crtActiveLock(tdb, name, 1, mode) != 0)306 if (os2_crtActiveLock(tdb, name, "tdb_open_ex") != 0) 307 307 goto fail; 308 308 #endif … … 623 623 tdb->hActiveLock = -1; 624 624 625 if (os2_crtActiveLock(tdb, tdb->name, 0, 0) != 0)625 if (os2_crtActiveLock(tdb, tdb->name, "tdb_reopen") != 0) 626 626 goto fail; 627 627 #endif … … 680 680 } 681 681 #ifdef __OS2__ 682 int os2_crtActiveLock(struct tdb_context *tdb, const char *name, const int truncate, const int mode)682 int os2_crtActiveLock(struct tdb_context *tdb, const char *name, const char *origin) 683 683 { 684 684 // name could be null, so handle it … … 686 686 return 0; 687 687 688 struct stat st; 689 bool emptytdb = false; 688 690 char activeLockName[_MAX_PATH]; 691 char *emptyString = "used for active lock\n\0"; 689 692 sprintf(activeLockName, "%s_AL", name); 693 694 if ((stat(activeLockName, &st) == -1) || (st.st_size < strlen(emptyString))) 695 emptytdb = true; 696 690 697 tdb->hActiveLock = open(activeLockName, tdb->open_flags | O_CREAT, 0777); 691 698 if (tdb->hActiveLock == -1) { 692 699 TDB_LOG((tdb, TDB_DEBUG_ERROR, "os2_crtActiveLock: cannot create activeLock %s called from %s %s\n", 693 activeLockName, truncate?"tdb_open_ex":"tdb_reopen", strerror(errno)));700 activeLockName, origin, strerror(errno))); 694 701 errno = EINVAL; 695 702 return -1; … … 698 705 // we try to truncate the db when called from tdb_open_ex 699 706 // but if it's not working it's ok as well 700 if (truncate) { 701 if (lseek(tdb->hActiveLock, 0, SEEK_SET) == -1) 702 return 0; 703 704 if (ftruncate(tdb->hActiveLock, 0) == -1) 705 return 0; 706 707 tdb_write_all(tdb->hActiveLock, "used for active lock\n", 21); 708 } 707 if (emptytdb) 708 tdb_write_all(tdb->hActiveLock, emptyString, strlen(emptyString)); 709 709 710 710 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.