detect frozen drives and show that the user

This commit is contained in:
2020-09-11 17:18:53 +02:00
parent 5f593682e2
commit 67b8e302be
7 changed files with 103 additions and 15 deletions

View File

@ -52,6 +52,7 @@ void reHDD::app_logic(void)
thread thDevices(ThreadScannDevices); //start thread that scanns for drives
thread thUserInput(ThreadUserInput); //start thread that reads user input
thread thCheckFrozenDrives(ThreadCheckFrozenDrives); //start thread that checks timeout for drives
while(1)
{
@ -60,15 +61,14 @@ void reHDD::app_logic(void)
FD_SET(fdShredInformPipe[0], &selectSet);
select(FD_SETSIZE, &selectSet, NULL, NULL, NULL);
mxScannDrives.lock();
if( FD_ISSET(fdNewDrivesInformPipe[0], &selectSet))
{
char dummy;
read (fdNewDrivesInformPipe[0],&dummy,1);
mxScannDrives.lock();
filterNewDrives(&vecDrives, &vecNewDrives); //filter and copy to app logic vector
printDrives(&vecDrives);
mxScannDrives.unlock();
}
if (FD_ISSET(fdShredInformPipe[0], &selectSet))
@ -77,9 +77,11 @@ void reHDD::app_logic(void)
read (fdShredInformPipe[0],&dummy,1);
}
ui->updateTUI(&vecDrives, u8SelectedEntry);
mxScannDrives.unlock();
} //endless loop
thDevices.join();
thUserInput.join();
thCheckFrozenDrives.join();
}
Drive* reHDD::getSelectedDrive()
@ -110,6 +112,25 @@ void reHDD::ThreadScannDevices()
}
}
void reHDD::ThreadCheckFrozenDrives()
{
while(true)
{
mxScannDrives.lock();
for(auto it = begin(vecDrives); it != end(vecDrives); ++it)
{
if(it->state == Drive::SHRED_ACTIVE)
{
it->checkFrozenDrive();
}
}
mxScannDrives.unlock();
sleep(5); //sleep 5 sec
}
}
void reHDD::ThreadUserInput()
{
while(true)