Changeset 836 for branches/samba-3.5.x/lib/tdb/common/open.c
- Timestamp:
- Nov 25, 2013, 6:40:10 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.5.x/lib/tdb/common/open.c
r829 r836 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!) */ … … 184 179 tdb->hash_fn = hash_fn ? hash_fn : default_tdb_hash; 185 180 186 #ifdef __OS2__187 if (os2_CrtSem(tdb, name, "tdb_open_ex") != 0) {188 goto fail;189 }190 #endif191 192 181 /* cache the page size */ 193 182 tdb->page_size = getpagesize(); … … 262 251 if ((tdb_flags & TDB_CLEAR_IF_FIRST) && 263 252 (!tdb->read_only) 264 #ifndef __OS2__265 253 && (locked = (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_WRLCK, F_SETLK, 0, 1) == 0)) 266 #endif267 254 ) { 268 255 open_flags |= O_CREAT; … … 328 315 tdb_mmap(tdb); 329 316 if (locked) { 330 #ifndef __OS2__331 317 if (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_UNLCK, F_SETLK, 0, 1) == -1) { 332 318 TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: " … … 335 321 goto fail; 336 322 } 337 338 #endif339 323 } 340 324 … … 343 327 users know we're using it. */ 344 328 345 #ifndef __OS2__346 329 if (tdb_flags & TDB_CLEAR_IF_FIRST) { 347 330 /* leave this lock in place to indicate it's in use */ … … 349 332 goto fail; 350 333 } 351 #endif352 334 353 335 /* if needed, run recovery */ … … 355 337 goto fail; 356 338 } 357 358 #ifdef __OS2__359 // YD internal databases do not get global lock!360 if (tdb->methods->tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1) == -1)361 goto fail;362 #endif363 339 364 340 #ifdef TDB_TRACE … … 382 358 * do with disk files, and resume here by releasing their 383 359 * global lock and hooking into the active list. */ 384 #ifndef __OS2__385 360 if (tdb->methods->tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1) == -1) 386 361 goto fail; 387 #endif388 362 tdb->next = tdbs; 389 363 tdbs = tdb; … … 406 380 } 407 381 SAFE_FREE(tdb->name); 408 #ifdef __OS2__409 os2_DltSem(tdb, "tdb_open_ex");410 #endif411 382 if (tdb->fd != -1) 412 383 if (close(tdb->fd) != 0) … … 449 420 } 450 421 SAFE_FREE(tdb->name); 451 #ifdef __OS2__452 // YD internal databases do not have a global lock453 if (!(tdb->flags & TDB_INTERNAL))454 tdb->methods->tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLK, 0, 1);455 #endif456 422 if (tdb->fd != -1) { 457 423 ret = close(tdb->fd); … … 459 425 } 460 426 SAFE_FREE(tdb->lockrecs); 461 #ifdef __OS2__462 os2_DltSem(tdb, "tdb_close");463 #endif464 427 465 428 /* Remove from contexts list */ … … 502 465 return 0; /* Nothing to do. */ 503 466 } 504 505 #ifdef __OS2__506 os2_DltSem(tdb, "tdb_reopen");507 508 if (os2_CrtSem(tdb, tdb->name, "tdb_reopen") != 0) {509 goto fail;510 }511 #endif512 467 513 468 if (tdb->num_locks != 0 || tdb->global_lock.count) { … … 596 551 return 0; 597 552 } 598 599 #ifdef __OS2__600 int os2_CrtSem(struct tdb_context *tdb, const char *name, const char *caller)601 {602 // name could be null, so handle it603 if (name == NULL) return -1;604 605 if (!(tdb->flags & TDB_INTERNAL))606 {607 char szSem[_MAX_PATH];608 char drive[_MAX_DRIVE], dir[_MAX_DIR];609 char fname[_MAX_FNAME], ext[_MAX_EXT];610 APIRET rc;611 // extract path info612 _splitpath( name, drive, dir, fname, ext);613 sprintf( szSem, "\\SEM32\\TDB_GL_%s%s%s%i", dir, fname, ext, global_Sem32Add);614 rc = DosCreateMutexSem( szSem, &tdb->hGlobalLock, 0, FALSE);615 if (rc == ERROR_DUPLICATE_NAME)616 rc = DosOpenMutexSem( szSem, &tdb->hGlobalLock);617 if (rc != NO_ERROR) {618 TDB_LOG((tdb, TDB_DEBUG_ERROR, "cannot open %s %d\n", szSem, rc));619 errno = EINVAL;620 return -1;621 }622 TDB_LOG((tdb, TDB_DEBUG_TRACE,"%s pid %d global handle %d\n", caller, getpid(), tdb->hGlobalLock));623 624 sprintf( szSem, "\\SEM32\\TDB_AL_%s%s%s%i", dir, fname, ext, global_Sem32Add);625 rc = DosCreateMutexSem( szSem, &tdb->hActiveLock, 0, FALSE);626 if (rc == ERROR_DUPLICATE_NAME)627 rc = DosOpenMutexSem( szSem, &tdb->hActiveLock);628 if (rc != NO_ERROR) {629 TDB_LOG((tdb, TDB_DEBUG_ERROR, "cannot open %s %d\n", szSem, rc));630 errno = EINVAL;631 return -1;632 }633 TDB_LOG((tdb, TDB_DEBUG_TRACE,"%s pid %d active handle %d\n", caller, getpid(), tdb->hActiveLock));634 635 sprintf( szSem, "\\SEM32\\TDB_TL_%s%s%s%i", dir, fname, ext, global_Sem32Add);636 rc = DosCreateMutexSem( szSem, &tdb->hTransactionLock, 0, FALSE);637 if (rc == ERROR_DUPLICATE_NAME)638 rc = DosOpenMutexSem( szSem, &tdb->hTransactionLock);639 if (rc != NO_ERROR) {640 TDB_LOG((tdb, TDB_DEBUG_ERROR, "cannot open %s %d\n", szSem, rc));641 errno = EINVAL;642 return -1;643 }644 TDB_LOG((tdb, TDB_DEBUG_TRACE,"%s pid %d transaction handle %d\n", caller, getpid(), tdb->hTransactionLock));645 }646 return 0;647 }648 649 int os2_DltSem(struct tdb_context *tdb, const char *caller)650 {651 DosCloseMutexSem( tdb->hGlobalLock);652 tdb->hGlobalLock = 0;653 DosCloseMutexSem( tdb->hActiveLock);654 tdb->hActiveLock = 0;655 DosCloseMutexSem( tdb->hTransactionLock);656 tdb->hTransactionLock = 0;657 658 return 0;659 }660 #endif661
Note:
See TracChangeset
for help on using the changeset viewer.