2005-02-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>

* server/ModMonoApplicationHost.cs:
	* server/ModMonoTCPWebSource.cs:
	* server/server.cs: use a FileStream as a lock to prevent running
	more than one mod-mono-server with the same arguments.


svn path=/trunk/xsp/; revision=40919
This commit is contained in:
Gonzalo Paniagua Javier 2005-02-20 08:14:43 +00:00
Родитель 900270a33e
Коммит 3619ac6e7a
4 изменённых файлов: 41 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,10 @@
2005-02-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* server/ModMonoApplicationHost.cs:
* server/ModMonoTCPWebSource.cs:
* server/server.cs: use a FileStream as a lock to prevent running
more than one mod-mono-server with the same arguments.
2005-02-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* server/ModMonoWorkerRequest.cs: override IsSecure and implement it.

Просмотреть файл

@ -43,10 +43,22 @@ namespace Mono.ASPNET
{
string filename;
bool file_bound;
Stream locker;
string lockfile;
protected ModMonoWebSource () {}
protected ModMonoWebSource (string lockfile)
{
this.lockfile = lockfile;
try {
locker = File.OpenWrite (lockfile);
} catch {
Console.Error.WriteLine ("Another mod-mono-server with the same arguments is already running.");
Environment.Exit (1);
}
}
public ModMonoWebSource (string filename)
public ModMonoWebSource (string filename, string lockfile)
: this (lockfile)
{
if (filename == null)
throw new ArgumentNullException ("filename");
@ -132,6 +144,11 @@ namespace Mono.ASPNET
filename = null;
if (file_bound)
File.Delete (f);
if (locker != null) {
locker.Close ();
File.Delete (lockfile);
}
}
}

Просмотреть файл

@ -37,7 +37,8 @@ namespace Mono.ASPNET
{
IPEndPoint bindAddress;
public ModMonoTCPWebSource (IPAddress address, int port)
public ModMonoTCPWebSource (IPAddress address, int port, string lockfile)
: base (lockfile)
{
if (address == IPAddress.Any)
address = IPAddress.Loopback;

Просмотреть файл

@ -195,8 +195,10 @@ namespace Mono.ASPNET
oport = 8080;
Options options = 0;
int hash = 0;
for (int i = 0; i < args.Length; i++){
string a = args [i];
hash ^= args [i].GetHashCode () + i;
switch (a){
#if MODMONO_SERVER
@ -252,6 +254,10 @@ namespace Mono.ASPNET
}
#if MODMONO_SERVER
if (hash < 0)
hash = -hash;
string lockfile;
bool useTCP = ((options & Options.Port) != 0);
if (!useTCP) {
if (filename == null || filename == "")
@ -263,6 +269,11 @@ namespace Mono.ASPNET
Console.WriteLine ("ERROR: --address without --port");
Environment.Exit (1);
}
lockfile = Path.Combine (Path.GetTempPath (), filename);
lockfile = String.Format ("{0}_{1}", lockfile, hash);
} else {
lockfile = Path.Combine (Path.GetTempPath (), "mod_mono_TCP_");
lockfile = String.Format ("{0}_{1}", lockfile, hash);
}
#endif
IPAddress ipaddr = null;
@ -295,9 +306,9 @@ namespace Mono.ASPNET
IWebSource webSource;
#if MODMONO_SERVER
if (useTCP) {
webSource = new ModMonoTCPWebSource (ipaddr, port);
webSource = new ModMonoTCPWebSource (ipaddr, port, lockfile);
} else {
webSource = new ModMonoWebSource (filename);
webSource = new ModMonoWebSource (filename, lockfile);
}
if ((options & Options.Terminate) != 0) {