[Mono-devel-list] Patch against mod_mono to add certain features.

Daniel Lopez daniel at rawbyte.com
Tue Apr 22 16:26:39 EDT 2003


Hello everyone,

The problem here is that Apache is running as several processes, each one
serving its own requests.
I believe (unless I am not understanding how Mono works) that this does not
allows them to share the ASP.NET session data for example. So the options are:
- Have an external process and pass the information via remoting (what Pedro
is doing and similar to how Tomcat and mod_jk works) 
The only worry I have is the performance of back and forth remoting calls,
but I believe this is how current IIS <-> ASP.NET works on Windows
- Port mod_mono to Apache threaded MPM so there is only one Mono process that 
can be accessed by rest of Apache threads (it is currently segfaulting)

I have set aside some time this week to work on mod_mono and solve this and
other issues. Let me know if you ahve any suggestions or if you see a way of
transparently sharing state when running mono in a multi process web server.

Daniel


On Mon, Apr 21, 2003 at 04:02:32AM +0200, yoros at wanadoo.es wrote:
> 
> Hello,
> 
> I've attached a patch against mod_mono. This patch is not a bugfix and
> before patching mod_mono, it will not work. I only send this patch for
> the people that could think that have ASP.NET working in two layers, one
> attached to apache (mod_mono) and other running always as an external
> daemon (to control the cache and other features).
> 
> A few indications:
>    - You must run RemotingWebServer.exe before point your browser to any
>      mono managed pages. (does not mind if apache2 is running).
>    - When running RemotingWebServer.exe, you could see a lot of messages
>      informing that there are referenced methods that it can't find. It
>      doesn't mind because it sould never call that methods (they are
>      called in the other layer (Apache/mod_mono side).
>    - I get strange exceptions... You can see them in apache2 logs.
> 
> If anybody is interested in this features or has the solution of my
> troubles, please mail me.
> 
> Regards,
> 
>     Pedro
> 
> -- 
> Pedro Martínez Juliá
> \  yoros at terra.es
> )|    yoros at wanadoo.es
> /        http://yoros.cjb.net
> Socio HispaLinux #311
> Usuario Linux #275438 - http://counter.li.org
> GnuPG public information:  pub  1024D/74F1D3AC
> Key fingerprint = 8431 7B47 D2B4 5A46 5F8E  534F 588B E285 74F1 D3AC

> Index: ApacheApplicationHost.cs
> ===================================================================
> RCS file: /mono/mod_mono/src/ApacheApplicationHost.cs,v
> retrieving revision 1.2
> diff -u -p -r1.2 ApacheApplicationHost.cs
> --- ApacheApplicationHost.cs	25 Feb 2003 10:40:01 -0000	1.2
> +++ ApacheApplicationHost.cs	21 Apr 2003 01:48:57 -0000
> @@ -51,12 +51,18 @@
>  
>  using System;
>  using System.Web.Hosting;
> +
> +using System.Runtime.Remoting.Channels.Tcp;
> +using System.Runtime.Remoting.Channels;
> +using System.Runtime.Remoting;
> +
>  using Mono.ASPNET;
>  
>  namespace Apache.Web
>  {
>  	public class ApacheApplicationHost : MarshalByRefObject, IApplicationHost
>  	{
> +
>  		object IApplicationHost.CreateApplicationHost (string virtualPath, string baseDirectory)
>  		{
>  			return CreateApplicationHost (virtualPath, baseDirectory);
> @@ -69,8 +75,15 @@ namespace Apache.Web
>  
>  		/* Hack until fix for TP calls from C, that did not made it in Mono 0.20 */
>  		private void internalProcessRequest (IntPtr request) {
> -			ApacheWorkerRequest wr = new ApacheWorkerRequest (this, request);
> -			wr.ProcessRequest ();
> +			TcpChannel ch = new TcpChannel(0);
> +			ChannelServices.RegisterChannel(ch);
> +			RemotingWorkerRequest rwr = (RemotingWorkerRequest)
> +				Activator.GetObject(typeof(RemotingWorkerRequest),
> +				"tcp://localhost:4321/rwr.rem");
> +			Request r = new Request(request);
> +			ApacheWorkerRequest wr = rwr.GetApacheWorkerRequest(this, r);
> +			wr.ProcessRequest();
> +			ch.StopListening(null);
>  		}
>  
>  		public void ProcessRequest (IntPtr request)
> Index: ApacheWorkerRequest.cs
> ===================================================================
> RCS file: /mono/mod_mono/src/ApacheWorkerRequest.cs,v
> retrieving revision 1.9
> diff -u -p -r1.9 ApacheWorkerRequest.cs
> --- ApacheWorkerRequest.cs	11 Apr 2003 11:32:01 -0000	1.9
> +++ ApacheWorkerRequest.cs	21 Apr 2003 01:48:57 -0000
> @@ -71,10 +71,10 @@ namespace Apache.Web
>  		int remotePort;
>  		string path;
>  
> -		public ApacheWorkerRequest (IApplicationHost appHost, IntPtr request)
> +		public ApacheWorkerRequest (IApplicationHost appHost, Request request)
>  			: base (appHost)
>  		{
> -			this.request = new Request (request);
> +			this.request = request;
>  		}
>  
>  		protected override bool GetRequestData ()
> Index: Request.cs
> ===================================================================
> RCS file: /mono/mod_mono/src/Request.cs,v
> retrieving revision 1.5
> diff -u -p -r1.5 Request.cs
> --- Request.cs	11 Mar 2003 12:03:33 -0000	1.5
> +++ Request.cs	21 Apr 2003 01:48:58 -0000
> @@ -58,7 +58,7 @@ using Mono.ASPNET;
>  
>  namespace Apache.Web
>  {
> -	public class Request
> +	public class Request : MarshalByRefObject
>  	{
>  		IntPtr request;
>  		IntPtr connection;
> Index: makedll.mak
> ===================================================================
> RCS file: /mono/mod_mono/src/makedll.mak,v
> retrieving revision 1.1
> diff -u -p -r1.1 makedll.mak
> --- makedll.mak	30 Dec 2002 14:47:15 -0000	1.1
> +++ makedll.mak	21 Apr 2003 01:48:58 -0000
> @@ -2,20 +2,24 @@ CSC=mcs
>  CSCFLAGS+= /debug+ /debug:full /nologo
>  
>  # 
> -REFERENCES= System.Web
> +REFERENCES= System.Web System.Runtime.Remoting
>  REFS= $(addsuffix .dll, $(addprefix /r:, $(REFERENCES)))
>  SOURCES = ApacheApplicationHost.cs \
> +	  RemotingWorkerRequest.cs \
>  	  ApacheWorkerRequest.cs \
>  	  MonoWorkerRequest.cs \
>  	  IApplicationHost.cs \
>  	  Request.cs
>  
> -all: ModMono.dll
> +all: ModMono.dll RemotingWebServer.exe
>  
>  ModMono.dll: $(SOURCES)
>  	$(CSC) $(CSCFLAGS) $(REFS) /target:library /out:$@ $^
>  
> +RemotingWebServer.exe: ModMono.dll
> +	$(CSC) $(CSFLAGS) $(REFS) /r:ModMono.dll /target:exe /out:$@ RemotingWebServer.cs
> +
>  clean:
> -	rm -f ModMono.dll *~ *.pdb *.dbg
> +	rm -f ModMono.dll RemotingWebServer.exe *~ *.pdb *.dbg
>  
>  




More information about the Mono-devel-list mailing list