Enhanced process control for jt9 executable

The wsjtx  process creates control  files .start, .stop, or  .quit and
the jt9  process deletes  them.  This  is intended  to avoid  any race
conditions that get the processes out of sync.
This commit is contained in:
Bill Somerville 2020-03-14 00:01:54 +00:00
parent ebf4952c7c
commit 523e9a1a07
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
3 changed files with 21 additions and 43 deletions

View File

@ -18,12 +18,11 @@ subroutine jt9a()
integer*1 attach_jt9
! integer*1 lock_jt9,unlock_jt9
integer size_jt9
integer itime(8)
! Multiple instances:
character*80 mykey
integer :: lun, stat
type(dec_data), pointer :: shared_data
type(params_block) :: local_params
logical fileExists
volatile shared_data
! Multiple instances:
@ -39,17 +38,19 @@ subroutine jt9a()
i0 = len(mykey)
i0=setkey_jt9(trim(mykey))
i1=attach_jt9()
msdelay=1
msdelay=100
! Wait here until the .lock file is removed by GUI
10 inquire(file=trim(temp_dir)//'/.lock',exist=fileExists)
if(fileExists) then
! Wait here until the .start file is created by GUI
10 open(newunit=lun,file=trim(temp_dir)//'/.start',iostat=stat,status='old')
if(stat.ne.0) then
call sleep_msec(msdelay)
go to 10
endif
close(unit=lun,status='delete')
inquire(file=trim(temp_dir)//'/.quit',exist=fileExists)
if(fileExists) then
open(newunit=lun,file=trim(temp_dir)//'/.quit',iostat=stat,status='old')
if(stat.eq.0) then
close(unit=lun,status='delete')
i1=detach_jt9()
go to 999
endif
@ -83,9 +84,12 @@ subroutine jt9a()
call multimode_decoder(shared_data%ss,shared_data%id2,local_params,12000)
call timer('decoder ',1)
! Wait here until GUI routine decodeDone() has re-created the .lock file
100 inquire(file=trim(temp_dir)//'/.lock',exist=fileExists)
if(fileExists) go to 10
! Wait here until GUI routine decodeDone() has re-created the .start file
100 open(newunit=lun,file=trim(temp_dir)//'/.stop',iostat=stat,status='old')
if(stat.eq.0) then
close(unit=lun,status='delete')
go to 10
endif
call sleep_msec(msdelay)
go to 100

View File

@ -1041,8 +1041,8 @@ void MainWindow::on_the_minute ()
void MainWindow::pause_jt9 ()
{
// Create .lock so jt9 will wait
QFile l {m_config.temp_dir ().absoluteFilePath (".lock")};
// Create .stop so jt9 will wait
QFile l {m_config.temp_dir ().absoluteFilePath (".stop")};
if (!l.open(QFile::ReadWrite))
{
MessageBox::warning_message (this, tr ("Error creating \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ()));
@ -1051,21 +1051,11 @@ void MainWindow::pause_jt9 ()
void MainWindow::release_jt9 ()
{
// Remove .lock so jt9 will continue
QFile l {m_config.temp_dir ().absoluteFilePath (".lock")};
while (l.exists ())
// Create .start so jt9 will continue
QFile l {m_config.temp_dir ().absoluteFilePath (".start")};
if (!l.open(QFile::ReadWrite))
{
if (!l.remove ())
{
if (MessageBox::Cancel == MessageBox::query_message (this
, tr ("IPC Error")
, tr ("Error removing \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ())
, QString {}
, MessageBox::Retry | MessageBox::Cancel))
{
break;
}
}
MessageBox::warning_message (this, tr ("Error creating \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ()));
}
}
@ -1108,21 +1098,6 @@ void MainWindow::stop_jt9 ()
}
}
void MainWindow::cleanup_jt9 ()
{
// Remove .quit as no longer needed
QFile l {m_config.temp_dir ().absoluteFilePath (".lock")};
while (l.exists ())
{
if (!l.remove ())
{
MessageBox::query_message (this
, tr ("Error removing \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ())
, tr ("Click OK to retry"));
}
}
}
//--------------------------------------------------- MainWindow destructor
MainWindow::~MainWindow()
{

View File

@ -774,7 +774,6 @@ private:
void pause_jt9 ();
void release_jt9 ();
void stop_jt9 ();
void cleanup_jt9 ();
};
extern int killbyname(const char* progName);