| 1441 | |
| 1442 | |
| 1443 | void LockManager::blocking_action_thread() |
| 1444 | { |
| 1445 | /************************************** |
| 1446 | * |
| 1447 | * b l o c k i n g _ a c t i o n _ t h r e a d |
| 1448 | * |
| 1449 | ************************************** |
| 1450 | * |
| 1451 | * Functional description |
| 1452 | * Thread to handle blocking signals. |
| 1453 | * |
| 1454 | **************************************/ |
| 1455 | |
| 1456 | /* |
| 1457 | * Main thread may be gone releasing our LockManager instance |
| 1458 | * when AST can't lock appropriate attachment mutex and therefore does not return. |
| 1459 | * |
| 1460 | * This causes multiple errors when entering/releasing mutexes/semaphores. |
| 1461 | * Catch this errors and log them. |
| 1462 | * |
| 1463 | * AP 2008 |
| 1464 | */ |
| 1465 | |
| 1466 | bool atStartup = true; |
| 1467 | |
| 1468 | try |
| 1469 | { |
| 1470 | while (true) |
| 1471 | { |
| 1472 | SLONG value; |
| 1473 | |
| 1474 | { // guardian's scope |
| 1475 | LockTableGuard guard(this, FB_FUNCTION, DUMMY_OWNER); |
| 1476 | |
| 1477 | // See if the main thread has requested us to go away |
| 1478 | if (!m_processOffset || m_process->prc_process_id != PID) |
| 1479 | { |
| 1480 | if (atStartup) |
| 1481 | { |
| 1482 | m_startupSemaphore.release(); |
| 1483 | } |
| 1484 | break; |
| 1485 | } |
| 1486 | |
| 1487 | value = m_sharedMemory->eventClear(&m_process->prc_blocking); |
| 1488 | |
| 1489 | DEBUG_DELAY; |
| 1490 | |
| 1491 | while (m_processOffset) |
| 1492 | { |
| 1493 | const prc* const process = (prc*) SRQ_ABS_PTR(m_processOffset); |
| 1494 | |
| 1495 | bool completed = true; |
| 1496 | |
| 1497 | srq* lock_srq; |
| 1498 | SRQ_LOOP(process->prc_owners, lock_srq) |
| 1499 | { |
| 1500 | const own* const owner = (own*) ((UCHAR*) lock_srq - offsetof(own, own_prc_owners)); |
no test coverage detected