Changeset 834 for trunk/server/lib/tdb/common/open.c
- Timestamp:
- Nov 25, 2013, 4:35:16 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/lib/tdb/common/open.c
r825 r834 27 27 28 28 #include "tdb_private.h" 29 30 #ifdef __OS2__31 // nmbd.c sets it to 132 int global_Sem32Add = 0;33 #endif34 29 35 30 /* all contexts, to ensure no double-opens (fcntl locks don't nest!) */ … … 242 237 } 243 238 244 #ifdef __OS2__245 if (os2_CrtSem(tdb, "tdb_open_ex") != 0) {246 goto fail;247 }248 #endif249 239 /* cache the page size */ 250 240 tdb->page_size = getpagesize(); … … 322 312 /* we need to zero database if we are the only one with it open */ 323 313 if ((tdb_flags & TDB_CLEAR_IF_FIRST) && 324 #ifndef __OS2__325 314 (!tdb->read_only) && 326 315 (locked = (tdb_nest_lock(tdb, ACTIVE_LOCK, F_WRLCK, TDB_LOCK_NOWAIT|TDB_LOCK_PROBE) == 0))) { 327 #else328 (!tdb->read_only) ) {329 #endif330 316 int ret; 331 317 ret = tdb_brlock(tdb, F_WRLCK, FREELIST_TOP, 0, … … 429 415 tdb_mmap(tdb); 430 416 if (locked) { 431 #ifndef __OS2__432 417 if (tdb_nest_unlock(tdb, ACTIVE_LOCK, F_WRLCK, false) == -1) { 433 418 TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: " … … 437 422 } 438 423 439 #endif440 424 } 441 425 … … 444 428 users know we're using it. */ 445 429 446 #ifndef __OS2__447 430 if (tdb_flags & TDB_CLEAR_IF_FIRST) { 448 431 /* leave this lock in place to indicate it's in use */ … … 451 434 } 452 435 } 453 #endif454 436 455 437 /* if needed, run recovery */ … … 457 439 goto fail; 458 440 } 459 460 #ifdef __OS2__461 // YD internal databases do not get global lock!462 if (tdb_nest_unlock(tdb, OPEN_LOCK, F_WRLCK, false) == -1)463 goto fail;464 #endif465 441 466 442 #ifdef TDB_TRACE … … 484 460 * do with disk files, and resume here by releasing their 485 461 * open lock and hooking into the active list. */ 486 #ifndef __OS2__487 462 if (tdb_nest_unlock(tdb, OPEN_LOCK, F_WRLCK, false) == -1) { 488 463 goto fail; 489 464 } 490 #endif491 465 tdb->next = tdbs; 492 466 tdbs = tdb; … … 511 485 if (close(tdb->fd) != 0) 512 486 TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: failed to close tdb->fd on error!\n")); 513 #ifdef __OS2__514 os2_DltSem(tdb, "tdb_open_ex");515 #endif516 487 SAFE_FREE(tdb->lockrecs); 517 488 SAFE_FREE(tdb->name); … … 553 524 } 554 525 SAFE_FREE(tdb->name); 555 #ifdef __OS2__556 // YD internal databases do not have a global lock557 if (!(tdb->flags & TDB_INTERNAL))558 tdb_nest_unlock(tdb, OPEN_LOCK, F_WRLCK, false);559 #endif560 526 if (tdb->fd != -1) { 561 527 ret = close(tdb->fd); … … 564 530 SAFE_FREE(tdb->lockrecs); 565 531 566 #ifdef __OS2__567 os2_DltSem(tdb, "tdb_close");568 #endif569 532 /* Remove from contexts list */ 570 533 for (i = &tdbs; *i; i = &(*i)->next) { … … 606 569 return 0; /* Nothing to do. */ 607 570 } 608 609 #ifdef __OS2__610 os2_DltSem(tdb, "tdb_reopen");611 612 if (os2_CrtSem(tdb, "tdb_reopen") != 0) {613 goto fail;614 }615 #endif616 571 617 572 if (tdb_have_extra_locks(tdb)) { … … 703 658 return 0; 704 659 } 705 706 #ifdef __OS2__707 int os2_CrtSem(struct tdb_context *tdb, const char *caller)708 {709 // tbd->name could be null, so handle it710 if (tdb->name == NULL) return -1;711 712 if (!(tdb->flags & TDB_INTERNAL))713 {714 char szSem[_MAX_PATH];715 char drive[_MAX_DRIVE], dir[_MAX_DIR];716 char fname[_MAX_FNAME], ext[_MAX_EXT];717 APIRET rc;718 // extract path info719 _splitpath( tdb->name, drive, dir, fname, ext);720 sprintf( szSem, "\\SEM32\\TDB_OL_%s%s%s%i", dir, fname, ext, global_Sem32Add);721 rc = DosCreateMutexSem( szSem, &tdb->hGlobalLock, 0, FALSE);722 if (rc == ERROR_DUPLICATE_NAME)723 rc = DosOpenMutexSem( szSem, &tdb->hGlobalLock);724 if (rc != NO_ERROR) {725 TDB_LOG((tdb, TDB_DEBUG_ERROR, "cannot open %s %d\n", szSem, rc));726 errno = EINVAL;727 return -1;728 }729 TDB_LOG((tdb, TDB_DEBUG_TRACE,"%s pid %d open handle %d\n", caller, getpid(), tdb->hGlobalLock));730 731 sprintf( szSem, "\\SEM32\\TDB_AL_%s%s%s%i", dir, fname, ext, global_Sem32Add);732 rc = DosCreateMutexSem( szSem, &tdb->hActiveLock, 0, FALSE);733 if (rc == ERROR_DUPLICATE_NAME)734 rc = DosOpenMutexSem( szSem, &tdb->hActiveLock);735 if (rc != NO_ERROR) {736 TDB_LOG((tdb, TDB_DEBUG_ERROR, "cannot open %s %d\n", szSem, rc));737 errno = EINVAL;738 return -1;739 }740 TDB_LOG((tdb, TDB_DEBUG_TRACE,"%s pid %d active handle %d\n", caller, getpid(), tdb->hActiveLock));741 742 sprintf( szSem, "\\SEM32\\TDB_TL_%s%s%s%i", dir, fname, ext, global_Sem32Add);743 rc = DosCreateMutexSem( szSem, &tdb->hTransactionLock, 0, FALSE);744 if (rc == ERROR_DUPLICATE_NAME)745 rc = DosOpenMutexSem( szSem, &tdb->hTransactionLock);746 if (rc != NO_ERROR) {747 TDB_LOG((tdb, TDB_DEBUG_ERROR, "cannot open %s %d\n", szSem, rc));748 errno = EINVAL;749 return -1;750 }751 TDB_LOG((tdb, TDB_DEBUG_TRACE,"%s pid %d transaction handle %d\n", caller, getpid(), tdb->hTransactionLock));752 }753 return 0;754 }755 756 int os2_DltSem(struct tdb_context *tdb, const char *caller)757 {758 DosCloseMutexSem( tdb->hGlobalLock);759 tdb->hGlobalLock = 0;760 DosCloseMutexSem( tdb->hActiveLock);761 tdb->hActiveLock = 0;762 DosCloseMutexSem( tdb->hTransactionLock);763 tdb->hTransactionLock = 0;764 765 return 0;766 }767 #endif
Note:
See TracChangeset
for help on using the changeset viewer.