summaryrefslogtreecommitdiff
path: root/WinRPR.c
diff options
context:
space:
mode:
authorDave Hibberd <d@vehibberd.com>2023-12-08 12:26:52 +0000
committerDave Hibberd <d@vehibberd.com>2023-12-08 12:26:52 +0000
commit2ccd083256a3a05ae1f402a0ef259fbfff709088 (patch)
treebe574dcfe62344d0499d5ebb902b1cc9a3fd6cb3 /WinRPR.c
parent120df97dc7f30ce81623cc952ba2bd21b86f2425 (diff)
New upstream version 6.0.24.22upstream/6.0.24.22
Diffstat (limited to 'WinRPR.c')
-rw-r--r--WinRPR.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/WinRPR.c b/WinRPR.c
index 51c6983..03d81ac 100644
--- a/WinRPR.c
+++ b/WinRPR.c
@@ -106,6 +106,7 @@ int ConnecttoWinRPR(int port);
BOOL KillOldTNC(char * Path);
int KillTNC(struct TNCINFO * TNC);
+void CountRestarts(struct TNCINFO * TNC);
static BOOL RestartTNC(struct TNCINFO * TNC)
{
@@ -789,16 +790,15 @@ void * WinRPRExtInit(EXTPORTDATA * PortEntry)
return ExtProc;
}
+ if (TNC->AutoStartDelay == 0)
+ TNC->AutoStartDelay = 2000;
+
sprintf(msg,"WinRPR Host %s %d", TNC->HostName, htons(TNC->destaddr.sin_port));
WritetoConsoleLocal(msg);
TNC->Port = port;
TNC->Hardware = H_WINRPR;
- if (TNC->ProgramPath)
- TNC->WeStartedTNC = RestartTNC(TNC);
-
-
// Set up DED addresses for streams
for (Stream = 0; Stream <= MaxStreams; Stream++)
@@ -887,6 +887,9 @@ void * WinRPRExtInit(EXTPORTDATA * PortEntry)
TNC->WEB_MODE = zalloc(20);
TNC->WEB_BUFFERS = zalloc(100);
TNC->WEB_TRAFFIC = zalloc(100);
+ TNC->WEB_RESTARTTIME = zalloc(100);
+ TNC->WEB_RESTARTS = zalloc(100);
+
#ifndef LINBPQ
@@ -1451,14 +1454,9 @@ VOID WinRPRThread(void * portptr)
// can only check if running on local host
TNC->PID = GetListeningPortsPID(TNC->destaddr.sin_port);
+
if (TNC->PID == 0)
- {
- TNC->CONNECTING = FALSE;
- sprintf(TNC->WEB_COMMSSTATE, "Waiting for TNC");
- MySetWindowText(TNC->xIDC_COMMSSTATE, TNC->WEB_COMMSSTATE);
-
- return; // Not listening so no point trying to connect
- }
+ goto TNCNotRunning;
// Get the File Name in case we want to restart it.
@@ -1480,17 +1478,25 @@ VOID WinRPRThread(void * portptr)
}
}
}
+ goto TNCRunning;
}
#endif
-// // If we started the TNC make sure it is still running.
+TNCNotRunning:
+
+ // Not running or can't check, restart if we have a path
+
+ if (TNC->ProgramPath)
+ {
+ Consoleprintf("Trying to (re)start TNC %s", TNC->ProgramPath);
-// if (!IsProcess(TNC->PID))
-// {
-// RestartTNC(TNC);
-// Sleep(3000);
-// }
+ if (RestartTNC(TNC))
+ CountRestarts(TNC);
+
+ Sleep(TNC->AutoStartDelay);
+ }
+TNCRunning:
TNC->destaddr.sin_addr.s_addr = inet_addr(TNC->HostName);
TNC->Datadestaddr.sin_addr.s_addr = inet_addr(TNC->HostName);