Skip to content
Snippets Groups Projects
Commit b8fafb89 authored by rswindell's avatar rswindell
Browse files

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.
parent 708d9615
No related branches found
No related tags found
No related merge requests found
...@@ -126,6 +126,9 @@ DWORD services_svc_config_size; ...@@ -126,6 +126,9 @@ DWORD services_svc_config_size;
DWORD MaxLogLen=20000; DWORD MaxLogLen=20000;
int threads=1; 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) static void thread_up(void* p, BOOL up, BOOL setuid)
{ {
...@@ -2224,6 +2227,12 @@ void __fastcall TMainForm::StartupTimerTick(TObject *Sender) ...@@ -2224,6 +2227,12 @@ void __fastcall TMainForm::StartupTimerTick(TObject *Sender)
return; 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(!(cfg.sys_misc&SM_LOCAL_TZ)) {
if(putenv("TZ=UTC0")) { if(putenv("TZ=UTC0")) {
Application->MessageBox("Error setting timezone" Application->MessageBox("Error setting timezone"
...@@ -2335,6 +2344,9 @@ void __fastcall TMainForm::StartupTimerTick(TObject *Sender) ...@@ -2335,6 +2344,9 @@ void __fastcall TMainForm::StartupTimerTick(TObject *Sender)
NodeForm->Timer->Enabled=true; NodeForm->Timer->Enabled=true;
ClientForm->Timer->Enabled=true; ClientForm->Timer->Enabled=true;
SemFileTimer->Interval=global.sem_chk_freq;
SemFileTimer->Enabled=true;
StatsTimer->Interval=cfg.node_stat_check*1000; StatsTimer->Interval=cfg.node_stat_check*1000;
StatsTimer->Enabled=true; StatsTimer->Enabled=true;
Initialized=true; Initialized=true;
...@@ -3131,6 +3143,7 @@ void __fastcall TMainForm::PropertiesExecute(TObject *Sender) ...@@ -3131,6 +3143,7 @@ void __fastcall TMainForm::PropertiesExecute(TObject *Sender)
SAFECOPY(global.ctrl_dir,PropertiesDlg->CtrlDirEdit->Text.c_str()); SAFECOPY(global.ctrl_dir,PropertiesDlg->CtrlDirEdit->Text.c_str());
SAFECOPY(global.temp_dir,PropertiesDlg->TempDirEdit->Text.c_str()); SAFECOPY(global.temp_dir,PropertiesDlg->TempDirEdit->Text.c_str());
global.sem_chk_freq=PropertiesDlg->SemFreqUpDown->Position; global.sem_chk_freq=PropertiesDlg->SemFreqUpDown->Position;
SemFileTimer->Interval=global.sem_chk_freq;
/* Copy global values to server startup structs */ /* Copy global values to server startup structs */
/* We don't support per-server unique values here (yet) */ /* We don't support per-server unique values here (yet) */
...@@ -3262,6 +3275,7 @@ void __fastcall TMainForm::ReloadConfigExecute(TObject *Sender) ...@@ -3262,6 +3275,7 @@ void __fastcall TMainForm::ReloadConfigExecute(TObject *Sender)
FtpRecycleExecute(Sender); FtpRecycleExecute(Sender);
WebRecycleExecute(Sender); WebRecycleExecute(Sender);
MailRecycleExecute(Sender); MailRecycleExecute(Sender);
TelnetRecycleExecute(Sender);
ServicesRecycleExecute(Sender); ServicesRecycleExecute(Sender);
char error[256]; char error[256];
...@@ -3271,7 +3285,9 @@ void __fastcall TMainForm::ReloadConfigExecute(TObject *Sender) ...@@ -3271,7 +3285,9 @@ void __fastcall TMainForm::ReloadConfigExecute(TObject *Sender)
,MB_OK|MB_ICONEXCLAMATION); ,MB_OK|MB_ICONEXCLAMATION);
Application->Terminate(); Application->Terminate();
} }
semfile_list_check(&initialized,recycle_semfiles);
#if 0 /* This appears to be redundant */
node_t node; node_t node;
for(int i=0;i<cfg.sys_nodes;i++) { for(int i=0;i<cfg.sys_nodes;i++) {
int file; int file;
...@@ -3281,6 +3297,7 @@ void __fastcall TMainForm::ReloadConfigExecute(TObject *Sender) ...@@ -3281,6 +3297,7 @@ void __fastcall TMainForm::ReloadConfigExecute(TObject *Sender)
if(NodeForm->putnodedat(i+1,&node,file)) if(NodeForm->putnodedat(i+1,&node,file))
break; break;
} }
#endif
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -3682,3 +3699,20 @@ void __fastcall TMainForm::ViewFile(AnsiString filename, AnsiString Caption) ...@@ -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);
}
}
//---------------------------------------------------------------------------
...@@ -10,7 +10,7 @@ object MainForm: TMainForm ...@@ -10,7 +10,7 @@ object MainForm: TMainForm
DragMode = dmAutomatic DragMode = dmAutomatic
Font.Charset = DEFAULT_CHARSET Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText Font.Color = clWindowText
Font.Height = -14 Font.Height = -11
Font.Name = 'MS Sans Serif' Font.Name = 'MS Sans Serif'
Font.Style = [] Font.Style = []
Icon.Data = { Icon.Data = {
...@@ -46,11 +46,11 @@ object MainForm: TMainForm ...@@ -46,11 +46,11 @@ object MainForm: TMainForm
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow OnShow = FormShow
PixelsPerInch = 120 PixelsPerInch = 96
TextHeight = 16 TextHeight = 13
object HorizontalSplitter: TSplitter object HorizontalSplitter: TSplitter
Left = 0 Left = 0
Top = 195 Top = 164
Width = 632 Width = 632
Height = 1 Height = 1
Cursor = crVSplit Cursor = crVSplit
...@@ -61,9 +61,9 @@ object MainForm: TMainForm ...@@ -61,9 +61,9 @@ object MainForm: TMainForm
end end
object Logo: TImage object Logo: TImage
Left = 0 Left = 0
Top = 196 Top = 165
Width = 632 Width = 632
Height = 121 Height = 162
Align = alClient Align = alClient
AutoSize = True AutoSize = True
Center = True Center = True
...@@ -13499,7 +13499,7 @@ object MainForm: TMainForm ...@@ -13499,7 +13499,7 @@ object MainForm: TMainForm
Left = 0 Left = 0
Top = 30 Top = 30
Width = 632 Width = 632
Height = 165 Height = 134
Align = alTop Align = alTop
BevelOuter = bvNone BevelOuter = bvNone
Constraints.MinHeight = 100 Constraints.MinHeight = 100
...@@ -13507,18 +13507,18 @@ object MainForm: TMainForm ...@@ -13507,18 +13507,18 @@ object MainForm: TMainForm
TabOrder = 1 TabOrder = 1
Visible = False Visible = False
object TopVerticalSplitter: TSplitter object TopVerticalSplitter: TSplitter
Left = 289 Left = 235
Top = 0 Top = 0
Width = 3 Width = 2
Height = 165 Height = 134
Cursor = crHSplit Cursor = crHSplit
MinSize = 1 MinSize = 1
end end
object UpperLeftPageControl: TPageControl object UpperLeftPageControl: TPageControl
Left = 0 Left = 0
Top = 0 Top = 0
Width = 289 Width = 235
Height = 165 Height = 134
Align = alLeft Align = alLeft
DockSite = True DockSite = True
TabOrder = 0 TabOrder = 0
...@@ -13526,10 +13526,10 @@ object MainForm: TMainForm ...@@ -13526,10 +13526,10 @@ object MainForm: TMainForm
OnUnDock = PageControlUnDock OnUnDock = PageControlUnDock
end end
object UpperRightPageControl: TPageControl object UpperRightPageControl: TPageControl
Left = 292 Left = 237
Top = 0 Top = 0
Width = 340 Width = 395
Height = 165 Height = 134
Align = alClient Align = alClient
DockSite = True DockSite = True
TabOrder = 1 TabOrder = 1
...@@ -13539,26 +13539,26 @@ object MainForm: TMainForm ...@@ -13539,26 +13539,26 @@ object MainForm: TMainForm
end end
object BottomPanel: TPanel object BottomPanel: TPanel
Left = 0 Left = 0
Top = 196 Top = 165
Width = 632 Width = 632
Height = 121 Height = 162
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
TabOrder = 2 TabOrder = 2
Visible = False Visible = False
object BottomVerticalSplitter: TSplitter object BottomVerticalSplitter: TSplitter
Left = 289 Left = 235
Top = 0 Top = 0
Width = 3 Width = 2
Height = 121 Height = 162
Cursor = crHSplit Cursor = crHSplit
MinSize = 1 MinSize = 1
end end
object LowerLeftPageControl: TPageControl object LowerLeftPageControl: TPageControl
Left = 0 Left = 0
Top = 0 Top = 0
Width = 289 Width = 235
Height = 121 Height = 162
Align = alLeft Align = alLeft
DockSite = True DockSite = True
TabOrder = 0 TabOrder = 0
...@@ -13566,10 +13566,10 @@ object MainForm: TMainForm ...@@ -13566,10 +13566,10 @@ object MainForm: TMainForm
OnUnDock = PageControlUnDock OnUnDock = PageControlUnDock
end end
object LowerRightPageControl: TPageControl object LowerRightPageControl: TPageControl
Left = 292 Left = 237
Top = 0 Top = 0
Width = 340 Width = 395
Height = 121 Height = 162
Align = alClient Align = alClient
DockSite = True DockSite = True
TabOrder = 1 TabOrder = 1
...@@ -13579,7 +13579,7 @@ object MainForm: TMainForm ...@@ -13579,7 +13579,7 @@ object MainForm: TMainForm
end end
object StatusBar: TStatusBar object StatusBar: TStatusBar
Left = 0 Left = 0
Top = 317 Top = 327
Width = 632 Width = 632
Height = 25 Height = 25
Panels = < Panels = <
...@@ -16995,4 +16995,11 @@ object MainForm: TMainForm ...@@ -16995,4 +16995,11 @@ object MainForm: TMainForm
Left = 504 Left = 504
Top = 40 Top = 40
end end
object SemFileTimer: TTimer
Enabled = False
Interval = 5000
OnTimer = SemFileTimerTick
Left = 472
Top = 40
end
end end
...@@ -302,6 +302,7 @@ __published: // IDE-managed Components ...@@ -302,6 +302,7 @@ __published: // IDE-managed Components
TMenuItem *ConfigureWebTrayMenuItem; TMenuItem *ConfigureWebTrayMenuItem;
TMenuItem *ConfigureServicesTrayMenuItem; TMenuItem *ConfigureServicesTrayMenuItem;
TMenuItem *HelpTechnicalSupportMenuItem; TMenuItem *HelpTechnicalSupportMenuItem;
TTimer *SemFileTimer;
void __fastcall FileExitMenuItemClick(TObject *Sender); void __fastcall FileExitMenuItemClick(TObject *Sender);
void __fastcall ViewToolbarMenuItemClick(TObject *Sender); void __fastcall ViewToolbarMenuItemClick(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action); void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
...@@ -390,6 +391,7 @@ __published: // IDE-managed Components ...@@ -390,6 +391,7 @@ __published: // IDE-managed Components
void __fastcall WebRecycleExecute(TObject *Sender); void __fastcall WebRecycleExecute(TObject *Sender);
void __fastcall WebConfigureExecute(TObject *Sender); void __fastcall WebConfigureExecute(TObject *Sender);
void __fastcall ViewServicesExecute(TObject *Sender); void __fastcall ViewServicesExecute(TObject *Sender);
void __fastcall SemFileTimerTick(TObject *Sender);
private: // User declarations private: // User declarations
public: // User declarations public: // User declarations
__fastcall TMainForm(TComponent* Owner); __fastcall TMainForm(TComponent* Owner);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment