| 427 | |
| 428 | |
| 429 | void L2LAPDm::serviceLoop() |
| 430 | { |
| 431 | mLock.lock(); |
| 432 | while (mRunning) { |
| 433 | // Block for up to T200 expiration, then check T200. |
| 434 | // Allow other threads to modify state while blocked. |
| 435 | // Add 2 ms to prevent race condition due to roundoff error. |
| 436 | unsigned timeout = mT200.remaining() + 2; |
| 437 | // If SAP0 is released, other SAPs need to release also. |
| 438 | if (mMaster) { |
| 439 | if (mMaster->mState==LinkReleased) { |
| 440 | OBJLOG(DEBUG) << "master release"; |
| 441 | mState=LinkReleased; |
| 442 | } |
| 443 | } |
| 444 | if (!mT200.active()) { |
| 445 | if (mState==LinkReleased) timeout=3600000; |
| 446 | else timeout = T200(); // currently 3.6sec |
| 447 | } |
| 448 | OBJLOG(DEBUG) << "read blocking up to " << timeout << " ms ";//, state=" << mState; |
| 449 | mLock.unlock(); |
| 450 | // FIXME -- If the link is released, there should be no timeout at all. |
| 451 | L2Frame* frame = mL1In.read(timeout); |
| 452 | mLock.lock(); |
| 453 | if (frame!=NULL) { |
| 454 | //OBJLOG(DEBUG) << "state=" << mState << " received " << *frame; |
| 455 | OBJLOG(DEBUG) << " received " << *frame; |
| 456 | receiveFrame(*frame); |
| 457 | delete frame; |
| 458 | } |
| 459 | if (mT200.expired()) T200Expiration(); |
| 460 | } |
| 461 | mLock.unlock(); |
| 462 | } |
| 463 | |
| 464 | |
| 465 |
no test coverage detected