/// <summary> /// This method should be called when an unexpected failure occurs /// in the workspace. /// </summary> public void HandleMiscFailure(Exception ex) { WmSm.LockNotif(); KLogging.LogException(ex); // We cannot handle failures during task switches. We need the // task switches to succeed to recover from failures. if (m_taskSwitchFlag) { KBase.HandleException(ex, true); } // Increase the severity of the rebuild required if possible. if (m_cd.CurrentTask == KwsTask.Rebuild) { WorsenRebuild(KwsRebuildFlag.FlushKcdData | KwsRebuildFlag.FlushLocalData); } // Stop the workspace if required. SetUserTask(KwsTask.Stop); RequestTaskSwitch(KwsTask.Stop, ex); // Let the state machine sort it out. RequestRun("application failure"); WmSm.UnlockNotif(); }
/// <summary> /// Stop the KMOD thread and kill all pending and executing /// transactions. /// </summary> private void Killall(Exception ex) { // Get the list of failing transactions and clear the current data // structures. List <KmodTransaction> list = new List <KmodTransaction>(); list.AddRange(m_transactionQueue); m_transactionQueue.Clear(); if (m_curTransaction != null) { list.Add(m_curTransaction); m_curTransaction = null; } // Mark the transactions as failing. foreach (KmodTransaction transaction in list) { transaction.Status = KmodTransactionStatus.Failing; } // Stop the thread if it is running. StopKmodThread(); // Kill all transactions. foreach (KmodTransaction transaction in list) { if (transaction.Status != KmodTransactionStatus.Failing) { continue; } transaction.Status = KmodTransactionStatus.Finished; transaction.Ex = ex; if (ex != null) { KLogging.LogException(ex); } try { transaction.Run(KmodTransactionReason.Error); } catch (Exception ex2) { KBase.HandleException(ex2, true); } } }