forked from localhorst/reHDD
update shred metric in main thread instead of shred thread
This commit is contained in:
@ -71,9 +71,14 @@ void reHDD::app_logic(void)
|
||||
{
|
||||
char dummy;
|
||||
read (fdShredInformPipe[0],&dummy,1);
|
||||
updateShredMetrics(&listDrives);
|
||||
#ifdef LOG_LEVEL_HIGH
|
||||
Logger::logThis()->info("got progress signal from a shred task");
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
ui->updateTUI(&listDrives, u8SelectedEntry);
|
||||
} //endless loop
|
||||
@ -445,6 +450,33 @@ void reHDD::printDrives(list <Drive>* plistDrives)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief update shred metrics for all drives
|
||||
* \param pointer of list <Drive>* plistDrives
|
||||
* \return void
|
||||
*/
|
||||
void reHDD::updateShredMetrics(list <Drive>* plistDrives)
|
||||
{
|
||||
list <Drive>::iterator it;
|
||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||
{
|
||||
if(it->state == Drive::SHRED_ACTIVE)
|
||||
{
|
||||
Drive* pTmpDrive = iterator_to_pointer<Drive, std::list<Drive>::iterator > (it);
|
||||
//set metrics for calculating shred speed
|
||||
std::chrono::time_point<std::chrono::system_clock> chronoCurrentTimestamp = std::chrono::system_clock::now();
|
||||
time_t u32ShredTimeDelta = (chronoCurrentTimestamp - pTmpDrive->sShredSpeed.chronoShredTimestamp).count();
|
||||
if(u32ShredTimeDelta > METRIC_THRESHOLD)
|
||||
{
|
||||
pTmpDrive->sShredSpeed.u32ShredTimeDelta = u32ShredTimeDelta;
|
||||
pTmpDrive->sShredSpeed.chronoShredTimestamp = std::chrono::system_clock::now();
|
||||
pTmpDrive->sShredSpeed.ulWrittenBytes = pTmpDrive->sShredSpeed.ulSpeedMetricBytesWritten;
|
||||
pTmpDrive->sShredSpeed.ulSpeedMetricBytesWritten = 0U;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief add S.M.A.R.T data from SMART
|
||||
* \param pointer of list <Drive>* plistDrives
|
||||
|
Reference in New Issue
Block a user