Fix deamon restart bugs.
This commit is contained in:
parent
123dd0541d
commit
08f652522a
@ -4,9 +4,8 @@
|
|||||||
<images-root-path>..</images-root-path>
|
<images-root-path>..</images-root-path>
|
||||||
</configuration>
|
</configuration>
|
||||||
<import>
|
<import>
|
||||||
<widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
|
|
||||||
<widget-library name="../net-libs/appindicator3-sharp.dll" />
|
<widget-library name="../net-libs/appindicator3-sharp.dll" />
|
||||||
<widget-library name="../bin/Release/MelonVPNClient.exe" internal="true" />
|
<widget-library name="../bin/Debug/MelonVPNClient.exe" internal="true" />
|
||||||
</import>
|
</import>
|
||||||
<widget class="Gtk.Window" id="MainWindow" design-size="204 86">
|
<widget class="Gtk.Window" id="MainWindow" design-size="204 86">
|
||||||
<property name="MemberName" />
|
<property name="MemberName" />
|
||||||
|
@ -44,7 +44,7 @@ namespace MelonVPNCore
|
|||||||
if (data.IndexOf(Messages.EOF, StringComparison.CurrentCulture) > -1) break;
|
if (data.IndexOf(Messages.EOF, StringComparison.CurrentCulture) > -1) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.StartsWith(Messages.ClientListStartMsg, StringComparison.CurrentCulture))
|
if (data.StartsWith(Messages.ClientListStartMsg, StringComparison.CurrentCulture) && shouldBeRunning)
|
||||||
{
|
{
|
||||||
lastClientUpdate = data;
|
lastClientUpdate = data;
|
||||||
Client.SendCustomMessage(lastClientUpdate, true);
|
Client.SendCustomMessage(lastClientUpdate, true);
|
||||||
@ -91,6 +91,13 @@ namespace MelonVPNCore
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Sending online reply");
|
Console.WriteLine("Sending online reply");
|
||||||
Client.SendDataMessage(DataMessage.Online, true);
|
Client.SendDataMessage(DataMessage.Online, true);
|
||||||
|
currentVpnProcess.EnableRaisingEvents = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shouldBeRunning = false;
|
||||||
|
Client.SendDataMessage(DataMessage.Offline, true);
|
||||||
|
Client.SendCustomMessage(Messages.ClientListEmptyMsg, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -178,12 +185,12 @@ namespace MelonVPNCore
|
|||||||
|
|
||||||
static void CurrentVpnProcess_Exited(object sender, EventArgs e)
|
static void CurrentVpnProcess_Exited(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Client.SendDataMessage(DataMessage.Restarting, true);
|
|
||||||
Console.WriteLine("Restarting embedded process");
|
Console.WriteLine("Restarting embedded process");
|
||||||
currentVpnProcess.Dispose();
|
currentVpnProcess.Dispose();
|
||||||
currentVpnProcess = null;
|
currentVpnProcess = null;
|
||||||
Thread.Sleep(restartDelay);
|
Thread.Sleep(restartDelay);
|
||||||
if (shouldRestart)
|
bool imonline = false;
|
||||||
|
while (shouldRestart && shouldBeRunning)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Sending restarting reply");
|
Console.WriteLine("Sending restarting reply");
|
||||||
Client.SendDataMessage(DataMessage.Restarting, true);
|
Client.SendDataMessage(DataMessage.Restarting, true);
|
||||||
@ -191,10 +198,21 @@ namespace MelonVPNCore
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Sending online reply");
|
Console.WriteLine("Sending online reply");
|
||||||
Client.SendDataMessage(DataMessage.Online, true);
|
Client.SendDataMessage(DataMessage.Online, true);
|
||||||
}
|
currentVpnProcess.EnableRaisingEvents = true;
|
||||||
|
imonline = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
currentVpnProcess.Dispose();
|
||||||
|
currentVpnProcess = null;
|
||||||
|
Thread.Sleep(restartDelay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! imonline)
|
||||||
|
{
|
||||||
|
shouldBeRunning = false;
|
||||||
|
Console.WriteLine("Sending offline reply");
|
||||||
Client.SendDataMessage(DataMessage.Offline, true);
|
Client.SendDataMessage(DataMessage.Offline, true);
|
||||||
Client.SendCustomMessage(Messages.ClientListEmptyMsg, true);
|
Client.SendCustomMessage(Messages.ClientListEmptyMsg, true);
|
||||||
}
|
}
|
||||||
@ -209,7 +227,7 @@ namespace MelonVPNCore
|
|||||||
currentVpnProcess = new Process
|
currentVpnProcess = new Process
|
||||||
{
|
{
|
||||||
StartInfo = new ProcessStartInfo("simple-vpn", "client /etc/melon-vpn/client.cfg"),
|
StartInfo = new ProcessStartInfo("simple-vpn", "client /etc/melon-vpn/client.cfg"),
|
||||||
EnableRaisingEvents = true
|
EnableRaisingEvents = false
|
||||||
};
|
};
|
||||||
currentVpnProcess.Exited += CurrentVpnProcess_Exited;
|
currentVpnProcess.Exited += CurrentVpnProcess_Exited;
|
||||||
currentVpnProcess.Start();
|
currentVpnProcess.Start();
|
||||||
|
Loading…
Reference in New Issue
Block a user