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

View File

@ -1041,8 +1041,8 @@ void MainWindow::on_the_minute ()
void MainWindow::pause_jt9 () void MainWindow::pause_jt9 ()
{ {
// Create .lock so jt9 will wait // Create .stop so jt9 will wait
QFile l {m_config.temp_dir ().absoluteFilePath (".lock")}; QFile l {m_config.temp_dir ().absoluteFilePath (".stop")};
if (!l.open(QFile::ReadWrite)) if (!l.open(QFile::ReadWrite))
{ {
MessageBox::warning_message (this, tr ("Error creating \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ())); 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 () void MainWindow::release_jt9 ()
{ {
// Remove .lock so jt9 will continue // Create .start so jt9 will continue
QFile l {m_config.temp_dir ().absoluteFilePath (".lock")}; QFile l {m_config.temp_dir ().absoluteFilePath (".start")};
while (l.exists ()) if (!l.open(QFile::ReadWrite))
{ {
if (!l.remove ()) MessageBox::warning_message (this, tr ("Error creating \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ()));
{
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;
}
}
} }
} }
@ -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 destructor
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {

View File

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