Changeset 857 for trunk/server/lib/tdb/common/open.c
- Timestamp:
- Mar 18, 2014, 4:51:05 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/lib/tdb/common/open.c
r846 r857 293 293 } 294 294 295 #ifdef __OS2__296 if (os2_crtSem(tdb, name, "tdb_open_ex") != 0)297 goto fail;298 #endif299 300 295 if ((tdb->fd = open(name, open_flags, mode)) == -1) { 301 296 TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_open_ex: could not open file %s: %s\n", … … 314 309 goto fail; /* errno set by tdb_brlock */ 315 310 } 311 312 #ifdef __OS2__ 313 if (os2_crtActiveLock(tdb, name, 1, mode) != 0) 314 goto fail; 315 #endif 316 316 317 317 /* we need to zero database if we are the only one with it open */ … … 476 476 477 477 #ifdef __OS2__ 478 DosCloseMutexSem(tdb->hActiveLock);479 tdb->hActiveLock = 0;478 close(tdb->hActiveLock); 479 tdb->hActiveLock = -1; 480 480 #endif 481 481 if (!tdb) … … 548 548 549 549 #ifdef __OS2__ 550 DosCloseMutexSem(tdb->hActiveLock);551 tdb->hActiveLock = 0;550 close(tdb->hActiveLock); 551 tdb->hActiveLock = -1; 552 552 #endif 553 553 … … 620 620 621 621 #ifdef __OS2__ 622 DosCloseMutexSem(tdb->hActiveLock);623 tdb->hActiveLock = 0;624 625 if (os2_crt Sem(tdb, tdb->name, "tdb_reopen") != 0)622 close(tdb->hActiveLock); 623 tdb->hActiveLock = -1; 624 625 if (os2_crtActiveLock(tdb, tdb->name, 0, 0) != 0) 626 626 goto fail; 627 627 #endif … … 680 680 } 681 681 #ifdef __OS2__ 682 int os2_crt Sem(struct tdb_context *tdb, const char *name, const char *caller)682 int os2_crtActiveLock(struct tdb_context *tdb, const char *name, const int truncate, const int mode) 683 683 { 684 684 // name could be null, so handle it … … 686 686 return -1; 687 687 688 char szSem[_MAX_PATH]; 689 char drive[_MAX_DRIVE], dir[_MAX_DIR]; 690 char fname[_MAX_FNAME], ext[_MAX_EXT]; 691 APIRET rc; 692 // extract path info 693 _splitpath(name, drive, dir, fname, ext); 694 sprintf(szSem, "\\SEM32\\TDB_AL_%s%s%s", dir, fname, ext); 695 rc = DosCreateMutexSem(szSem, &tdb->hActiveLock, 0, FALSE); 696 if (rc == ERROR_DUPLICATE_NAME) 697 rc = DosOpenMutexSem(szSem, &tdb->hActiveLock); 698 if (rc != NO_ERROR) { 699 TDB_LOG((tdb, TDB_DEBUG_ERROR, "os2_crtSem: cannot create sem32 %s (rc=%d) called from %s\n", 700 szSem, rc, caller)); 688 char activeLockName[_MAX_PATH]; 689 sprintf(activeLockName, "%s_AL", name); 690 tdb->hActiveLock = open(activeLockName, tdb->open_flags, mode); 691 if (tdb->hActiveLock == -1) { 692 TDB_LOG((tdb, TDB_DEBUG_ERROR, "os2_crtSem: cannot create activeLock %s called from %s\n", 693 activeLockName, truncate?"tdb_open_ex":"tdb_reopen")); 701 694 errno = EINVAL; 702 695 return -1; 703 696 } 697 698 if (truncate) { 699 if (lseek(tdb->hActiveLock, 0, SEEK_SET) == -1) 700 return -1; 701 702 if (ftruncate(tdb->hActiveLock, 0) == -1) 703 return -1; 704 705 tdb_write_all(tdb->hActiveLock, "used for active lock\n", 21); 706 } 707 704 708 return 0; 705 709 }
Note:
See TracChangeset
for help on using the changeset viewer.