| 1478 | } |
| 1479 | |
| 1480 | static void cmd_sem_unlock( TARGET * t ) |
| 1481 | { |
| 1482 | CMD * cmd = ( CMD * )t->cmds; |
| 1483 | TARGETS * iter; |
| 1484 | /* Release the semaphores. */ |
| 1485 | for ( iter = cmd->unlock; iter; iter = iter->next ) |
| 1486 | { |
| 1487 | if ( DEBUG_EXECCMD ) |
| 1488 | out_printf( "SEM: %s is now free\n", object_str( |
| 1489 | iter->target->name ) ); |
| 1490 | --iter->target->asynccnt; |
| 1491 | assert( iter->target->asynccnt <= 0 ); |
| 1492 | } |
| 1493 | for ( iter = cmd->unlock; iter; iter = iter->next ) |
| 1494 | { |
| 1495 | /* Find a waiting target that's ready */ |
| 1496 | while ( iter->target->parents ) |
| 1497 | { |
| 1498 | TARGETS * first = iter->target->parents; |
| 1499 | TARGET * t1 = first->target; |
| 1500 | |
| 1501 | /* Pop the first waiting CMD */ |
| 1502 | if ( first->next ) |
| 1503 | first->next->tail = first->tail; |
| 1504 | iter->target->parents = first->next; |
| 1505 | BJAM_FREE( first ); |
| 1506 | |
| 1507 | if ( cmd_sem_lock( t1 ) ) |
| 1508 | { |
| 1509 | push_state( &state_stack, t1, NULL, T_STATE_MAKE1C ); |
| 1510 | break; |
| 1511 | } |
| 1512 | } |
| 1513 | } |
| 1514 | } |
| 1515 | |
| 1516 | #endif |
no test coverage detected