From b8fafb8952d09ddfc10e802332638545b032ba9f Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Tue, 14 Mar 2006 03:17:39 +0000 Subject: [PATCH] sbbsctrl now supports the ctrl/recycle[.ctrl] and ctrl/shutdown[.ctrl] semaphore files so: 1. SCFG will touch ctrl/recycle causing sbbsctrl to reload its copy of the config files resolving the FAQ about why users appear to be running the wrong external program in the node window after adding/removing external programs in SCFG. 2. the control panel can now be gracefully shutdown by touching ctrl/shutdown. --- src/sbbs3/ctrl/MainFormUnit.cpp | 34 +++++++++++++++++++ src/sbbs3/ctrl/MainFormUnit.dfm | 59 ++++++++++++++++++--------------- src/sbbs3/ctrl/MainFormUnit.h | 2 ++ 3 files changed, 69 insertions(+), 26 deletions(-) diff --git a/src/sbbs3/ctrl/MainFormUnit.cpp b/src/sbbs3/ctrl/MainFormUnit.cpp index 09003cf32c..647e86ba55 100644 --- a/src/sbbs3/ctrl/MainFormUnit.cpp +++ b/src/sbbs3/ctrl/MainFormUnit.cpp @@ -126,6 +126,9 @@ DWORD services_svc_config_size; DWORD MaxLogLen=20000; int threads=1; +time_t initialized=0; +static str_list_t recycle_semfiles; +static str_list_t shutdown_semfiles; static void thread_up(void* p, BOOL up, BOOL setuid) { @@ -2224,6 +2227,12 @@ void __fastcall TMainForm::StartupTimerTick(TObject *Sender) return; } + recycle_semfiles=semfile_list_init(cfg.ctrl_dir,"recycle","ctrl"); + semfile_list_check(&initialized,recycle_semfiles); + + shutdown_semfiles=semfile_list_init(cfg.ctrl_dir,"shutdown","ctrl"); + semfile_list_check(&initialized,shutdown_semfiles); + if(!(cfg.sys_misc&SM_LOCAL_TZ)) { if(putenv("TZ=UTC0")) { Application->MessageBox("Error setting timezone" @@ -2335,6 +2344,9 @@ void __fastcall TMainForm::StartupTimerTick(TObject *Sender) NodeForm->Timer->Enabled=true; ClientForm->Timer->Enabled=true; + SemFileTimer->Interval=global.sem_chk_freq; + SemFileTimer->Enabled=true; + StatsTimer->Interval=cfg.node_stat_check*1000; StatsTimer->Enabled=true; Initialized=true; @@ -3131,6 +3143,7 @@ void __fastcall TMainForm::PropertiesExecute(TObject *Sender) SAFECOPY(global.ctrl_dir,PropertiesDlg->CtrlDirEdit->Text.c_str()); SAFECOPY(global.temp_dir,PropertiesDlg->TempDirEdit->Text.c_str()); global.sem_chk_freq=PropertiesDlg->SemFreqUpDown->Position; + SemFileTimer->Interval=global.sem_chk_freq; /* Copy global values to server startup structs */ /* We don't support per-server unique values here (yet) */ @@ -3262,6 +3275,7 @@ void __fastcall TMainForm::ReloadConfigExecute(TObject *Sender) FtpRecycleExecute(Sender); WebRecycleExecute(Sender); MailRecycleExecute(Sender); + TelnetRecycleExecute(Sender); ServicesRecycleExecute(Sender); char error[256]; @@ -3271,7 +3285,9 @@ void __fastcall TMainForm::ReloadConfigExecute(TObject *Sender) ,MB_OK|MB_ICONEXCLAMATION); Application->Terminate(); } + semfile_list_check(&initialized,recycle_semfiles); +#if 0 /* This appears to be redundant */ node_t node; for(int i=0;i<cfg.sys_nodes;i++) { int file; @@ -3281,6 +3297,7 @@ void __fastcall TMainForm::ReloadConfigExecute(TObject *Sender) if(NodeForm->putnodedat(i+1,&node,file)) break; } +#endif } //--------------------------------------------------------------------------- @@ -3682,3 +3699,20 @@ void __fastcall TMainForm::ViewFile(AnsiString filename, AnsiString Caption) } //--------------------------------------------------------------------------- + + +void __fastcall TMainForm::SemFileTimerTick(TObject *Sender) +{ + char* p; + + if((p=semfile_list_check(&initialized,shutdown_semfiles))!=NULL) { + StatusBar->Panels->Items[4]->Text=AnsiString(p) + " signaled"; + Close(); + } + else if((p=semfile_list_check(&initialized,recycle_semfiles))!=NULL) { + StatusBar->Panels->Items[4]->Text=AnsiString(p) + " signaled"; + ReloadConfigExecute(Sender); + } +} +//--------------------------------------------------------------------------- + diff --git a/src/sbbs3/ctrl/MainFormUnit.dfm b/src/sbbs3/ctrl/MainFormUnit.dfm index 5a3fb7fa77..5033ddb3b2 100644 --- a/src/sbbs3/ctrl/MainFormUnit.dfm +++ b/src/sbbs3/ctrl/MainFormUnit.dfm @@ -10,7 +10,7 @@ object MainForm: TMainForm DragMode = dmAutomatic Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText - Font.Height = -14 + Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] Icon.Data = { @@ -46,11 +46,11 @@ object MainForm: TMainForm OnCloseQuery = FormCloseQuery OnCreate = FormCreate OnShow = FormShow - PixelsPerInch = 120 - TextHeight = 16 + PixelsPerInch = 96 + TextHeight = 13 object HorizontalSplitter: TSplitter Left = 0 - Top = 195 + Top = 164 Width = 632 Height = 1 Cursor = crVSplit @@ -61,9 +61,9 @@ object MainForm: TMainForm end object Logo: TImage Left = 0 - Top = 196 + Top = 165 Width = 632 - Height = 121 + Height = 162 Align = alClient AutoSize = True Center = True @@ -13499,7 +13499,7 @@ object MainForm: TMainForm Left = 0 Top = 30 Width = 632 - Height = 165 + Height = 134 Align = alTop BevelOuter = bvNone Constraints.MinHeight = 100 @@ -13507,18 +13507,18 @@ object MainForm: TMainForm TabOrder = 1 Visible = False object TopVerticalSplitter: TSplitter - Left = 289 + Left = 235 Top = 0 - Width = 3 - Height = 165 + Width = 2 + Height = 134 Cursor = crHSplit MinSize = 1 end object UpperLeftPageControl: TPageControl Left = 0 Top = 0 - Width = 289 - Height = 165 + Width = 235 + Height = 134 Align = alLeft DockSite = True TabOrder = 0 @@ -13526,10 +13526,10 @@ object MainForm: TMainForm OnUnDock = PageControlUnDock end object UpperRightPageControl: TPageControl - Left = 292 + Left = 237 Top = 0 - Width = 340 - Height = 165 + Width = 395 + Height = 134 Align = alClient DockSite = True TabOrder = 1 @@ -13539,26 +13539,26 @@ object MainForm: TMainForm end object BottomPanel: TPanel Left = 0 - Top = 196 + Top = 165 Width = 632 - Height = 121 + Height = 162 Align = alClient BevelOuter = bvNone TabOrder = 2 Visible = False object BottomVerticalSplitter: TSplitter - Left = 289 + Left = 235 Top = 0 - Width = 3 - Height = 121 + Width = 2 + Height = 162 Cursor = crHSplit MinSize = 1 end object LowerLeftPageControl: TPageControl Left = 0 Top = 0 - Width = 289 - Height = 121 + Width = 235 + Height = 162 Align = alLeft DockSite = True TabOrder = 0 @@ -13566,10 +13566,10 @@ object MainForm: TMainForm OnUnDock = PageControlUnDock end object LowerRightPageControl: TPageControl - Left = 292 + Left = 237 Top = 0 - Width = 340 - Height = 121 + Width = 395 + Height = 162 Align = alClient DockSite = True TabOrder = 1 @@ -13579,7 +13579,7 @@ object MainForm: TMainForm end object StatusBar: TStatusBar Left = 0 - Top = 317 + Top = 327 Width = 632 Height = 25 Panels = < @@ -16995,4 +16995,11 @@ object MainForm: TMainForm Left = 504 Top = 40 end + object SemFileTimer: TTimer + Enabled = False + Interval = 5000 + OnTimer = SemFileTimerTick + Left = 472 + Top = 40 + end end diff --git a/src/sbbs3/ctrl/MainFormUnit.h b/src/sbbs3/ctrl/MainFormUnit.h index af58f0b15f..a5be4e304d 100644 --- a/src/sbbs3/ctrl/MainFormUnit.h +++ b/src/sbbs3/ctrl/MainFormUnit.h @@ -302,6 +302,7 @@ __published: // IDE-managed Components TMenuItem *ConfigureWebTrayMenuItem; TMenuItem *ConfigureServicesTrayMenuItem; TMenuItem *HelpTechnicalSupportMenuItem; + TTimer *SemFileTimer; void __fastcall FileExitMenuItemClick(TObject *Sender); void __fastcall ViewToolbarMenuItemClick(TObject *Sender); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); @@ -390,6 +391,7 @@ __published: // IDE-managed Components void __fastcall WebRecycleExecute(TObject *Sender); void __fastcall WebConfigureExecute(TObject *Sender); void __fastcall ViewServicesExecute(TObject *Sender); + void __fastcall SemFileTimerTick(TObject *Sender); private: // User declarations public: // User declarations __fastcall TMainForm(TComponent* Owner); -- GitLab