Historically, COM placed a giant try/except around your server's methods. If your server encountered what would normally be an unhandled exception, the giant try/except would catch it and turn it into the error RPC_E_SERVERFAULT. It then marked the exception as handled, so that the server remained running, thereby "improving robustness by keeping the server running even when it encountered a problem." Mind you, this was actually a disservice.The fact that an unhandled exception occurred means that the server was in an unexpected state. By catching the exception and saying, "Don't worry, it's all good," you end up leaving a corrupted server running. For example: HRESULT CServer::DoOneWork(...)
{
CWork *pwork = m_listWorkPending.RemoveFirst();
if (pwork) {
pwork->UpdateTimeStamp();
pwork->FrobTheWidget();
pwork->ReversePolarity();
pwork->UnfrobTheWidget();
m_listWorkDone.Add(pwork);
}
return S_OK;
}Suppose there's a bug somewhere that causes pwork->ReversePolarity() to crash. Maybe the problem is that the neutrons aren't flowing, so there's no polarity to reverse. Maybe the polarizer is not property initialized. Whatever, doesn't matter what the problem is, just assume there's a bug that prevents it from working. Read more: The old new thing
{
CWork *pwork = m_listWorkPending.RemoveFirst();
if (pwork) {
pwork->UpdateTimeStamp();
pwork->FrobTheWidget();
pwork->ReversePolarity();
pwork->UnfrobTheWidget();
m_listWorkDone.Add(pwork);
}
return S_OK;
}Suppose there's a bug somewhere that causes pwork->ReversePolarity() to crash. Maybe the problem is that the neutrons aren't flowing, so there's no polarity to reverse. Maybe the polarizer is not property initialized. Whatever, doesn't matter what the problem is, just assume there's a bug that prevents it from working. Read more: The old new thing
0 comments:
Post a Comment