From arun at eagle-india.com Wed Dec 2 02:14:36 2009 From: arun at eagle-india.com (A. M. ArunKumar) Date: Wed, 2 Dec 2009 12:44:36 +0530 Subject: [FASTCGI] FastCGI with Oracle Message-ID: <20091202071610.9797A5821@smtp.chelsea.net> Hi, I am new to this FastCGI. I have an issue in connecting to Oracle database through fast CGI using my C++ program. I get the error as "Cannot Create OCI Environment" The same program works fine without fast CGI. The issue happens to be only in FastCGI. I defined the following SetEnvs to work in cgi-bin SetEnv ORACLE_BASE "/app/oracle" SetEnv ORACLE_HOME "/app/oracle/product/10.2.0/db_1" SetEnv ORACLE_SID "DEVPORC1" SetEnv OCILIB_INC "/usr/local/include" SetEnv OCILIB_LIB "/usr/local/lib" SetEnv LD_LIBRARY_PATH "/app/oracle/product/10.2.0/db_1" If I do the same thing for fcgi-bin its not working. Thanks Arun -------------- next part -------------- An HTML attachment was scrubbed... URL: From rclemley at booksys.com Wed Dec 2 10:22:29 2009 From: rclemley at booksys.com (Rob Lemley) Date: Wed, 02 Dec 2009 09:22:29 -0600 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <20091202071610.9797A5821@smtp.chelsea.net> References: <20091202071610.9797A5821@smtp.chelsea.net> Message-ID: <4B168635.4090800@booksys.com> A. M. ArunKumar wrote: > I am new to this FastCGI. I have an issue in connecting to Oracle > database through fast CGI using my C++ program. I get the error as > ?Cannot Create OCI Environment? The same program works fine without > fast CGI. The issue happens to be only in FastCGI. I don't know anything about connecting to Oracle and your description is a little sketchy. My best guess is that your C++ program is not getting the correct environment variables. If that's your problem and you're running internal FastCgiServer (as opposed to FastCgiExternalServer), you need to pass the environment variables like this: FastCgiServer yourapp \ -initial-env ORACLE_BASE=app/oracle \ -initial-env ORACLE_SID=DEVPORC1 \ -initial-env yadayadayada=etcetera > > > I defined the following SetEnvs to work in cgi-bin > > > > > > SetEnv > > SetEnv ORACLE_HOME "/app/oracle/product/10.2.0/db_1" > > SetEnv ORACLE_SID "DEVPORC1" > > SetEnv OCILIB_INC "/usr/local/include" > > SetEnv OCILIB_LIB "/usr/local/lib" > > SetEnv LD_LIBRARY_PATH "/app/oracle/product/10.2.0/db_1" > > > > > > > > If I do the same thing for fcgi-bin its not working. > From t0m at state51.co.uk Wed Dec 2 14:42:56 2009 From: t0m at state51.co.uk (Tomas Doran) Date: Wed, 2 Dec 2009 19:42:56 +0000 Subject: [FASTCGI] FILENO IO:: interface patch to the FCGI CPAN module. (Was: Re: The FCGI module) In-Reply-To: <20091129203838.GE7872@kotnet.org> References: <20091031120356.GT451@agaton.scsys.co.uk> <20091031122041.GV15045@kotnet.org> <20091031155437.GU451@agaton.scsys.co.uk> <027A781D-D519-4DFA-ABFE-9811E028995B@bobtfish.net> <20091128211327.GX7872@kotnet.org> <0604107D-9087-4F32-8517-70E112DFCE81@bobtfish.net> <20091129141829.GZ7872@kotnet.org> <4B129783.4000100@bobtfish.net> <20091129162852.GD7872@kotnet.org> <4B12A669.1030402@bobtfish.net> <20091129203838.GE7872@kotnet.org> Message-ID: <18A46659-9D75-4FB4-B5A7-63EB865958B6@state51.co.uk> On 29 Nov 2009, at 20:38, Sven Verdoolaege wrote: > On Sun, Nov 29, 2009 at 04:50:49PM +0000, Tomas Doran wrote: >> Sven Verdoolaege wrote: >>> Also, would you like me to collect your patches or do you >>> plan on taking over eventually? > > Let's just stick to you sending me patches for now (CC'd to the list). > I'll release a new version of FCGI before the end of the year. Please find attached a patch to add a FILENO method to FCGI.pm, as discussed. If you would prefer to view a diff in your browser, please see: http://goatse.co.uk/~bobtfish/Gitalist/script/gitalist.fcgi/commitdiff?p=fcgi2.git;h=bc584fde07f64d87f33ec75b92bf342c3649c094 or if you'd like to pull from my repository: http://goatse.co.uk/~bobtfish/fcgi2.git/ This fixes a longstanding issue (http://rt.cpan.org/Public/Bug/Display.html?id=50972 ), and removes the need for vendor patches applied by (at least) debian and OpenBSD. Cheers t0m -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Add-FILENO-method-to-FCGI.pm-to-comply-with-IO-inter.patch Type: application/octet-stream Size: 2049 bytes Desc: not available URL: -------------- next part -------------- P.S. I am unsure if this message will make it to the FCGI developers list - I tried to subscribe from both my work and home addresses, but I only got a confirm to work (this address), and I am unable to log into the mailman web interface with the password in my 'welcome to the "FCGI-developers" mailing list email to check as it says the password is incorrect. The 'email me my password' button also does not appear to function as expected. P.P.S. I emailed both addresses I could find for the list admin about this issue several days ago and have received no response. From skimo-fastcgi at kotnet.org Thu Dec 3 15:08:04 2009 From: skimo-fastcgi at kotnet.org (Sven Verdoolaege) Date: Thu, 3 Dec 2009 21:08:04 +0100 Subject: [FASTCGI] new maintainer for the perl FCGI module Message-ID: <20091203200803.GS7872@kotnet.org> Those of you who have been around here for a while may remember me as the maintainer of the perl FCGI module, but I haven't been able to devote enough time to the module for the last couple of years. brian d foy has kindly accepted to take over maintenance. I'm sure he'll do a much better job than I have been doing lately. skimo From skimo-fastcgi at kotnet.org Thu Dec 3 15:55:33 2009 From: skimo-fastcgi at kotnet.org (Sven Verdoolaege) Date: Thu, 3 Dec 2009 21:55:33 +0100 Subject: [FASTCGI] FILENO IO:: interface patch to the FCGI CPAN module. (Was: Re: The FCGI module) In-Reply-To: <18A46659-9D75-4FB4-B5A7-63EB865958B6@state51.co.uk> References: <20091031155437.GU451@agaton.scsys.co.uk> <027A781D-D519-4DFA-ABFE-9811E028995B@bobtfish.net> <20091128211327.GX7872@kotnet.org> <0604107D-9087-4F32-8517-70E112DFCE81@bobtfish.net> <20091129141829.GZ7872@kotnet.org> <4B129783.4000100@bobtfish.net> <20091129162852.GD7872@kotnet.org> <4B12A669.1030402@bobtfish.net> <20091129203838.GE7872@kotnet.org> <18A46659-9D75-4FB4-B5A7-63EB865958B6@state51.co.uk> Message-ID: <20091203205533.GU7872@kotnet.org> On Wed, Dec 02, 2009 at 07:42:56PM +0000, Tomas Doran wrote: > If you would prefer to view a diff in your browser, please see: > http://goatse.co.uk/~bobtfish/Gitalist/script/gitalist.fcgi/commitdiff?p=fcgi2.git;h=bc584fde07f64d87f33ec75b92bf342c3649c094 It would be more convenient if you could actually inline the patch so that people could comment on it by simply replying. Of course, brian may feel differently. In any case, I think the actual code change and the commit message are ok. The reason I never enabled this method is that whenever someone thought they needed it, it turned out that they actually didn't. I guess you found a case where you do really need it. I would still prefer it if you could keep the indentation in ChangeLog consistent, but it's not my call anymore. skimo From arun at eagle-india.com Fri Dec 4 06:07:07 2009 From: arun at eagle-india.com (A. M. ArunKumar) Date: Fri, 4 Dec 2009 16:37:07 +0530 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <4B168635.4090800@booksys.com> Message-ID: <20091204110840.162187A88@smtp.chelsea.net> Thank you Rob Lemley, I was not able to work on this issue yesterday. Today I was able to resolve it. The solution which you gave me was not helping, but there was another gentleman who helped me out there. Looks like Fast CGI is clearing the environmental variables, we need to set it back in the C++ program. I used the setenv function in c++ and now its connecting to oracle. Thanks for the timely reply. Arun -----Original Message----- From: Rob Lemley [mailto:rclemley at booksys.com] Sent: Wednesday, December 02, 2009 8:52 PM To: A. M. ArunKumar Cc: fastcgi-developers at mailman.pins.net Subject: Re: [FASTCGI] FastCGI with Oracle A. M. ArunKumar wrote: > I am new to this FastCGI. I have an issue in connecting to Oracle > database through fast CGI using my C++ program. I get the error as > "Cannot Create OCI Environment" The same program works fine without > fast CGI. The issue happens to be only in FastCGI. I don't know anything about connecting to Oracle and your description is a little sketchy. My best guess is that your C++ program is not getting the correct environment variables. If that's your problem and you're running internal FastCgiServer (as opposed to FastCgiExternalServer), you need to pass the environment variables like this: FastCgiServer yourapp \ -initial-env ORACLE_BASE=app/oracle \ -initial-env ORACLE_SID=DEVPORC1 \ -initial-env yadayadayada=etcetera > > > I defined the following SetEnvs to work in cgi-bin > > > > > > SetEnv > > SetEnv ORACLE_HOME "/app/oracle/product/10.2.0/db_1" > > SetEnv ORACLE_SID "DEVPORC1" > > SetEnv OCILIB_INC "/usr/local/include" > > SetEnv OCILIB_LIB "/usr/local/lib" > > SetEnv LD_LIBRARY_PATH "/app/oracle/product/10.2.0/db_1" > > > > > > > > If I do the same thing for fcgi-bin its not working. > From arun at eagle-india.com Fri Dec 4 06:12:33 2009 From: arun at eagle-india.com (A. M. ArunKumar) Date: Fri, 4 Dec 2009 16:42:33 +0530 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <6bc6070912021806t30437f0bx265df7b774578749@mail.gmail.com> Message-ID: <20091204111358.AB63E814C@smtp.chelsea.net> Thank you libo (I am not sure about the name, since it shows in chinese language) The solution which you gave has helped me. But its not after accept its before that. we need to set it back in the C++ program. I used the setenv function in c++ and now its connecting to oracle. Thanks for the timely reply. Arun _____ From: ?? [mailto:libo.868 at gmail.com] Sent: Thursday, December 03, 2009 7:37 AM To: A. M. ArunKumar Subject: Re: [FASTCGI] FastCGI with Oracle ha ha , i know the answer, ^_^ you should set oracle env at c++ source code after Accept() .because all env will be cleared after Accept() 2009/12/2 A. M. ArunKumar Hi, I am new to this FastCGI. I have an issue in connecting to Oracle database through fast CGI using my C++ program. I get the error as ?Cannot Create OCI Environment? The same program works fine without fast CGI. The issue happens to be only in FastCGI. I defined the following SetEnvs to work in cgi-bin SetEnv ORACLE_BASE "/app/oracle" SetEnv ORACLE_HOME "/app/oracle/product/10.2.0/db_1" SetEnv ORACLE_SID "DEVPORC1" SetEnv OCILIB_INC "/usr/local/include" SetEnv OCILIB_LIB "/usr/local/lib" SetEnv LD_LIBRARY_PATH "/app/oracle/product/10.2.0/db_1" If I do the same thing for fcgi-bin its not working. Thanks Arun _______________________________________________ FastCGI-developers mailing list FastCGI-developers at mailman.fastcgi.com http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists.drrngrvy at gmail.com Fri Dec 4 08:17:41 2009 From: lists.drrngrvy at gmail.com (Darren Garvey) Date: Fri, 4 Dec 2009 13:17:41 +0000 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <20091204111358.AB63E814C@smtp.chelsea.net> References: <6bc6070912021806t30437f0bx265df7b774578749@mail.gmail.com> <20091204111358.AB63E814C@smtp.chelsea.net> Message-ID: <4509b54b0912040517s3b1fb3celbda0f47bc1c00a83@mail.gmail.com> Hi, 2009/12/4 A. M. ArunKumar > Thank you libo (I am not sure about the name, since it shows in chinese > language) > > > > The solution which you gave has helped me. But its not after accept its > before that. we need to set it back in the C++ program. I used the setenv > function in c++ and now its connecting to oracle. > Is this how it is supposed to happen? I don't see why the FastCGI library should clear environment variables for the whole application... Regards, Darren -------------- next part -------------- An HTML attachment was scrubbed... URL: From arun at eagle-india.com Sun Dec 6 22:59:03 2009 From: arun at eagle-india.com (A. M. ArunKumar) Date: Mon, 7 Dec 2009 09:29:03 +0530 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <4509b54b0912040517s3b1fb3celbda0f47bc1c00a83@mail.gmail.com> Message-ID: <20091207040032.34D424657@smtp.chelsea.net> That what I was also thinking. Why should FastCGI clear environment variables. Is there any reason to clear the environment variables? Thanks Arun _____ From: darren.garvey at gmail.com [mailto:darren.garvey at gmail.com] On Behalf Of Darren Garvey Sent: Friday, December 04, 2009 6:48 PM To: A. M. ArunKumar Cc: ??; fastcgi-developers at mailman.pins.net Subject: Re: [FASTCGI] FastCGI with Oracle Hi, 2009/12/4 A. M. ArunKumar Thank you libo (I am not sure about the name, since it shows in chinese language) The solution which you gave has helped me. But its not after accept its before that. we need to set it back in the C++ program. I used the setenv function in c++ and now its connecting to oracle. Is this how it is supposed to happen? I don't see why the FastCGI library should clear environment variables for the whole application... Regards, Darren -------------- next part -------------- An HTML attachment was scrubbed... URL: From charles_thomas at mac.com Mon Dec 7 08:24:22 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Mon, 07 Dec 2009 07:24:22 -0600 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <20091207040032.34D424657@smtp.chelsea.net> References: <20091207040032.34D424657@smtp.chelsea.net> Message-ID: <8F79AD03-1A7A-4FE2-B8AD-433D11FBB95B@mac.com> From what I understand you have to specifically set any environment variables that you want to use in the configuration (I use apache and mod_fcgid ). The way I look at -- it is like the taint mode in Perl on steroids. perl -T (or perl -w ?) will generate a warning/error if you use relative paths or there are any environment variables that are considered security risks in your code. FastCgi handles it by not letting you set ANY variables... because that would be a security risk. There is an example in the API that covers how to set up a connection for Oracle. In my particular applications I have to use PGUSER and PGDATABASE. Tom On Dec 6, 2009, at 9:59 PM, A. M. ArunKumar wrote: > That what I was also thinking. Why should FastCGI clear > environment variables. Is there any reason to clear the > environment variables? > > > > Thanks > > Arun > > From: darren.garvey at gmail.com [mailto:darren.garvey at gmail.com] On > Behalf Of Darren Garvey > Sent: Friday, December 04, 2009 6:48 PM > To: A. M. ArunKumar > Cc: ??; fastcgi-developers at mailman.pins.net > Subject: Re: [FASTCGI] FastCGI with Oracle > > > > Hi, > > 2009/12/4 A. M. ArunKumar > > Thank you libo (I am not sure about the name, since it shows in > chinese language) > > > > The solution which you gave has helped me. But its not after > accept its before that. we need to set it back in the C++ program. > I used the setenv function in c++ and now its connecting to oracle. > > > Is this how it is supposed to happen? I don't see why the FastCGI > library should clear environment variables for the whole > application... > > Regards, > Darren > > _______________________________________________ > FastCGI-developers mailing list > FastCGI-developers at mailman.fastcgi.com > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers -------------- next part -------------- An HTML attachment was scrubbed... URL: From rclemley at booksys.com Mon Dec 7 12:47:39 2009 From: rclemley at booksys.com (Rob Lemley) Date: Mon, 07 Dec 2009 11:47:39 -0600 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <4509b54b0912040517s3b1fb3celbda0f47bc1c00a83@mail.gmail.com> References: <6bc6070912021806t30437f0bx265df7b774578749@mail.gmail.com> <20091204111358.AB63E814C@smtp.chelsea.net> <4509b54b0912040517s3b1fb3celbda0f47bc1c00a83@mail.gmail.com> Message-ID: <4B1D3FBB.6080105@booksys.com> Darren Garvey wrote: > 2009/12/4 A. M. ArunKumar > > > The solution which you gave has helped me. But its not after > accept its before that. we need to set it back in the C++ > program. I used the setenv function in c++ and now its connecting > to oracle. > > Is this how it is supposed to happen? I don't see why the FastCGI > library should clear environment variables for the whole application... We really can't tell what is happening because we need to know more about how A.M. ArunKumar is starting the fastcgi server app. I think he's using the apache mod_fastcgi but we don't know if it's external FastCGI, internal FastCGI, or FastCGI started through the apache ExecCGI system. I know from experience that the mod_fastcgi FastCgiServer directive (ie "internal" fastcgi server) with the "-initial-env name=[value]" option passes the values into the specified application which is started by the mod_fastcgi process manager. So from that, I assume that ArunKumar is NOT running an "internal" fastcgi server via the FastCgiServer directive. ArunKumar, can you give us more details about how you're initializing/executing/starting your FastCGI server C++ app? If you're running it as a "FastCgiExternalServer" and starting via some other means (such as init scripts, daemontools, or the windows service manager), then it's true, the environment variables will not be passed through the FastCGI connection to the external fastcgi server app. The only thing I know of like this is the FastCgiExternalServer "-pass-header" option, which I'm thinking would pass the headers only upon receipt of a request from the client. I haven't worked with the apache "SetHandler" and "AddHandler" directives to know how environment variables work with those. Rob -------------- next part -------------- An HTML attachment was scrubbed... URL: From charles_thomas at mac.com Mon Dec 7 13:24:33 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Mon, 07 Dec 2009 12:24:33 -0600 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <4B1D3FBB.6080105@booksys.com> References: <6bc6070912021806t30437f0bx265df7b774578749@mail.gmail.com> <20091204111358.AB63E814C@smtp.chelsea.net> <4509b54b0912040517s3b1fb3celbda0f47bc1c00a83@mail.gmail.com> <4B1D3FBB.6080105@booksys.com> Message-ID: <2B0FDE78-2974-43F4-9616-C19955981A28@mac.com> I am trying to remember where I read this in the fastcgi/fastcgx documentation -- but somewhere they recommend not using setenv within the accept loop. Perhaps each iteration of FCGII_Accept/FCGIX_Accept it clears and resets? It's a real security risk (IMHO).... an old hacker trick is to modify the path (for example) to point to your own version of a sh (sushi, etc). I've only used mod_fcgid -- with AddHandler -- and its (still) confusing me. Tom On Dec 7, 2009, at 11:47 AM, Rob Lemley wrote: > Darren Garvey wrote: >> 2009/12/4 A. M. ArunKumar >> The solution which you gave has helped me. But its not after >> accept its before that. we need to set it back in the C++ >> program. I used the setenv function in c++ and now its connecting >> to oracle. >> Is this how it is supposed to happen? I don't see why the FastCGI >> library should clear environment variables for the whole >> application... > > We really can't tell what is happening because we need to know more > about how A.M. ArunKumar is starting the fastcgi server app. I > think he's using the apache mod_fastcgi but we don't know if it's > external FastCGI, internal FastCGI, or FastCGI started through the > apache ExecCGI system. > > I know from experience that the mod_fastcgi FastCgiServer directive > (ie "internal" fastcgi server) with the "-initial-env name=[value]" > option passes the values into the specified application which is > started by the mod_fastcgi process manager. > > So from that, I assume that ArunKumar is NOT running an "internal" > fastcgi server via the FastCgiServer directive. > > ArunKumar, can you give us more details about how you're > initializing/executing/starting your FastCGI server C++ app? > > If you're running it as a "FastCgiExternalServer" and starting via > some other means (such as init scripts, daemontools, or the windows > service manager), then it's true, the environment variables will > not be passed through the FastCGI connection to the external > fastcgi server app. The only thing I know of like this is the > FastCgiExternalServer "-pass-header" option, which I'm thinking > would pass the headers only upon receipt of a request from the client. > > I haven't worked with the apache "SetHandler" and "AddHandler" > directives to know how environment variables work with those. > > Rob > > _______________________________________________ > FastCGI-developers mailing list > FastCGI-developers at mailman.fastcgi.com > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers -------------- next part -------------- An HTML attachment was scrubbed... URL: From charles_thomas at mac.com Mon Dec 7 13:30:51 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Mon, 07 Dec 2009 12:30:51 -0600 Subject: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? Message-ID: Is the difference between these modules just a matter of version? I am using Apache 2.2+ server -- and it uses mod_fcgid... from what i can tell the big difference is that the configuration keywords are difference ( FcgidAuthenticator, FcgidAuthorizer, FcgidAccessChecker, FcgidWrapper, etc.). tom From jlrobins at socialserve.com Mon Dec 7 13:59:54 2009 From: jlrobins at socialserve.com (James Robinson) Date: Mon, 7 Dec 2009 13:59:54 -0500 Subject: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? In-Reply-To: References: Message-ID: On Dec 7, 2009, at 1:30 PM, Tom Bowden wrote: > Is the difference between these modules just a matter of version? I > am using Apache 2.2+ server -- and it uses mod_fcgid... from what i > can tell the big difference is that the configuration keywords are > difference ( FcgidAuthenticator, FcgidAuthorizer, > FcgidAccessChecker, FcgidWrapper, etc.). > > tom If this is the adoption of the fcigd I'm thinking of, then, internal differences will be: * no remote-server fastcgi support. * 1 to 1 relationship between fascgi process and local domain socket for apache -> fastcgi communication, implying that mod_fcgid knows which exact factcgi process took too long [ 'FcgidBusyTimeout' at http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html ], so that it can then kill off that exact (runaway) process. mod_fastcgi uses a 'one socket, many listening fastcgis all blocking on accept()' model, so that it can't know which exact backend process was used to field a runaway request. ---- James Robinson Socialserve.com From rclemley at booksys.com Mon Dec 7 14:04:09 2009 From: rclemley at booksys.com (Rob Lemley) Date: Mon, 07 Dec 2009 13:04:09 -0600 Subject: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? In-Reply-To: References: Message-ID: <4B1D51A9.3030002@booksys.com> Tom Bowden wrote: > Is the difference between these modules just a matter of version? I > am using Apache 2.2+ server -- and it uses mod_fcgid... from what i > can tell the big difference is that the configuration keywords are > difference ( FcgidAuthenticator, FcgidAuthorizer, FcgidAccessChecker, > FcgidWrapper, etc.). mod_fcgid is a different project. I've never used mod_fcgid. It appears useful in situations where many processes are somehow started and you want the fcgid process manager to kill them when not needed. We have one multi-threaded FastCgiExternalServer process per apache2 virtual host. These servers never exit. Therefore, I never saw the advantage to the mod_fcgid "process management strategy, which concentrates on reducing the number of fastcgi server, and kick out the corrupt fastcgi server as soon as possible". I'm not sure, but I guess if you had a single threaded fcgi server and wanted to have the number of instances of it (processes) to grow and shrink dynamically, then maybe that's the purpose of mod_fcgid. In our case, we can accept fastcgi requests about as fast as apache sends them, because our accept loop immediately spawns a new thread to handle the request and goes back to get the next request. One user has reported much slower response times for mod_fcgid. The fastcgi server library code is somewhat "scary", global variables, unclearly documented return codes, etc. But it seems to work well for what we're doing. We've had problems with mod_fastcgi versions on windows. I think we haven't been able to go above a certain version (2.8?) with the most recent version of apache 2. Rob From charles_thomas at mac.com Mon Dec 7 14:13:56 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Mon, 07 Dec 2009 13:13:56 -0600 Subject: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? In-Reply-To: <4B1D51A9.3030002@booksys.com> References: <4B1D51A9.3030002@booksys.com> Message-ID: <12140AEB-9CF0-433C-8BBB-98FC512207B5@mac.com> I just got through uninstalling mod_fcgid, and building mod_fastcgi to use. I really think that is better suited for my needs than mod_fcgid (I agree with what you said below and what James Robinson talked about. What I really need/like about what fastcgi offers is only (truly) supported by mod_fastcgi. mod_fcgid seems to be a separate project (as James mentioned)... its part of apache.org as well - which is why I liked initially.. when in Rome... Thanks for all the help! Tom On Dec 7, 2009, at 1:04 PM, Rob Lemley wrote: > Tom Bowden wrote: >> Is the difference between these modules just a matter of version? I >> am using Apache 2.2+ server -- and it uses mod_fcgid... from what i >> can tell the big difference is that the configuration keywords are >> difference ( FcgidAuthenticator, FcgidAuthorizer, FcgidAccessChecker, >> FcgidWrapper, etc.). > > mod_fcgid is a different project. I've never used mod_fcgid. It > appears useful in situations where many processes are somehow started > and you want the fcgid process manager to kill them when not needed. > > We have one multi-threaded FastCgiExternalServer process per apache2 > virtual host. These servers never exit. Therefore, I never saw the > advantage to the mod_fcgid "process management strategy, which > concentrates on reducing the number of fastcgi server, and kick out > the > corrupt fastcgi server as soon as possible". > > I'm not sure, but I guess if you had a single threaded fcgi server and > wanted to have the number of instances of it (processes) to grow and > shrink dynamically, then maybe that's the purpose of mod_fcgid. In > our > case, we can accept fastcgi requests about as fast as apache sends > them, > because our accept loop immediately spawns a new thread to handle the > request and goes back to get the next request. > > One user has reported much slower response times for mod_fcgid. > > The fastcgi server library code is somewhat "scary", global variables, > unclearly documented return codes, etc. But it seems to work well for > what we're doing. > > We've had problems with mod_fastcgi versions on windows. I think we > haven't been able to go above a certain version (2.8?) with the most > recent version of apache 2. > > Rob > > _______________________________________________ > FastCGI-developers mailing list > FastCGI-developers at mailman.fastcgi.com > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers From chapmanm at pixia.com Mon Dec 7 14:20:30 2009 From: chapmanm at pixia.com (Martin Chapman) Date: Mon, 7 Dec 2009 12:20:30 -0700 Subject: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? In-Reply-To: <4B1D51A9.3030002@booksys.com> References: <4B1D51A9.3030002@booksys.com> Message-ID: Rob, Let me get this straight. You say you have one multi-threaded fastcgi instance running per Apache instance and you handle all requests through that one instance using a thread pool of worker threads that all block on FCGI_Accept() and asyncronously handle requests? I have used threads for years and attempted to do the same thing but ran into the problem that fastcgi stores the handles to stdin and stdout in a global non-syncronized structure. Therefore, unless I put a mutex or critical section around the entire code in the accept loop, fastcgi would reset the io pointers when another thread would call FCGI_Accept(). Thus, making it impossible to truly run more than one thread at a time. The multi threaded example code that comes with FastCGI is completely flawed and tricks people who don't understand multi-threaded code into believing that it actually works when in fact it does not. This is tricky to understand because you can make multiple threads that all call FCGI_Accept(), and it will appear to work if you have a critical section or mutex around the code in your loop, BUT, because the request handling code is all synchronized with the critical section or mutex (whatever you choose to synchronize with) it is really only letting one block of code run at any given time. If you think I am mistaken then please tell me what you did to get it to work because I would much rather run a single instance of my CGI process with multiple threads than multiple single threaded CGI processes. Best regards, Martin -----Original Message----- From: fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com [mailto:fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com] On Behalf Of Rob Lemley Sent: Monday, December 07, 2009 12:04 PM Cc: FastCGI Developers Subject: Re: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? Tom Bowden wrote: > Is the difference between these modules just a matter of version? I > am using Apache 2.2+ server -- and it uses mod_fcgid... from what i > can tell the big difference is that the configuration keywords are > difference ( FcgidAuthenticator, FcgidAuthorizer, FcgidAccessChecker, > FcgidWrapper, etc.). mod_fcgid is a different project. I've never used mod_fcgid. It appears useful in situations where many processes are somehow started and you want the fcgid process manager to kill them when not needed. We have one multi-threaded FastCgiExternalServer process per apache2 virtual host. These servers never exit. Therefore, I never saw the advantage to the mod_fcgid "process management strategy, which concentrates on reducing the number of fastcgi server, and kick out the corrupt fastcgi server as soon as possible". I'm not sure, but I guess if you had a single threaded fcgi server and wanted to have the number of instances of it (processes) to grow and shrink dynamically, then maybe that's the purpose of mod_fcgid. In our case, we can accept fastcgi requests about as fast as apache sends them, because our accept loop immediately spawns a new thread to handle the request and goes back to get the next request. One user has reported much slower response times for mod_fcgid. The fastcgi server library code is somewhat "scary", global variables, unclearly documented return codes, etc. But it seems to work well for what we're doing. We've had problems with mod_fastcgi versions on windows. I think we haven't been able to go above a certain version (2.8?) with the most recent version of apache 2. Rob _______________________________________________ FastCGI-developers mailing list FastCGI-developers at mailman.fastcgi.com http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers From charles_thomas at mac.com Mon Dec 7 14:35:33 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Mon, 07 Dec 2009 13:35:33 -0600 Subject: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? In-Reply-To: References: <4B1D51A9.3030002@booksys.com> Message-ID: I've had to work through a similar (but different :) situation... don't know if this helps at all. I have an fcgi app -- where I use FCGX_Accept() instead of FCGI_Accept (). Within the same thread I am also checking a postgres socket and an inotifyd fd using pselect. My problem was that since FCG*_Accept is a blocking call on stdin my pselect loop was either missing signals - or not being able to respond in a timely fashion. To fix it, i had to fcntl(FCGI_LISTENSOCKET_FILENO, F_SETFL, O_NONBLOCK), and then use a loop structure like: while(1) { if ( ....CALL PSELECT.... returns a fd==FCGI_LISTENSOCKET_FILENO) { if ( FCGX_Accept_r(&request) ) { ... fastcgi stuff.. FCGX_Finish_r(&request) } } } For some reason I had to call the Finish logic at the end of each cycle... but the end result is that I am able to run a server that can listen for/respond to input from apache, postgres, or file system changes. Tom On Dec 7, 2009, at 1:20 PM, Martin Chapman wrote: > Rob, > > Let me get this straight. You say you have one multi-threaded fastcgi > instance running per Apache instance and you handle all requests > through > that one instance using a thread pool of worker threads that all > block on > FCGI_Accept() and asyncronously handle requests? > > I have used threads for years and attempted to do the same thing > but ran > into the problem that fastcgi stores the handles to stdin and > stdout in a > global non-syncronized structure. Therefore, unless I put a mutex or > critical section around the entire code in the accept loop, fastcgi > would > reset the io pointers when another thread would call FCGI_Accept > (). Thus, > making it impossible to truly run more than one thread at a time. > The multi > threaded example code that comes with FastCGI is completely flawed and > tricks people who don't understand multi-threaded code into > believing that > it actually works when in fact it does not. > > This is tricky to understand because you can make multiple threads > that all > call FCGI_Accept(), and it will appear to work if you have a critical > section or mutex around the code in your loop, BUT, because the > request > handling code is all synchronized with the critical section or mutex > (whatever you choose to synchronize with) it is really only letting > one > block of code run at any given time. > > If you think I am mistaken then please tell me what you did to get > it to > work because I would much rather run a single instance of my CGI > process > with multiple threads than multiple single threaded CGI processes. > > Best regards, > Martin > > > -----Original Message----- > From: fastcgi-developers-bounces > +chapmanm=pixia.com at mailman.fastcgi.com > [mailto:fastcgi-developers-bounces > +chapmanm=pixia.com at mailman.fastcgi.com] > On Behalf Of Rob Lemley > Sent: Monday, December 07, 2009 12:04 PM > Cc: FastCGI Developers > Subject: Re: [FASTCGI] difference between apache's mod_fcgi, > mod_cgid, and > mod_fcgid? > > Tom Bowden wrote: >> Is the difference between these modules just a matter of version? I >> am using Apache 2.2+ server -- and it uses mod_fcgid... from what i >> can tell the big difference is that the configuration keywords are >> difference ( FcgidAuthenticator, FcgidAuthorizer, FcgidAccessChecker, >> FcgidWrapper, etc.). > > mod_fcgid is a different project. I've never used mod_fcgid. It > appears useful in situations where many processes are somehow started > and you want the fcgid process manager to kill them when not needed. > > We have one multi-threaded FastCgiExternalServer process per apache2 > virtual host. These servers never exit. Therefore, I never saw the > advantage to the mod_fcgid "process management strategy, which > concentrates on reducing the number of fastcgi server, and kick out > the > corrupt fastcgi server as soon as possible". > > I'm not sure, but I guess if you had a single threaded fcgi server and > wanted to have the number of instances of it (processes) to grow and > shrink dynamically, then maybe that's the purpose of mod_fcgid. In > our > case, we can accept fastcgi requests about as fast as apache sends > them, > because our accept loop immediately spawns a new thread to handle the > request and goes back to get the next request. > > One user has reported much slower response times for mod_fcgid. > > The fastcgi server library code is somewhat "scary", global variables, > unclearly documented return codes, etc. But it seems to work well for > what we're doing. > > We've had problems with mod_fastcgi versions on windows. I think we > haven't been able to go above a certain version (2.8?) with the most > recent version of apache 2. > > Rob > > _______________________________________________ > FastCGI-developers mailing list > FastCGI-developers at mailman.fastcgi.com > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers > > _______________________________________________ > FastCGI-developers mailing list > FastCGI-developers at mailman.fastcgi.com > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers From chapmanm at pixia.com Mon Dec 7 14:39:36 2009 From: chapmanm at pixia.com (Martin Chapman) Date: Mon, 7 Dec 2009 12:39:36 -0700 Subject: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? In-Reply-To: References: <4B1D51A9.3030002@booksys.com> Message-ID: <7450F7900C5E43C98D0C8FC682BB07DA@chapmanm64> Tom, That is awesome! I was also using the FCGX_... commands to avoid fastcg_stdio.h from re-defining everything. I am going to give that a shot sometime in the next few days. I'll write back when I get it implemented and let you know how it went. If it works then you are the man! Best regards, Martin -----Original Message----- From: Tom Bowden [mailto:charles_thomas at mac.com] Sent: Monday, December 07, 2009 12:36 PM To: Martin Chapman Cc: 'Rob Lemley'; 'FastCGI Developers' Subject: Re: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? I've had to work through a similar (but different :) situation... don't know if this helps at all. I have an fcgi app -- where I use FCGX_Accept() instead of FCGI_Accept (). Within the same thread I am also checking a postgres socket and an inotifyd fd using pselect. My problem was that since FCG*_Accept is a blocking call on stdin my pselect loop was either missing signals - or not being able to respond in a timely fashion. To fix it, i had to fcntl(FCGI_LISTENSOCKET_FILENO, F_SETFL, O_NONBLOCK), and then use a loop structure like: while(1) { if ( ....CALL PSELECT.... returns a fd==FCGI_LISTENSOCKET_FILENO) { if ( FCGX_Accept_r(&request) ) { ... fastcgi stuff.. FCGX_Finish_r(&request) } } } For some reason I had to call the Finish logic at the end of each cycle... but the end result is that I am able to run a server that can listen for/respond to input from apache, postgres, or file system changes. Tom On Dec 7, 2009, at 1:20 PM, Martin Chapman wrote: > Rob, > > Let me get this straight. You say you have one multi-threaded fastcgi > instance running per Apache instance and you handle all requests > through > that one instance using a thread pool of worker threads that all > block on > FCGI_Accept() and asyncronously handle requests? > > I have used threads for years and attempted to do the same thing > but ran > into the problem that fastcgi stores the handles to stdin and > stdout in a > global non-syncronized structure. Therefore, unless I put a mutex or > critical section around the entire code in the accept loop, fastcgi > would > reset the io pointers when another thread would call FCGI_Accept > (). Thus, > making it impossible to truly run more than one thread at a time. > The multi > threaded example code that comes with FastCGI is completely flawed and > tricks people who don't understand multi-threaded code into > believing that > it actually works when in fact it does not. > > This is tricky to understand because you can make multiple threads > that all > call FCGI_Accept(), and it will appear to work if you have a critical > section or mutex around the code in your loop, BUT, because the > request > handling code is all synchronized with the critical section or mutex > (whatever you choose to synchronize with) it is really only letting > one > block of code run at any given time. > > If you think I am mistaken then please tell me what you did to get > it to > work because I would much rather run a single instance of my CGI > process > with multiple threads than multiple single threaded CGI processes. > > Best regards, > Martin > > > -----Original Message----- > From: fastcgi-developers-bounces > +chapmanm=pixia.com at mailman.fastcgi.com > [mailto:fastcgi-developers-bounces > +chapmanm=pixia.com at mailman.fastcgi.com] > On Behalf Of Rob Lemley > Sent: Monday, December 07, 2009 12:04 PM > Cc: FastCGI Developers > Subject: Re: [FASTCGI] difference between apache's mod_fcgi, > mod_cgid, and > mod_fcgid? > > Tom Bowden wrote: >> Is the difference between these modules just a matter of version? I >> am using Apache 2.2+ server -- and it uses mod_fcgid... from what i >> can tell the big difference is that the configuration keywords are >> difference ( FcgidAuthenticator, FcgidAuthorizer, FcgidAccessChecker, >> FcgidWrapper, etc.). > > mod_fcgid is a different project. I've never used mod_fcgid. It > appears useful in situations where many processes are somehow started > and you want the fcgid process manager to kill them when not needed. > > We have one multi-threaded FastCgiExternalServer process per apache2 > virtual host. These servers never exit. Therefore, I never saw the > advantage to the mod_fcgid "process management strategy, which > concentrates on reducing the number of fastcgi server, and kick out > the > corrupt fastcgi server as soon as possible". > > I'm not sure, but I guess if you had a single threaded fcgi server and > wanted to have the number of instances of it (processes) to grow and > shrink dynamically, then maybe that's the purpose of mod_fcgid. In > our > case, we can accept fastcgi requests about as fast as apache sends > them, > because our accept loop immediately spawns a new thread to handle the > request and goes back to get the next request. > > One user has reported much slower response times for mod_fcgid. > > The fastcgi server library code is somewhat "scary", global variables, > unclearly documented return codes, etc. But it seems to work well for > what we're doing. > > We've had problems with mod_fastcgi versions on windows. I think we > haven't been able to go above a certain version (2.8?) with the most > recent version of apache 2. > > Rob > > _______________________________________________ > FastCGI-developers mailing list > FastCGI-developers at mailman.fastcgi.com > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers > > _______________________________________________ > FastCGI-developers mailing list > FastCGI-developers at mailman.fastcgi.com > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers From charles_thomas at mac.com Mon Dec 7 15:06:17 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Mon, 07 Dec 2009 14:06:17 -0600 Subject: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? In-Reply-To: <7450F7900C5E43C98D0C8FC682BB07DA@chapmanm64> References: <4B1D51A9.3030002@booksys.com> <7450F7900C5E43C98D0C8FC682BB07DA@chapmanm64> Message-ID: <10920626-0847-4918-873B-B442137FC244@mac.com> I wish I could take credit for that particular gem -- but its something I read about online. One error in the pseudo code below (btw) is that its if ( FCGX_Accept_r(&request)==0) ) .... not if ( FCGX_Accept_r(&request)).. Tom On Dec 7, 2009, at 1:39 PM, Martin Chapman wrote: > > Tom, > > That is awesome! I was also using the FCGX_... commands to avoid > fastcg_stdio.h from re-defining everything. I am going to give > that a shot > sometime in the next few days. I'll write back when I get it > implemented > and let you know how it went. If it works then you are the man! > > Best regards, > Martin > > > -----Original Message----- > From: Tom Bowden [mailto:charles_thomas at mac.com] > Sent: Monday, December 07, 2009 12:36 PM > To: Martin Chapman > Cc: 'Rob Lemley'; 'FastCGI Developers' > Subject: Re: [FASTCGI] difference between apache's mod_fcgi, > mod_cgid, and > mod_fcgid? > > I've had to work through a similar (but different :) situation... > don't know if this helps at all. > > I have an fcgi app -- where I use FCGX_Accept() instead of FCGI_Accept > (). Within the same thread I am also checking a postgres socket and > an inotifyd fd using pselect. > > My problem was that since FCG*_Accept is a blocking call on stdin my > pselect loop was either missing signals - or not being able to > respond in a timely fashion. > > To fix it, i had to fcntl(FCGI_LISTENSOCKET_FILENO, F_SETFL, > O_NONBLOCK), and then use a loop structure like: > > while(1) { > if ( ....CALL PSELECT.... returns a > fd==FCGI_LISTENSOCKET_FILENO) { > if ( FCGX_Accept_r(&request) ) { > ... fastcgi stuff.. > FCGX_Finish_r(&request) > } > } > } > > For some reason I had to call the Finish logic at the end of each > cycle... but the end result is that I am able to run a server that > can listen for/respond to input from apache, postgres, or file system > changes. > > > Tom > > On Dec 7, 2009, at 1:20 PM, Martin Chapman wrote: > >> Rob, >> >> Let me get this straight. You say you have one multi-threaded >> fastcgi >> instance running per Apache instance and you handle all requests >> through >> that one instance using a thread pool of worker threads that all >> block on >> FCGI_Accept() and asyncronously handle requests? >> >> I have used threads for years and attempted to do the same thing >> but ran >> into the problem that fastcgi stores the handles to stdin and >> stdout in a >> global non-syncronized structure. Therefore, unless I put a mutex or >> critical section around the entire code in the accept loop, fastcgi >> would >> reset the io pointers when another thread would call FCGI_Accept >> (). Thus, >> making it impossible to truly run more than one thread at a time. >> The multi >> threaded example code that comes with FastCGI is completely flawed >> and >> tricks people who don't understand multi-threaded code into >> believing that >> it actually works when in fact it does not. >> >> This is tricky to understand because you can make multiple threads >> that all >> call FCGI_Accept(), and it will appear to work if you have a critical >> section or mutex around the code in your loop, BUT, because the >> request >> handling code is all synchronized with the critical section or mutex >> (whatever you choose to synchronize with) it is really only letting >> one >> block of code run at any given time. >> >> If you think I am mistaken then please tell me what you did to get >> it to >> work because I would much rather run a single instance of my CGI >> process >> with multiple threads than multiple single threaded CGI processes. >> >> Best regards, >> Martin >> >> >> -----Original Message----- >> From: fastcgi-developers-bounces >> +chapmanm=pixia.com at mailman.fastcgi.com >> [mailto:fastcgi-developers-bounces >> +chapmanm=pixia.com at mailman.fastcgi.com] >> On Behalf Of Rob Lemley >> Sent: Monday, December 07, 2009 12:04 PM >> Cc: FastCGI Developers >> Subject: Re: [FASTCGI] difference between apache's mod_fcgi, >> mod_cgid, and >> mod_fcgid? >> >> Tom Bowden wrote: >>> Is the difference between these modules just a matter of version? I >>> am using Apache 2.2+ server -- and it uses mod_fcgid... from what i >>> can tell the big difference is that the configuration keywords are >>> difference ( FcgidAuthenticator, FcgidAuthorizer, >>> FcgidAccessChecker, >>> FcgidWrapper, etc.). >> >> mod_fcgid is a different project. I've never used mod_fcgid. It >> appears useful in situations where many processes are somehow started >> and you want the fcgid process manager to kill them when not needed. >> >> We have one multi-threaded FastCgiExternalServer process per apache2 >> virtual host. These servers never exit. Therefore, I never saw the >> advantage to the mod_fcgid "process management strategy, which >> concentrates on reducing the number of fastcgi server, and kick out >> the >> corrupt fastcgi server as soon as possible". >> >> I'm not sure, but I guess if you had a single threaded fcgi server >> and >> wanted to have the number of instances of it (processes) to grow and >> shrink dynamically, then maybe that's the purpose of mod_fcgid. In >> our >> case, we can accept fastcgi requests about as fast as apache sends >> them, >> because our accept loop immediately spawns a new thread to handle the >> request and goes back to get the next request. >> >> One user has reported much slower response times for mod_fcgid. >> >> The fastcgi server library code is somewhat "scary", global >> variables, >> unclearly documented return codes, etc. But it seems to work well >> for >> what we're doing. >> >> We've had problems with mod_fastcgi versions on windows. I think we >> haven't been able to go above a certain version (2.8?) with the most >> recent version of apache 2. >> >> Rob >> >> _______________________________________________ >> FastCGI-developers mailing list >> FastCGI-developers at mailman.fastcgi.com >> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers >> >> _______________________________________________ >> FastCGI-developers mailing list >> FastCGI-developers at mailman.fastcgi.com >> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers > From chapmanm at pixia.com Mon Dec 7 15:08:54 2009 From: chapmanm at pixia.com (Martin Chapman) Date: Mon, 7 Dec 2009 13:08:54 -0700 Subject: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? In-Reply-To: <10920626-0847-4918-873B-B442137FC244@mac.com> References: <4B1D51A9.3030002@booksys.com> <7450F7900C5E43C98D0C8FC682BB07DA@chapmanm64> <10920626-0847-4918-873B-B442137FC244@mac.com> Message-ID: Thanks for the info Tom but if it works we'll give you credit for this thread anyway. :) Martin -----Original Message----- From: Tom Bowden [mailto:charles_thomas at mac.com] Sent: Monday, December 07, 2009 1:06 PM To: Martin Chapman Cc: 'Rob Lemley'; 'FastCGI Developers' Subject: Re: [FASTCGI] difference between apache's mod_fcgi, mod_cgid, and mod_fcgid? I wish I could take credit for that particular gem -- but its something I read about online. One error in the pseudo code below (btw) is that its if ( FCGX_Accept_r(&request)==0) ) .... not if ( FCGX_Accept_r(&request)).. Tom On Dec 7, 2009, at 1:39 PM, Martin Chapman wrote: > > Tom, > > That is awesome! I was also using the FCGX_... commands to avoid > fastcg_stdio.h from re-defining everything. I am going to give > that a shot > sometime in the next few days. I'll write back when I get it > implemented > and let you know how it went. If it works then you are the man! > > Best regards, > Martin > > > -----Original Message----- > From: Tom Bowden [mailto:charles_thomas at mac.com] > Sent: Monday, December 07, 2009 12:36 PM > To: Martin Chapman > Cc: 'Rob Lemley'; 'FastCGI Developers' > Subject: Re: [FASTCGI] difference between apache's mod_fcgi, > mod_cgid, and > mod_fcgid? > > I've had to work through a similar (but different :) situation... > don't know if this helps at all. > > I have an fcgi app -- where I use FCGX_Accept() instead of FCGI_Accept > (). Within the same thread I am also checking a postgres socket and > an inotifyd fd using pselect. > > My problem was that since FCG*_Accept is a blocking call on stdin my > pselect loop was either missing signals - or not being able to > respond in a timely fashion. > > To fix it, i had to fcntl(FCGI_LISTENSOCKET_FILENO, F_SETFL, > O_NONBLOCK), and then use a loop structure like: > > while(1) { > if ( ....CALL PSELECT.... returns a > fd==FCGI_LISTENSOCKET_FILENO) { > if ( FCGX_Accept_r(&request) ) { > ... fastcgi stuff.. > FCGX_Finish_r(&request) > } > } > } > > For some reason I had to call the Finish logic at the end of each > cycle... but the end result is that I am able to run a server that > can listen for/respond to input from apache, postgres, or file system > changes. > > > Tom > > On Dec 7, 2009, at 1:20 PM, Martin Chapman wrote: > >> Rob, >> >> Let me get this straight. You say you have one multi-threaded >> fastcgi >> instance running per Apache instance and you handle all requests >> through >> that one instance using a thread pool of worker threads that all >> block on >> FCGI_Accept() and asyncronously handle requests? >> >> I have used threads for years and attempted to do the same thing >> but ran >> into the problem that fastcgi stores the handles to stdin and >> stdout in a >> global non-syncronized structure. Therefore, unless I put a mutex or >> critical section around the entire code in the accept loop, fastcgi >> would >> reset the io pointers when another thread would call FCGI_Accept >> (). Thus, >> making it impossible to truly run more than one thread at a time. >> The multi >> threaded example code that comes with FastCGI is completely flawed >> and >> tricks people who don't understand multi-threaded code into >> believing that >> it actually works when in fact it does not. >> >> This is tricky to understand because you can make multiple threads >> that all >> call FCGI_Accept(), and it will appear to work if you have a critical >> section or mutex around the code in your loop, BUT, because the >> request >> handling code is all synchronized with the critical section or mutex >> (whatever you choose to synchronize with) it is really only letting >> one >> block of code run at any given time. >> >> If you think I am mistaken then please tell me what you did to get >> it to >> work because I would much rather run a single instance of my CGI >> process >> with multiple threads than multiple single threaded CGI processes. >> >> Best regards, >> Martin >> >> >> -----Original Message----- >> From: fastcgi-developers-bounces >> +chapmanm=pixia.com at mailman.fastcgi.com >> [mailto:fastcgi-developers-bounces >> +chapmanm=pixia.com at mailman.fastcgi.com] >> On Behalf Of Rob Lemley >> Sent: Monday, December 07, 2009 12:04 PM >> Cc: FastCGI Developers >> Subject: Re: [FASTCGI] difference between apache's mod_fcgi, >> mod_cgid, and >> mod_fcgid? >> >> Tom Bowden wrote: >>> Is the difference between these modules just a matter of version? I >>> am using Apache 2.2+ server -- and it uses mod_fcgid... from what i >>> can tell the big difference is that the configuration keywords are >>> difference ( FcgidAuthenticator, FcgidAuthorizer, >>> FcgidAccessChecker, >>> FcgidWrapper, etc.). >> >> mod_fcgid is a different project. I've never used mod_fcgid. It >> appears useful in situations where many processes are somehow started >> and you want the fcgid process manager to kill them when not needed. >> >> We have one multi-threaded FastCgiExternalServer process per apache2 >> virtual host. These servers never exit. Therefore, I never saw the >> advantage to the mod_fcgid "process management strategy, which >> concentrates on reducing the number of fastcgi server, and kick out >> the >> corrupt fastcgi server as soon as possible". >> >> I'm not sure, but I guess if you had a single threaded fcgi server >> and >> wanted to have the number of instances of it (processes) to grow and >> shrink dynamically, then maybe that's the purpose of mod_fcgid. In >> our >> case, we can accept fastcgi requests about as fast as apache sends >> them, >> because our accept loop immediately spawns a new thread to handle the >> request and goes back to get the next request. >> >> One user has reported much slower response times for mod_fcgid. >> >> The fastcgi server library code is somewhat "scary", global >> variables, >> unclearly documented return codes, etc. But it seems to work well >> for >> what we're doing. >> >> We've had problems with mod_fastcgi versions on windows. I think we >> haven't been able to go above a certain version (2.8?) with the most >> recent version of apache 2. >> >> Rob >> >> _______________________________________________ >> FastCGI-developers mailing list >> FastCGI-developers at mailman.fastcgi.com >> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers >> >> _______________________________________________ >> FastCGI-developers mailing list >> FastCGI-developers at mailman.fastcgi.com >> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers > From arun at eagle-india.com Mon Dec 7 23:28:39 2009 From: arun at eagle-india.com (A. M. ArunKumar) Date: Tue, 8 Dec 2009 09:58:39 +0530 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <2B0FDE78-2974-43F4-9616-C19955981A28@mac.com> Message-ID: <20091208043015.CF0B74A10@smtp.chelsea.net> I understand the security risk explained. Well mine is FastCGI application started through apache ExecCGI system. I have to lookup how to setup the application as FastCGI internal application. Let me try and get back to you all Thanks Arun _____ From: Tom Bowden [mailto:charles_thomas at mac.com] Sent: Monday, December 07, 2009 11:55 PM To: Rob Lemley Cc: darren.garvey at gmail.com; A. M. ArunKumar; fastcgi-developers at mailman.pins.net Subject: Re: [FASTCGI] FastCGI with Oracle I am trying to remember where I read this in the fastcgi/fastcgx documentation -- but somewhere they recommend not using setenv within the accept loop. Perhaps each iteration of FCGII_Accept/FCGIX_Accept it clears and resets? It's a real security risk (IMHO).... an old hacker trick is to modify the path (for example) to point to your own version of a sh (sushi, etc). I've only used mod_fcgid -- with AddHandler -- and its (still) confusing me. Tom On Dec 7, 2009, at 11:47 AM, Rob Lemley wrote: Darren Garvey wrote: 2009/12/4 A. M. ArunKumar The solution which you gave has helped me. But its not after accept its before that. we need to set it back in the C++ program. I used the setenv function in c++ and now its connecting to oracle. Is this how it is supposed to happen? I don't see why the FastCGI library should clear environment variables for the whole application... We really can't tell what is happening because we need to know more about how A.M. ArunKumar is starting the fastcgi server app. I think he's using the apache mod_fastcgi but we don't know if it's external FastCGI, internal FastCGI, or FastCGI started through the apache ExecCGI system. I know from experience that the mod_fastcgi FastCgiServer directive (ie "internal" fastcgi server) with the "-initial-env name=[value]" option passes the values into the specified application which is started by the mod_fastcgi process manager. So from that, I assume that ArunKumar is NOT running an "internal" fastcgi server via the FastCgiServer directive. ArunKumar, can you give us more details about how you're initializing/executing/starting your FastCGI server C++ app? If you're running it as a "FastCgiExternalServer" and starting via some other means (such as init scripts, daemontools, or the windows service manager), then it's true, the environment variables will not be passed through the FastCGI connection to the external fastcgi server app. The only thing I know of like this is the FastCgiExternalServer "-pass-header" option, which I'm thinking would pass the headers only upon receipt of a request from the client. I haven't worked with the apache "SetHandler" and "AddHandler" directives to know how environment variables work with those. Rob _______________________________________________ FastCGI-developers mailing list FastCGI-developers at mailman.fastcgi.com http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon at group309.com Tue Dec 8 01:01:14 2009 From: gordon at group309.com (Gordon Colburn) Date: Tue, 8 Dec 2009 01:01:14 -0500 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <20091208043015.CF0B74A10@smtp.chelsea.net> References: <2B0FDE78-2974-43F4-9616-C19955981A28@mac.com> <20091208043015.CF0B74A10@smtp.chelsea.net> Message-ID: <000001ca77cb$de973b80$0138a8c0@mozart> I recently ran into this issue using static fast CGI servers with mod_fastcgi. Tom is correct; FCGI_accept resets the environment each time it is called. Any environment variables that are set using the -initial-env parameter of the FastCgiServer directive will be available in the environment when the application is first started, but once FCGI_accept is called they will no longer be available. I think the reason this is done is that mod_fastcgi passes request specific information in the environment much like a regular CGI application does and to do this it resets the environment each time FCGI_accept is called. _____ From: fastcgi-developers-bounces+gordon=group309.com at mailman.fastcgi.com [mailto:fastcgi-developers-bounces+gordon=group309.com at mailman.fastcgi.com] On Behalf Of A. M. ArunKumar Sent: Monday, December 07, 2009 11:29 PM To: 'Tom Bowden'; 'Rob Lemley'; '??' Cc: darren.garvey at gmail.com; fastcgi-developers at mailman.pins.net Subject: Re: [FASTCGI] FastCGI with Oracle I understand the security risk explained. Well mine is FastCGI application started through apache ExecCGI system. I have to lookup how to setup the application as FastCGI internal application. Let me try and get back to you all Thanks Arun _____ From: Tom Bowden [mailto:charles_thomas at mac.com] Sent: Monday, December 07, 2009 11:55 PM To: Rob Lemley Cc: darren.garvey at gmail.com; A. M. ArunKumar; fastcgi-developers at mailman.pins.net Subject: Re: [FASTCGI] FastCGI with Oracle I am trying to remember where I read this in the fastcgi/fastcgx documentation -- but somewhere they recommend not using setenv within the accept loop. Perhaps each iteration of FCGII_Accept/FCGIX_Accept it clears and resets? It's a real security risk (IMHO).... an old hacker trick is to modify the path (for example) to point to your own version of a sh (sushi, etc). I've only used mod_fcgid -- with AddHandler -- and its (still) confusing me. Tom On Dec 7, 2009, at 11:47 AM, Rob Lemley wrote: Darren Garvey wrote: 2009/12/4 A. M. ArunKumar The solution which you gave has helped me. But its not after accept its before that. we need to set it back in the C++ program. I used the setenv function in c++ and now its connecting to oracle. Is this how it is supposed to happen? I don't see why the FastCGI library should clear environment variables for the whole application... We really can't tell what is happening because we need to know more about how A.M. ArunKumar is starting the fastcgi server app. I think he's using the apache mod_fastcgi but we don't know if it's external FastCGI, internal FastCGI, or FastCGI started through the apache ExecCGI system. I know from experience that the mod_fastcgi FastCgiServer directive (ie "internal" fastcgi server) with the "-initial-env name=[value]" option passes the values into the specified application which is started by the mod_fastcgi process manager. So from that, I assume that ArunKumar is NOT running an "internal" fastcgi server via the FastCgiServer directive. ArunKumar, can you give us more details about how you're initializing/executing/starting your FastCGI server C++ app? If you're running it as a "FastCgiExternalServer" and starting via some other means (such as init scripts, daemontools, or the windows service manager), then it's true, the environment variables will not be passed through the FastCGI connection to the external fastcgi server app. The only thing I know of like this is the FastCgiExternalServer "-pass-header" option, which I'm thinking would pass the headers only upon receipt of a request from the client. I haven't worked with the apache "SetHandler" and "AddHandler" directives to know how environment variables work with those. Rob _______________________________________________ FastCGI-developers mailing list FastCGI-developers at mailman.fastcgi.com http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers -------------- next part -------------- An HTML attachment was scrubbed... URL: From rclemley at booksys.com Tue Dec 8 11:37:30 2009 From: rclemley at booksys.com (Rob Lemley) Date: Tue, 08 Dec 2009 10:37:30 -0600 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <000001ca77cb$de973b80$0138a8c0@mozart> References: <2B0FDE78-2974-43F4-9616-C19955981A28@mac.com> <20091208043015.CF0B74A10@smtp.chelsea.net> <000001ca77cb$de973b80$0138a8c0@mozart> Message-ID: <4B1E80CA.1070609@booksys.com> *fcgiapp.h:* FCG*X*_Accept() and FCG*X*_Accept_r() do not touch the global environment (extern char **environ). *fcgi_stdio.h:* FCG*I*_Accept() resets the environment. *fcgiapp.h* the direct API to fastcgi. Does not touch the global environment. *fcgi_stdio.h* an even higher level interface that should make it easier to convert existing CGI programs to FastCGI. As Gordon said, "much like a regular CGI application". This interface is implemented "on top of" fcgiapp.h. Rob Gordon Colburn wrote: > > I recently ran into this issue using static fast CGI servers with > mod_fastcgi. Tom is correct; FCGI_accept resets the environment each > time it is called. Any environment variables that are set using the > -initial-env parameter of the FastCgiServer directive will be > available in the environment when the application is first started, > but once FCGI_accept is called they will no longer be available. I > think the reason this is done is that mod_fastcgi passes request > specific information in the environment much like a regular CGI > application does and to do this it resets the environment each time > FCGI_accept is called. > > > > ------------------------------------------------------------------------ > > *From:* > fastcgi-developers-bounces+gordon=group309.com at mailman.fastcgi.com > [mailto:fastcgi-developers-bounces+gordon=group309.com at mailman.fastcgi.com] > *On Behalf Of *A. M. ArunKumar > *Sent:* Monday, December 07, 2009 11:29 PM > *To:* 'Tom Bowden'; 'Rob Lemley'; '??' > *Cc:* darren.garvey at gmail.com; fastcgi-developers at mailman.pins.net > *Subject:* Re: [FASTCGI] FastCGI with Oracle > > > > I understand the security risk explained. > > > > Well mine is FastCGI application started through apache ExecCGI system. > > > > I have to lookup how to setup the application as FastCGI internal > application. Let me try and get back to you all > > > > Thanks > > Arun > > ------------------------------------------------------------------------ > > *From:* Tom Bowden [mailto:charles_thomas at mac.com] > *Sent:* Monday, December 07, 2009 11:55 PM > *To:* Rob Lemley > *Cc:* darren.garvey at gmail.com; A. M. ArunKumar; > fastcgi-developers at mailman.pins.net > *Subject:* Re: [FASTCGI] FastCGI with Oracle > > > > I am trying to remember where I read this in the fastcgi/fastcgx > documentation -- but somewhere they recommend not using setenv within > the accept loop. Perhaps each iteration of FCGII_Accept/FCGIX_Accept > it clears and resets? > > It's a real security risk (IMHO).... an old hacker trick is to modify > the path (for example) to point to your own version of a sh (sushi, etc). > > > > I've only used mod_fcgid -- with AddHandler -- and its (still) > confusing me. > > > > > > Tom > > > > On Dec 7, 2009, at 11:47 AM, Rob Lemley wrote: > > > > Darren Garvey wrote: > > 2009/12/4 A. M. ArunKumar > > > The solution which you gave has helped me. But its not after accept > its before that. we need to set it back in the C++ program. I used > the setenv function in c++ and now its connecting to oracle. > > Is this how it is supposed to happen? I don't see why the FastCGI > library should clear environment variables for the whole application... > > > We really can't tell what is happening because we need to know more > about how A.M. ArunKumar is starting the fastcgi server app. I think > he's using the apache mod_fastcgi but we don't know if it's external > FastCGI, internal FastCGI, or FastCGI started through the apache > ExecCGI system. > > I know from experience that the mod_fastcgi FastCgiServer directive > (ie "internal" fastcgi server) with the "-initial-env name=[value]" > option passes the values into the specified application which is > started by the mod_fastcgi process manager. > > So from that, I assume that ArunKumar is NOT running an "internal" > fastcgi server via the FastCgiServer directive. > > ArunKumar, can you give us more details about how you're > initializing/executing/starting your FastCGI server C++ app? > > If you're running it as a "FastCgiExternalServer" and starting via > some other means (such as init scripts, daemontools, or the windows > service manager), then it's true, the environment variables will not > be passed through the FastCGI connection to the external fastcgi > server app. The only thing I know of like this is the > FastCgiExternalServer "-pass-header" option, which I'm thinking would > pass the headers only upon receipt of a request from the client. > > I haven't worked with the apache "SetHandler" and "AddHandler" > directives to know how environment variables work with those. > > Rob > > _______________________________________________ > > FastCGI-developers mailing list > > FastCGI-developers at mailman.fastcgi.com > > > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From charles_thomas at mac.com Tue Dec 8 11:59:52 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Tue, 08 Dec 2009 10:59:52 -0600 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <4B1E80CA.1070609@booksys.com> References: <2B0FDE78-2974-43F4-9616-C19955981A28@mac.com> <20091208043015.CF0B74A10@smtp.chelsea.net> <000001ca77cb$de973b80$0138a8c0@mozart> <4B1E80CA.1070609@booksys.com> Message-ID: <5A3A1367-C38F-4736-90F4-5C7E695D9053@mac.com> But in either case (and this is just for clarification) - do they recommend that you not use setenv()? Tom On Dec 8, 2009, at 10:37 AM, Rob Lemley wrote: > fcgiapp.h: FCGX_Accept() and FCGX_Accept_r() do not touch the > global environment (extern char **environ). > fcgi_stdio.h: FCGI_Accept() resets the environment. > > fcgiapp.h the direct API to fastcgi. Does not touch the global > environment. > > fcgi_stdio.h an even higher level interface that should make it > easier to convert existing CGI programs to FastCGI. As Gordon > said, "much like a regular CGI application". This interface is > implemented "on top of" fcgiapp.h. > > Rob > > > Gordon Colburn wrote: >> I recently ran into this issue using static fast CGI servers with >> mod_fastcgi. Tom is correct; FCGI_accept resets the environment >> each time it is called. Any environment variables that are set >> using the -initial-env parameter of the FastCgiServer directive >> will be available in the environment when the application is first >> started, but once FCGI_accept is called they will no longer be >> available. I think the reason this is done is that mod_fastcgi >> passes request specific information in the environment much like a >> regular CGI application does and to do this it resets the >> environment each time FCGI_accept is called. >> >> From: fastcgi-developers-bounces >> +gordon=group309.com at mailman.fastcgi.com [mailto:fastcgi- >> developers-bounces+gordon=group309.com at mailman.fastcgi.com] On >> Behalf Of A. M. ArunKumar >> Sent: Monday, December 07, 2009 11:29 PM >> To: 'Tom Bowden'; 'Rob Lemley'; '??' >> Cc: darren.garvey at gmail.com; fastcgi-developers at mailman.pins.net >> Subject: Re: [FASTCGI] FastCGI with Oracle >> >> I understand the security risk explained. >> >> Well mine is FastCGI application started through apache ExecCGI >> system. >> >> I have to lookup how to setup the application as FastCGI internal >> application. Let me try and get back to you all >> >> Thanks >> Arun >> From: Tom Bowden [mailto:charles_thomas at mac.com] >> Sent: Monday, December 07, 2009 11:55 PM >> To: Rob Lemley >> Cc: darren.garvey at gmail.com; A. M. ArunKumar; fastcgi- >> developers at mailman.pins.net >> Subject: Re: [FASTCGI] FastCGI with Oracle >> >> I am trying to remember where I read this in the fastcgi/fastcgx >> documentation -- but somewhere they recommend not using setenv >> within the accept loop. Perhaps each iteration of FCGII_Accept/ >> FCGIX_Accept it clears and resets? >> It's a real security risk (IMHO).... an old hacker trick is to >> modify the path (for example) to point to your own version of a sh >> (sushi, etc). >> >> I've only used mod_fcgid -- with AddHandler -- and its (still) >> confusing me. >> >> >> Tom >> >> On Dec 7, 2009, at 11:47 AM, Rob Lemley wrote: >> >> >> Darren Garvey wrote: >> >> 2009/12/4 A. M. ArunKumar >> The solution which you gave has helped me. But its not after >> accept its before that. we need to set it back in the C++ >> program. I used the setenv function in c++ and now its connecting >> to oracle. >> >> Is this how it is supposed to happen? I don't see why the FastCGI >> library should clear environment variables for the whole >> application... >> >> We really can't tell what is happening because we need to know >> more about how A.M. ArunKumar is starting the fastcgi server >> app. I think he's using the apache mod_fastcgi but we don't know >> if it's external FastCGI, internal FastCGI, or FastCGI started >> through the apache ExecCGI system. >> >> I know from experience that the mod_fastcgi FastCgiServer >> directive (ie "internal" fastcgi server) with the "-initial-env >> name=[value]" option passes the values into the specified >> application which is started by the mod_fastcgi process manager. >> >> So from that, I assume that ArunKumar is NOT running an "internal" >> fastcgi server via the FastCgiServer directive. >> >> ArunKumar, can you give us more details about how you're >> initializing/executing/starting your FastCGI server C++ app? >> >> If you're running it as a "FastCgiExternalServer" and starting via >> some other means (such as init scripts, daemontools, or the >> windows service manager), then it's true, the environment >> variables will not be passed through the FastCGI connection to the >> external fastcgi server app. The only thing I know of like this >> is the FastCgiExternalServer "-pass-header" option, which I'm >> thinking would pass the headers only upon receipt of a request >> from the client. >> >> I haven't worked with the apache "SetHandler" and "AddHandler" >> directives to know how environment variables work with those. >> >> Rob >> >> _______________________________________________ >> FastCGI-developers mailing list >> FastCGI-developers at mailman.fastcgi.com >> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rclemley at booksys.com Tue Dec 8 12:34:07 2009 From: rclemley at booksys.com (Rob Lemley) Date: Tue, 08 Dec 2009 11:34:07 -0600 Subject: [FASTCGI] FastCGI with Oracle In-Reply-To: <5A3A1367-C38F-4736-90F4-5C7E695D9053@mac.com> References: <2B0FDE78-2974-43F4-9616-C19955981A28@mac.com> <20091208043015.CF0B74A10@smtp.chelsea.net> <000001ca77cb$de973b80$0138a8c0@mozart> <4B1E80CA.1070609@booksys.com> <5A3A1367-C38F-4736-90F4-5C7E695D9053@mac.com> Message-ID: <4B1E8E0F.9090508@booksys.com> I don't think there's any FastCGI-related problem modifying the environment if the program uses only fcgiapp.h. I've seen many warnings to leave the environment alone when using FCGI_Accept() from fcgi_stdio. http://www.fastcgi.com/devkit/doc/FCGI_Accept.3 http://www.fastcgi.com/om_archive/mail-archive/0019.html Tom Bowden wrote: > But in either case (and this is just for clarification) - do they > recommend that you not use setenv()? > > Tom > > On Dec 8, 2009, at 10:37 AM, Rob Lemley wrote: > >> *fcgiapp.h:* FCG*X*_Accept() and FCG*X*_Accept_r() do not touch the >> global environment (extern char **environ). >> *fcgi_stdio.h:* FCG*I*_Accept() resets the environment. >> >> *fcgiapp.h* the direct API to fastcgi. Does not touch the global >> environment. >> >> *fcgi_stdio.h* an even higher level interface that should make it >> easier to convert existing CGI programs to FastCGI. As Gordon said, >> "much like a regular CGI application". This interface is implemented >> "on top of" fcgiapp.h. >> >> Rob >> >> >> Gordon Colburn wrote: >>> >>> I recently ran into this issue using static fast CGI servers with >>> mod_fastcgi. Tom is correct; FCGI_accept resets the environment each >>> time it is called. Any environment variables that are set using the >>> -initial-env parameter of the FastCgiServer directive will be >>> available in the environment when the application is first started, >>> but once FCGI_accept is called they will no longer be available. I >>> think the reason this is done is that mod_fastcgi passes request >>> specific information in the environment much like a regular CGI >>> application does and to do this it resets the environment each time >>> FCGI_accept is called. >>> >>> >>> >>> ------------------------------------------------------------------------ >>> >>> *From:* >>> fastcgi-developers-bounces+gordon=group309.com at mailman.fastcgi.com >>> [mailto:fastcgi-developers-bounces+gordon=group309.com at mailman.fastcgi.com] >>> *On Behalf Of *A. M. ArunKumar >>> *Sent:* Monday, December 07, 2009 11:29 PM >>> *To:* 'Tom Bowden'; 'Rob Lemley'; '??' >>> *Cc:* darren.garvey at gmail.com; fastcgi-developers at mailman.pins.net >>> *Subject:* Re: [FASTCGI] FastCGI with Oracle >>> >>> >>> >>> I understand the security risk explained. >>> >>> >>> >>> Well mine is FastCGI application started through apache ExecCGI >>> system. >>> >>> >>> >>> I have to lookup how to setup the application as FastCGI internal >>> application. Let me try and get back to you all >>> >>> >>> >>> Thanks >>> >>> Arun >>> >>> ------------------------------------------------------------------------ >>> >>> *From:* Tom Bowden [mailto:charles_thomas at mac.com] >>> *Sent:* Monday, December 07, 2009 11:55 PM >>> *To:* Rob Lemley >>> *Cc:* darren.garvey at gmail.com; A. M. ArunKumar; >>> fastcgi-developers at mailman.pins.net >>> *Subject:* Re: [FASTCGI] FastCGI with Oracle >>> >>> >>> >>> I am trying to remember where I read this in the fastcgi/fastcgx >>> documentation -- but somewhere they recommend not using setenv >>> within the accept loop. Perhaps each iteration of >>> FCGII_Accept/FCGIX_Accept it clears and resets? >>> >>> It's a real security risk (IMHO).... an old hacker trick is to >>> modify the path (for example) to point to your own version of a sh >>> (sushi, etc). >>> >>> >>> >>> I've only used mod_fcgid -- with AddHandler -- and its (still) >>> confusing me. >>> >>> >>> >>> >>> >>> Tom >>> >>> >>> >>> On Dec 7, 2009, at 11:47 AM, Rob Lemley wrote: >>> >>> >>> >>> Darren Garvey wrote: >>> >>> 2009/12/4 A. M. ArunKumar >> > >>> >>> The solution which you gave has helped me. But its not after accept >>> its before that. we need to set it back in the C++ program. I used >>> the setenv function in c++ and now its connecting to oracle. >>> >>> Is this how it is supposed to happen? I don't see why the FastCGI >>> library should clear environment variables for the whole application... >>> >>> >>> We really can't tell what is happening because we need to know more >>> about how A.M. ArunKumar is starting the fastcgi server app. I >>> think he's using the apache mod_fastcgi but we don't know if it's >>> external FastCGI, internal FastCGI, or FastCGI started through the >>> apache ExecCGI system. >>> >>> I know from experience that the mod_fastcgi FastCgiServer directive >>> (ie "internal" fastcgi server) with the "-initial-env name=[value]" >>> option passes the values into the specified application which is >>> started by the mod_fastcgi process manager. >>> >>> So from that, I assume that ArunKumar is NOT running an "internal" >>> fastcgi server via the FastCgiServer directive. >>> >>> ArunKumar, can you give us more details about how you're >>> initializing/executing/starting your FastCGI server C++ app? >>> >>> If you're running it as a "FastCgiExternalServer" and starting via >>> some other means (such as init scripts, daemontools, or the windows >>> service manager), then it's true, the environment variables will not >>> be passed through the FastCGI connection to the external fastcgi >>> server app. The only thing I know of like this is the >>> FastCgiExternalServer "-pass-header" option, which I'm thinking >>> would pass the headers only upon receipt of a request from the client. >>> >>> I haven't worked with the apache "SetHandler" and "AddHandler" >>> directives to know how environment variables work with those. >>> >>> Rob >>> >>> _______________________________________________ >>> >>> FastCGI-developers mailing list >>> >>> FastCGI-developers at mailman.fastcgi.com >>> >>> >>> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers >>> >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From charles_thomas at mac.com Wed Dec 9 15:17:40 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Wed, 09 Dec 2009 14:17:40 -0600 Subject: [FASTCGI] Cookie processing in Fast CGI Message-ID: Is there a thread somewhere that talks about parsing cookies - or, is this something that I have to treat like any other header parsing task. Tom From chapmanm at pixia.com Wed Dec 9 15:47:15 2009 From: chapmanm at pixia.com (Martin Chapman) Date: Wed, 9 Dec 2009 13:47:15 -0700 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: References: Message-ID: <8C2873C32A3B4A89B76CF7A8A05AB631@chapmanm64> Tom, I have some old routines that parse cookies if you need a starting point. They are written using C++ and COM but the code would be easy to translate to ANSI C/C++ if you want the routines. You might be able to find something better on the web but if you can't let me know and I'll send them to you. Martin -----Original Message----- From: fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com [mailto:fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com] On Behalf Of Tom Bowden Sent: Wednesday, December 09, 2009 1:18 PM To: FastCGI Developers Subject: [FASTCGI] Cookie processing in Fast CGI Is there a thread somewhere that talks about parsing cookies - or, is this something that I have to treat like any other header parsing task. Tom _______________________________________________ FastCGI-developers mailing list FastCGI-developers at mailman.fastcgi.com http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers From chapmanm at pixia.com Wed Dec 9 16:02:03 2009 From: chapmanm at pixia.com (Martin Chapman) Date: Wed, 9 Dec 2009 14:02:03 -0700 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: References: Message-ID: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> Tom, It's a little ugly because it's COM and if you convert it to FastCGI it would be cool if you posted it back for the rest of us if you can. The entire COM implementation is attached. General Gist: 1. Get the cookie from the env vars. Should be called HTTP_COOKIE. 2. Use a method like the one below to parse the cookie value. STDMETHODIMP CCookie::ParseValue(BSTR sCookie) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); _bstr_t bstrCookie(sCookie); if (bstrCookie.length() == 0) return E_INVALIDARG; CString strCookie = (TCHAR*) bstrCookie; LPCSTR pEnd = strCookie; LPCSTR pStart = strCookie; CString name, value; while (*pEnd != '\0') { while (*pEnd && *pEnd != '=' && *pEnd != '&') pEnd++; if (*pEnd == '\0' || *pEnd == '&') { if (pEnd > pStart) { CopyToCString(value, pStart, pEnd); } put_Value(_bstr_t(value.GetBuffer())); if (*pEnd == '&') { pEnd++; pStart = pEnd; continue; } return S_OK; } else if (*pEnd == '=' ) { if (pEnd > pStart) { CopyToCString(name, pStart, pEnd); } else { pEnd++; pStart = pEnd; break; } pEnd++; pStart = pEnd; while (*pEnd && *pEnd != '&' && *pEnd != '=') pEnd++; if (pEnd > pStart) CopyToCString(value, pStart, pEnd); AddValue(_bstr_t(name.GetBuffer()), _bstr_t(value.GetBuffer())); if (*pEnd != '\0') pEnd++; pStart = pEnd; } } return S_OK; } 3. The following func parses a single cookie value and is used in the func above. STDMETHODIMP CCookie::ParseValue(BSTR sCookie) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); _bstr_t bstrCookie(sCookie); if (bstrCookie.length() == 0) return E_INVALIDARG; CString strCookie = (TCHAR*) bstrCookie; LPCSTR pEnd = strCookie; LPCSTR pStart = strCookie; CString name, value; while (*pEnd != '\0') { while (*pEnd && *pEnd != '=' && *pEnd != '&') pEnd++; if (*pEnd == '\0' || *pEnd == '&') { if (pEnd > pStart) { CopyToCString(value, pStart, pEnd); } put_Value(_bstr_t(value.GetBuffer())); if (*pEnd == '&') { pEnd++; pStart = pEnd; continue; } return S_OK; } else if (*pEnd == '=' ) { if (pEnd > pStart) { CopyToCString(name, pStart, pEnd); } else { pEnd++; pStart = pEnd; break; } pEnd++; pStart = pEnd; while (*pEnd && *pEnd != '&' && *pEnd != '=') pEnd++; if (pEnd > pStart) CopyToCString(value, pStart, pEnd); AddValue(_bstr_t(name.GetBuffer()), _bstr_t(value.GetBuffer())); if (*pEnd != '\0') pEnd++; pStart = pEnd; } } return S_OK; } -----Original Message----- From: fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com [mailto:fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com] On Behalf Of Tom Bowden Sent: Wednesday, December 09, 2009 1:18 PM To: FastCGI Developers Subject: [FASTCGI] Cookie processing in Fast CGI Is there a thread somewhere that talks about parsing cookies - or, is this something that I have to treat like any other header parsing task. Tom _______________________________________________ FastCGI-developers mailing list FastCGI-developers at mailman.fastcgi.com http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: CookieCollection.h URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Cookie.cpp URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Cookie.h URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: CookieCollection.cpp URL: From chapmanm at pixia.com Wed Dec 9 16:08:59 2009 From: chapmanm at pixia.com (Martin Chapman) Date: Wed, 9 Dec 2009 14:08:59 -0700 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> Message-ID: <85750C745B874A75B404810F47FB4E82@chapmanm64> Tom, I made a mistake in my last email. The first function should be as follows: STDMETHODIMP CRequest::ParseCookieString(BSTR sCookieString) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); HRESULT hr = S_OK; CString sSub; _bstr_t bstrCS(sCookieString); CString sCookieStringTemp = (TCHAR*) bstrCS; int nCount = 0; BOOL bInCookie = FALSE; CComPtr< ICookie> spCookie; hr = spCookie.CoCreateInstance(CLSID_Cookie); if (FAILED(hr)) return hr; while (AfxExtractSubString(sSub, sCookieStringTemp, nCount++, ';')) { int nPos = sSub.Find('='); if (nPos != -1) { CString sName = sSub.Left(nPos); sName.TrimLeft(); sName.TrimRight(); CString sValue = sSub.Mid(nPos + 1); if (sName.IsEmpty()) continue; // check for $Version if (sName.CompareNoCase("$Version") == 0) { // ignore for now... continue; } if (sValue.IsEmpty()) continue; if (sName[0] == '$') { // invalid cookie string if (!bInCookie) return E_FAIL; else { // add attribute to current cookie sName.TrimLeft('$'); hr = spCookie->AddAttribute(_bstr_t(sName.GetBuffer()), _bstr_t(sValue.GetBuffer())); if (FAILED(hr)) return hr; } } else { if (!bInCookie) { bInCookie = TRUE; hr = spCookie->put_Name(_bstr_t(sName.GetBuffer())); if (FAILED(hr)) return hr; hr = spCookie->ParseValue(_bstr_t(sValue.GetBuffer())); if (FAILED(hr)) return hr; } else { // add previous cookie _bstr_t sPreviousName; hr = spCookie->get_Name(sPreviousName.GetAddress()); if (FAILED(hr)) return hr; long nIndexOf = 0L; hr = m_spCookies->Add(spCookie, &nIndexOf); if (FAILED(hr)) return hr; // empty current cookie and start over hr = spCookie->Empty(); if (FAILED(hr)) return hr; hr = spCookie->put_Name(_bstr_t(sName.GetBuffer())); if (FAILED(hr)) return hr; hr = spCookie->ParseValue(_bstr_t(sValue.GetBuffer())); if (FAILED(hr)) return hr; } } } } VARIANT_BOOL bIsEmpty = VARIANT_FALSE; hr = spCookie->IsEmpty(&bIsEmpty); if (FAILED(hr)) return hr; if (bIsEmpty == VARIANT_FALSE) { _bstr_t sName; hr = spCookie->get_Name(sName.GetAddress()); if (FAILED(hr)) return hr; long nIndexOf = 0L; hr = m_spCookies->Add(spCookie, &nIndexOf); if (FAILED(hr)) return hr; } return S_OK; } -----Original Message----- From: fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com [mailto:fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com] On Behalf Of Martin Chapman Sent: Wednesday, December 09, 2009 2:02 PM To: 'Tom Bowden'; 'FastCGI Developers' Subject: Re: [FASTCGI] Cookie processing in Fast CGI Tom, It's a little ugly because it's COM and if you convert it to FastCGI it would be cool if you posted it back for the rest of us if you can. The entire COM implementation is attached. General Gist: 1. Get the cookie from the env vars. Should be called HTTP_COOKIE. 2. Use a method like the one below to parse the cookie value. STDMETHODIMP CCookie::ParseValue(BSTR sCookie) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); _bstr_t bstrCookie(sCookie); if (bstrCookie.length() == 0) return E_INVALIDARG; CString strCookie = (TCHAR*) bstrCookie; LPCSTR pEnd = strCookie; LPCSTR pStart = strCookie; CString name, value; while (*pEnd != '\0') { while (*pEnd && *pEnd != '=' && *pEnd != '&') pEnd++; if (*pEnd == '\0' || *pEnd == '&') { if (pEnd > pStart) { CopyToCString(value, pStart, pEnd); } put_Value(_bstr_t(value.GetBuffer())); if (*pEnd == '&') { pEnd++; pStart = pEnd; continue; } return S_OK; } else if (*pEnd == '=' ) { if (pEnd > pStart) { CopyToCString(name, pStart, pEnd); } else { pEnd++; pStart = pEnd; break; } pEnd++; pStart = pEnd; while (*pEnd && *pEnd != '&' && *pEnd != '=') pEnd++; if (pEnd > pStart) CopyToCString(value, pStart, pEnd); AddValue(_bstr_t(name.GetBuffer()), _bstr_t(value.GetBuffer())); if (*pEnd != '\0') pEnd++; pStart = pEnd; } } return S_OK; } 3. The following func parses a single cookie value and is used in the func above. STDMETHODIMP CCookie::ParseValue(BSTR sCookie) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); _bstr_t bstrCookie(sCookie); if (bstrCookie.length() == 0) return E_INVALIDARG; CString strCookie = (TCHAR*) bstrCookie; LPCSTR pEnd = strCookie; LPCSTR pStart = strCookie; CString name, value; while (*pEnd != '\0') { while (*pEnd && *pEnd != '=' && *pEnd != '&') pEnd++; if (*pEnd == '\0' || *pEnd == '&') { if (pEnd > pStart) { CopyToCString(value, pStart, pEnd); } put_Value(_bstr_t(value.GetBuffer())); if (*pEnd == '&') { pEnd++; pStart = pEnd; continue; } return S_OK; } else if (*pEnd == '=' ) { if (pEnd > pStart) { CopyToCString(name, pStart, pEnd); } else { pEnd++; pStart = pEnd; break; } pEnd++; pStart = pEnd; while (*pEnd && *pEnd != '&' && *pEnd != '=') pEnd++; if (pEnd > pStart) CopyToCString(value, pStart, pEnd); AddValue(_bstr_t(name.GetBuffer()), _bstr_t(value.GetBuffer())); if (*pEnd != '\0') pEnd++; pStart = pEnd; } } return S_OK; } -----Original Message----- From: fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com [mailto:fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com] On Behalf Of Tom Bowden Sent: Wednesday, December 09, 2009 1:18 PM To: FastCGI Developers Subject: [FASTCGI] Cookie processing in Fast CGI Is there a thread somewhere that talks about parsing cookies - or, is this something that I have to treat like any other header parsing task. Tom _______________________________________________ FastCGI-developers mailing list FastCGI-developers at mailman.fastcgi.com http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers From charles_thomas at mac.com Wed Dec 9 16:34:33 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Wed, 09 Dec 2009 15:34:33 -0600 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> Message-ID: <104D293C-5EFD-4073-BC0D-55DC06434745@mac.com> will post with pleasure. Thanks! Tom On Dec 9, 2009, at 3:02 PM, Martin Chapman wrote: > Tom, > > It's a little ugly because it's COM and if you convert it to > FastCGI it > would be cool if you posted it back for the rest of us if you can. > The > entire COM implementation is attached. > > General Gist: > > 1. Get the cookie from the env vars. Should be called HTTP_COOKIE. > > 2. Use a method like the one below to parse the cookie value. > > STDMETHODIMP CCookie::ParseValue(BSTR sCookie) > { > AFX_MANAGE_STATE(AfxGetStaticModuleState()); > > _bstr_t bstrCookie(sCookie); > if (bstrCookie.length() == 0) > return E_INVALIDARG; > > CString strCookie = (TCHAR*) bstrCookie; > LPCSTR pEnd = strCookie; > LPCSTR pStart = strCookie; > CString name, value; > > while (*pEnd != '\0') > { > while (*pEnd && *pEnd != '=' && *pEnd != '&') > pEnd++; > > if (*pEnd == '\0' || *pEnd == '&') > { > if (pEnd > pStart) > { > CopyToCString(value, pStart, pEnd); > } > put_Value(_bstr_t(value.GetBuffer())); > if (*pEnd == '&') > { > pEnd++; > pStart = pEnd; > continue; > } > return S_OK; > } > else if (*pEnd == '=' ) > { > if (pEnd > pStart) > { > CopyToCString(name, pStart, pEnd); > } > else > { > pEnd++; > pStart = pEnd; > break; > } > > pEnd++; > pStart = pEnd; > while (*pEnd && *pEnd != '&' && *pEnd != '=') > pEnd++; > if (pEnd > pStart) > CopyToCString(value, pStart, pEnd); > > AddValue(_bstr_t(name.GetBuffer()), > _bstr_t(value.GetBuffer())); > if (*pEnd != '\0') > pEnd++; > > pStart = pEnd; > } > } > > return S_OK; > } > > 3. The following func parses a single cookie value and is used in > the func > above. > > STDMETHODIMP CCookie::ParseValue(BSTR sCookie) > { > AFX_MANAGE_STATE(AfxGetStaticModuleState()); > > _bstr_t bstrCookie(sCookie); > if (bstrCookie.length() == 0) > return E_INVALIDARG; > > CString strCookie = (TCHAR*) bstrCookie; > LPCSTR pEnd = strCookie; > LPCSTR pStart = strCookie; > CString name, value; > > while (*pEnd != '\0') > { > while (*pEnd && *pEnd != '=' && *pEnd != '&') > pEnd++; > > if (*pEnd == '\0' || *pEnd == '&') > { > if (pEnd > pStart) > { > CopyToCString(value, pStart, pEnd); > } > put_Value(_bstr_t(value.GetBuffer())); > if (*pEnd == '&') > { > pEnd++; > pStart = pEnd; > continue; > } > return S_OK; > } > else > if (*pEnd == '=' ) > { > if (pEnd > pStart) > { > CopyToCString(name, pStart, pEnd); > } > else > { > pEnd++; > pStart = pEnd; > break; > } > > pEnd++; > pStart = pEnd; > while (*pEnd && *pEnd != '&' && *pEnd != '=') > pEnd++; > if (pEnd > pStart) > CopyToCString(value, pStart, pEnd); > > AddValue(_bstr_t(name.GetBuffer()), > _bstr_t(value.GetBuffer())); > if (*pEnd != '\0') > pEnd++; > > pStart = pEnd; > } > } > > return S_OK; > } > > > -----Original Message----- > From: fastcgi-developers-bounces > +chapmanm=pixia.com at mailman.fastcgi.com > [mailto:fastcgi-developers-bounces > +chapmanm=pixia.com at mailman.fastcgi.com] > On Behalf Of Tom Bowden > Sent: Wednesday, December 09, 2009 1:18 PM > To: FastCGI Developers > Subject: [FASTCGI] Cookie processing in Fast CGI > > Is there a thread somewhere that talks about parsing cookies - or, is > this something that I have to treat like any other header parsing > task. > > Tom > > _______________________________________________ > FastCGI-developers mailing list > FastCGI-developers at mailman.fastcgi.com > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi- > developers cpp> From rclemley at booksys.com Wed Dec 9 19:24:31 2009 From: rclemley at booksys.com (Rob Lemley) Date: Wed, 09 Dec 2009 18:24:31 -0600 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: <104D293C-5EFD-4073-BC0D-55DC06434745@mac.com> References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> <104D293C-5EFD-4073-BC0D-55DC06434745@mac.com> Message-ID: <4B203FBF.1000100@booksys.com> I'd recommend having rfc2109 and rfc2965 handy. Also note that the Content-Disposition header is very similar to the Cookie header, ie would be common code. Rob Tom Bowden wrote: > will post with pleasure. Thanks! > > Tom > > On Dec 9, 2009, at 3:02 PM, Martin Chapman wrote: > >> Tom, >> >> It's a little ugly because it's COM and if you convert it to FastCGI it >> would be cool if you posted it back for the rest of us if you can. The >> entire COM implementation is attached. >> >> General Gist: >> >> 1. Get the cookie from the env vars. Should be called HTTP_COOKIE. >> >> 2. Use a method like the one below to parse the cookie value. >> >> STDMETHODIMP CCookie::ParseValue(BSTR sCookie) >> { >> AFX_MANAGE_STATE(AfxGetStaticModuleState()); >> >> _bstr_t bstrCookie(sCookie); >> if (bstrCookie.length() == 0) >> return E_INVALIDARG; >> >> CString strCookie = (TCHAR*) bstrCookie; >> LPCSTR pEnd = strCookie; >> LPCSTR pStart = strCookie; >> CString name, value; >> >> while (*pEnd != '\0') >> { >> while (*pEnd && *pEnd != '=' && *pEnd != '&') >> pEnd++; >> >> if (*pEnd == '\0' || *pEnd == '&') >> { >> if (pEnd > pStart) >> { >> CopyToCString(value, pStart, pEnd); >> } >> put_Value(_bstr_t(value.GetBuffer())); >> if (*pEnd == '&') >> { >> pEnd++; >> pStart = pEnd; >> continue; >> } >> return S_OK; >> } >> else if (*pEnd == '=' ) >> { >> if (pEnd > pStart) >> { >> CopyToCString(name, pStart, pEnd); >> } >> else >> { >> pEnd++; >> pStart = pEnd; >> break; >> } >> >> pEnd++; >> pStart = pEnd; >> while (*pEnd && *pEnd != '&' && *pEnd != '=') >> pEnd++; >> if (pEnd > pStart) >> CopyToCString(value, pStart, pEnd); >> >> AddValue(_bstr_t(name.GetBuffer()), >> _bstr_t(value.GetBuffer())); >> if (*pEnd != '\0') >> pEnd++; >> >> pStart = pEnd; >> } >> } >> >> return S_OK; >> } >> >> 3. The following func parses a single cookie value and is used in the >> func >> above. >> >> STDMETHODIMP CCookie::ParseValue(BSTR sCookie) >> { >> AFX_MANAGE_STATE(AfxGetStaticModuleState()); >> >> _bstr_t bstrCookie(sCookie); >> if (bstrCookie.length() == 0) >> return E_INVALIDARG; >> >> CString strCookie = (TCHAR*) bstrCookie; >> LPCSTR pEnd = strCookie; >> LPCSTR pStart = strCookie; >> CString name, value; >> >> while (*pEnd != '\0') >> { >> while (*pEnd && *pEnd != '=' && *pEnd != '&') >> pEnd++; >> >> if (*pEnd == '\0' || *pEnd == '&') >> { >> if (pEnd > pStart) >> { >> CopyToCString(value, pStart, pEnd); >> } >> put_Value(_bstr_t(value.GetBuffer())); >> if (*pEnd == '&') >> { >> pEnd++; >> pStart = pEnd; >> continue; >> } >> return S_OK; >> } >> else >> if (*pEnd == '=' ) >> { >> if (pEnd > pStart) >> { >> CopyToCString(name, pStart, pEnd); >> } >> else >> { >> pEnd++; >> pStart = pEnd; >> break; >> } >> >> pEnd++; >> pStart = pEnd; >> while (*pEnd && *pEnd != '&' && *pEnd != '=') >> pEnd++; >> if (pEnd > pStart) >> CopyToCString(value, pStart, pEnd); >> >> AddValue(_bstr_t(name.GetBuffer()), >> _bstr_t(value.GetBuffer())); >> if (*pEnd != '\0') >> pEnd++; >> >> pStart = pEnd; >> } >> } >> >> return S_OK; >> } >> >> >> -----Original Message----- >> From: fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com >> [mailto:fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com] >> >> On Behalf Of Tom Bowden >> Sent: Wednesday, December 09, 2009 1:18 PM >> To: FastCGI Developers >> Subject: [FASTCGI] Cookie processing in Fast CGI >> >> Is there a thread somewhere that talks about parsing cookies - or, is >> this something that I have to treat like any other header parsing task. >> >> Tom >> >> _______________________________________________ >> FastCGI-developers mailing list >> FastCGI-developers at mailman.fastcgi.com >> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers >> > > _______________________________________________ > FastCGI-developers mailing list > FastCGI-developers at mailman.fastcgi.com > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers > > From charles_thomas at mac.com Thu Dec 10 14:54:17 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Thu, 10 Dec 2009 13:54:17 -0600 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: <4B203FBF.1000100@booksys.com> References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> <104D293C-5EFD-4073-BC0D-55DC06434745@mac.com> <4B203FBF.1000100@booksys.com> Message-ID: I was noticing that output in my fastcgi stuff yesterday. I use curl a lot for transfering between daemons/sysetms/postgres/etc., and I had a script that sent data as fields... it surprised me to see the Content-Disposition headers... but I can see where it would be common code. There is another thing I learned yesterday from what Jay pointed me to (wikipedia). Apparently every browser window/tab has a property (window.name) that can contain up to 32mb of data (like a json structure,etc.). The page recommended that as an alternative to session cookies. of course this is neither here nor there... but it speaks to what I am trying to do with this whole system. I have a context that is maintained in a c++ application/postgres that needs to be updated regularly with a context on the browser. The cookies are for persistent storage of login/session/context identifiers. With Respect to this common cookie stuff that I am writing; - I write in linux, using stl. So I can emulate a lot of the HTTP object that the com object is using with maps/vectors.... at least at the cookie level. - when it comes to the cookie jar (CookieContainer class) functionality, I usually use a JSON structure/library - and have written/acquired json objects in everything (C, C++, postgres, javascript (duh), and php). Since this is C++, and because I would get warm fuzzies if others can actually use it -- any problems with my favorite package (jsoncpp -- http://jsoncpp.sourceforge.net) ? As far as basic structure goes, I'll have an interface class that is then inherited by either a cookie object or a Content disposition object. the interface class (which is not a pure interface) will implement the container object -- so that the *Container can hold both cookies and the 'other' objects that inherit the interface. Tom On Dec 9, 2009, at 6:24 PM, Rob Lemley wrote: > I'd recommend having rfc2109 and rfc2965 handy. > > Also note that the Content-Disposition header is very similar to the > Cookie header, ie would be common code. > > Rob > > > Tom Bowden wrote: >> will post with pleasure. Thanks! >> >> Tom >> >> On Dec 9, 2009, at 3:02 PM, Martin Chapman wrote: >> >>> Tom, >>> >>> It's a little ugly because it's COM and if you convert it to >>> FastCGI it >>> would be cool if you posted it back for the rest of us if you >>> can. The >>> entire COM implementation is attached. >>> >>> General Gist: >>> >>> 1. Get the cookie from the env vars. Should be called HTTP_COOKIE. >>> >>> 2. Use a method like the one below to parse the cookie value. >>> >>> STDMETHODIMP CCookie::ParseValue(BSTR sCookie) >>> { >>> AFX_MANAGE_STATE(AfxGetStaticModuleState()); >>> >>> _bstr_t bstrCookie(sCookie); >>> if (bstrCookie.length() == 0) >>> return E_INVALIDARG; >>> >>> CString strCookie = (TCHAR*) bstrCookie; >>> LPCSTR pEnd = strCookie; >>> LPCSTR pStart = strCookie; >>> CString name, value; >>> >>> while (*pEnd != '\0') >>> { >>> while (*pEnd && *pEnd != '=' && *pEnd != '&') >>> pEnd++; >>> >>> if (*pEnd == '\0' || *pEnd == '&') >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(value, pStart, pEnd); >>> } >>> put_Value(_bstr_t(value.GetBuffer())); >>> if (*pEnd == '&') >>> { >>> pEnd++; >>> pStart = pEnd; >>> continue; >>> } >>> return S_OK; >>> } >>> else if (*pEnd == '=' ) >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(name, pStart, pEnd); >>> } >>> else >>> { >>> pEnd++; >>> pStart = pEnd; >>> break; >>> } >>> >>> pEnd++; >>> pStart = pEnd; >>> while (*pEnd && *pEnd != '&' && *pEnd != '=') >>> pEnd++; >>> if (pEnd > pStart) >>> CopyToCString(value, pStart, pEnd); >>> >>> AddValue(_bstr_t(name.GetBuffer()), >>> _bstr_t(value.GetBuffer())); >>> if (*pEnd != '\0') >>> pEnd++; >>> >>> pStart = pEnd; >>> } >>> } >>> >>> return S_OK; >>> } >>> >>> 3. The following func parses a single cookie value and is used in >>> the >>> func >>> above. >>> >>> STDMETHODIMP CCookie::ParseValue(BSTR sCookie) >>> { >>> AFX_MANAGE_STATE(AfxGetStaticModuleState()); >>> >>> _bstr_t bstrCookie(sCookie); >>> if (bstrCookie.length() == 0) >>> return E_INVALIDARG; >>> >>> CString strCookie = (TCHAR*) bstrCookie; >>> LPCSTR pEnd = strCookie; >>> LPCSTR pStart = strCookie; >>> CString name, value; >>> >>> while (*pEnd != '\0') >>> { >>> while (*pEnd && *pEnd != '=' && *pEnd != '&') >>> pEnd++; >>> >>> if (*pEnd == '\0' || *pEnd == '&') >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(value, pStart, pEnd); >>> } >>> put_Value(_bstr_t(value.GetBuffer())); >>> if (*pEnd == '&') >>> { >>> pEnd++; >>> pStart = pEnd; >>> continue; >>> } >>> return S_OK; >>> } >>> else >>> if (*pEnd == '=' ) >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(name, pStart, pEnd); >>> } >>> else >>> { >>> pEnd++; >>> pStart = pEnd; >>> break; >>> } >>> >>> pEnd++; >>> pStart = pEnd; >>> while (*pEnd && *pEnd != '&' && *pEnd != '=') >>> pEnd++; >>> if (pEnd > pStart) >>> CopyToCString(value, pStart, pEnd); >>> >>> AddValue(_bstr_t(name.GetBuffer()), >>> _bstr_t(value.GetBuffer())); >>> if (*pEnd != '\0') >>> pEnd++; >>> >>> pStart = pEnd; >>> } >>> } >>> >>> return S_OK; >>> } >>> >>> >>> -----Original Message----- >>> From: fastcgi-developers-bounces >>> +chapmanm=pixia.com at mailman.fastcgi.com >>> [mailto:fastcgi-developers-bounces >>> +chapmanm=pixia.com at mailman.fastcgi.com] >>> >>> On Behalf Of Tom Bowden >>> Sent: Wednesday, December 09, 2009 1:18 PM >>> To: FastCGI Developers >>> Subject: [FASTCGI] Cookie processing in Fast CGI >>> >>> Is there a thread somewhere that talks about parsing cookies - >>> or, is >>> this something that I have to treat like any other header parsing >>> task. >>> >>> Tom >>> >>> _______________________________________________ >>> FastCGI-developers mailing list >>> FastCGI-developers at mailman.fastcgi.com >>> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi- >>> developers>> n.cpp> >>> >> >> _______________________________________________ >> FastCGI-developers mailing list >> FastCGI-developers at mailman.fastcgi.com >> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers >> >> > From charles_thomas at mac.com Thu Dec 10 15:16:39 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Thu, 10 Dec 2009 14:16:39 -0600 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: <4B203FBF.1000100@booksys.com> References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> <104D293C-5EFD-4073-BC0D-55DC06434745@mac.com> <4B203FBF.1000100@booksys.com> Message-ID: The two rfc's you mention below are for Set-Cookie and Set-Cookie2. I presume the Set-Cookie2 is for sending multiple cookies in one header? Is that widely accepted? Also -- do you know which RFC includes the Content-Disposition spec? On Dec 9, 2009, at 6:24 PM, Rob Lemley wrote: > I'd recommend having rfc2109 and rfc2965 handy. > > Also note that the Content-Disposition header is very similar to the > Cookie header, ie would be common code. > > Rob > > > Tom Bowden wrote: >> will post with pleasure. Thanks! >> >> Tom >> >> On Dec 9, 2009, at 3:02 PM, Martin Chapman wrote: >> >>> Tom, >>> >>> It's a little ugly because it's COM and if you convert it to >>> FastCGI it >>> would be cool if you posted it back for the rest of us if you >>> can. The >>> entire COM implementation is attached. >>> >>> General Gist: >>> >>> 1. Get the cookie from the env vars. Should be called HTTP_COOKIE. >>> >>> 2. Use a method like the one below to parse the cookie value. >>> >>> STDMETHODIMP CCookie::ParseValue(BSTR sCookie) >>> { >>> AFX_MANAGE_STATE(AfxGetStaticModuleState()); >>> >>> _bstr_t bstrCookie(sCookie); >>> if (bstrCookie.length() == 0) >>> return E_INVALIDARG; >>> >>> CString strCookie = (TCHAR*) bstrCookie; >>> LPCSTR pEnd = strCookie; >>> LPCSTR pStart = strCookie; >>> CString name, value; >>> >>> while (*pEnd != '\0') >>> { >>> while (*pEnd && *pEnd != '=' && *pEnd != '&') >>> pEnd++; >>> >>> if (*pEnd == '\0' || *pEnd == '&') >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(value, pStart, pEnd); >>> } >>> put_Value(_bstr_t(value.GetBuffer())); >>> if (*pEnd == '&') >>> { >>> pEnd++; >>> pStart = pEnd; >>> continue; >>> } >>> return S_OK; >>> } >>> else if (*pEnd == '=' ) >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(name, pStart, pEnd); >>> } >>> else >>> { >>> pEnd++; >>> pStart = pEnd; >>> break; >>> } >>> >>> pEnd++; >>> pStart = pEnd; >>> while (*pEnd && *pEnd != '&' && *pEnd != '=') >>> pEnd++; >>> if (pEnd > pStart) >>> CopyToCString(value, pStart, pEnd); >>> >>> AddValue(_bstr_t(name.GetBuffer()), >>> _bstr_t(value.GetBuffer())); >>> if (*pEnd != '\0') >>> pEnd++; >>> >>> pStart = pEnd; >>> } >>> } >>> >>> return S_OK; >>> } >>> >>> 3. The following func parses a single cookie value and is used in >>> the >>> func >>> above. >>> >>> STDMETHODIMP CCookie::ParseValue(BSTR sCookie) >>> { >>> AFX_MANAGE_STATE(AfxGetStaticModuleState()); >>> >>> _bstr_t bstrCookie(sCookie); >>> if (bstrCookie.length() == 0) >>> return E_INVALIDARG; >>> >>> CString strCookie = (TCHAR*) bstrCookie; >>> LPCSTR pEnd = strCookie; >>> LPCSTR pStart = strCookie; >>> CString name, value; >>> >>> while (*pEnd != '\0') >>> { >>> while (*pEnd && *pEnd != '=' && *pEnd != '&') >>> pEnd++; >>> >>> if (*pEnd == '\0' || *pEnd == '&') >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(value, pStart, pEnd); >>> } >>> put_Value(_bstr_t(value.GetBuffer())); >>> if (*pEnd == '&') >>> { >>> pEnd++; >>> pStart = pEnd; >>> continue; >>> } >>> return S_OK; >>> } >>> else >>> if (*pEnd == '=' ) >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(name, pStart, pEnd); >>> } >>> else >>> { >>> pEnd++; >>> pStart = pEnd; >>> break; >>> } >>> >>> pEnd++; >>> pStart = pEnd; >>> while (*pEnd && *pEnd != '&' && *pEnd != '=') >>> pEnd++; >>> if (pEnd > pStart) >>> CopyToCString(value, pStart, pEnd); >>> >>> AddValue(_bstr_t(name.GetBuffer()), >>> _bstr_t(value.GetBuffer())); >>> if (*pEnd != '\0') >>> pEnd++; >>> >>> pStart = pEnd; >>> } >>> } >>> >>> return S_OK; >>> } >>> >>> >>> -----Original Message----- >>> From: fastcgi-developers-bounces >>> +chapmanm=pixia.com at mailman.fastcgi.com >>> [mailto:fastcgi-developers-bounces >>> +chapmanm=pixia.com at mailman.fastcgi.com] >>> >>> On Behalf Of Tom Bowden >>> Sent: Wednesday, December 09, 2009 1:18 PM >>> To: FastCGI Developers >>> Subject: [FASTCGI] Cookie processing in Fast CGI >>> >>> Is there a thread somewhere that talks about parsing cookies - >>> or, is >>> this something that I have to treat like any other header parsing >>> task. >>> >>> Tom >>> >>> _______________________________________________ >>> FastCGI-developers mailing list >>> FastCGI-developers at mailman.fastcgi.com >>> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi- >>> developers>> n.cpp> >>> >> >> _______________________________________________ >> FastCGI-developers mailing list >> FastCGI-developers at mailman.fastcgi.com >> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers >> >> > From chapmanm at pixia.com Thu Dec 10 15:19:11 2009 From: chapmanm at pixia.com (Martin Chapman) Date: Thu, 10 Dec 2009 13:19:11 -0700 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> <104D293C-5EFD-4073-BC0D-55DC06434745@mac.com> <4B203FBF.1000100@booksys.com> Message-ID: <58BC5E8025134A1E827A366E7A732327@chapmanm64> Check out: Http 1.0 master - http://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html Http 1.1 master - http://www.w3.org/Protocols/rfc2616/rfc2616.html Martin -----Original Message----- From: Tom Bowden [mailto:charles_thomas at mac.com] Sent: Thursday, December 10, 2009 1:17 PM To: Rob Lemley Cc: Martin Chapman; 'FastCGI Developers' Subject: Re: [FASTCGI] Cookie processing in Fast CGI The two rfc's you mention below are for Set-Cookie and Set-Cookie2. I presume the Set-Cookie2 is for sending multiple cookies in one header? Is that widely accepted? Also -- do you know which RFC includes the Content-Disposition spec? On Dec 9, 2009, at 6:24 PM, Rob Lemley wrote: > I'd recommend having rfc2109 and rfc2965 handy. > > Also note that the Content-Disposition header is very similar to the > Cookie header, ie would be common code. > > Rob > > > Tom Bowden wrote: >> will post with pleasure. Thanks! >> >> Tom >> >> On Dec 9, 2009, at 3:02 PM, Martin Chapman wrote: >> >>> Tom, >>> >>> It's a little ugly because it's COM and if you convert it to >>> FastCGI it >>> would be cool if you posted it back for the rest of us if you >>> can. The >>> entire COM implementation is attached. >>> >>> General Gist: >>> >>> 1. Get the cookie from the env vars. Should be called HTTP_COOKIE. >>> >>> 2. Use a method like the one below to parse the cookie value. >>> >>> STDMETHODIMP CCookie::ParseValue(BSTR sCookie) >>> { >>> AFX_MANAGE_STATE(AfxGetStaticModuleState()); >>> >>> _bstr_t bstrCookie(sCookie); >>> if (bstrCookie.length() == 0) >>> return E_INVALIDARG; >>> >>> CString strCookie = (TCHAR*) bstrCookie; >>> LPCSTR pEnd = strCookie; >>> LPCSTR pStart = strCookie; >>> CString name, value; >>> >>> while (*pEnd != '\0') >>> { >>> while (*pEnd && *pEnd != '=' && *pEnd != '&') >>> pEnd++; >>> >>> if (*pEnd == '\0' || *pEnd == '&') >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(value, pStart, pEnd); >>> } >>> put_Value(_bstr_t(value.GetBuffer())); >>> if (*pEnd == '&') >>> { >>> pEnd++; >>> pStart = pEnd; >>> continue; >>> } >>> return S_OK; >>> } >>> else if (*pEnd == '=' ) >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(name, pStart, pEnd); >>> } >>> else >>> { >>> pEnd++; >>> pStart = pEnd; >>> break; >>> } >>> >>> pEnd++; >>> pStart = pEnd; >>> while (*pEnd && *pEnd != '&' && *pEnd != '=') >>> pEnd++; >>> if (pEnd > pStart) >>> CopyToCString(value, pStart, pEnd); >>> >>> AddValue(_bstr_t(name.GetBuffer()), >>> _bstr_t(value.GetBuffer())); >>> if (*pEnd != '\0') >>> pEnd++; >>> >>> pStart = pEnd; >>> } >>> } >>> >>> return S_OK; >>> } >>> >>> 3. The following func parses a single cookie value and is used in >>> the >>> func >>> above. >>> >>> STDMETHODIMP CCookie::ParseValue(BSTR sCookie) >>> { >>> AFX_MANAGE_STATE(AfxGetStaticModuleState()); >>> >>> _bstr_t bstrCookie(sCookie); >>> if (bstrCookie.length() == 0) >>> return E_INVALIDARG; >>> >>> CString strCookie = (TCHAR*) bstrCookie; >>> LPCSTR pEnd = strCookie; >>> LPCSTR pStart = strCookie; >>> CString name, value; >>> >>> while (*pEnd != '\0') >>> { >>> while (*pEnd && *pEnd != '=' && *pEnd != '&') >>> pEnd++; >>> >>> if (*pEnd == '\0' || *pEnd == '&') >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(value, pStart, pEnd); >>> } >>> put_Value(_bstr_t(value.GetBuffer())); >>> if (*pEnd == '&') >>> { >>> pEnd++; >>> pStart = pEnd; >>> continue; >>> } >>> return S_OK; >>> } >>> else >>> if (*pEnd == '=' ) >>> { >>> if (pEnd > pStart) >>> { >>> CopyToCString(name, pStart, pEnd); >>> } >>> else >>> { >>> pEnd++; >>> pStart = pEnd; >>> break; >>> } >>> >>> pEnd++; >>> pStart = pEnd; >>> while (*pEnd && *pEnd != '&' && *pEnd != '=') >>> pEnd++; >>> if (pEnd > pStart) >>> CopyToCString(value, pStart, pEnd); >>> >>> AddValue(_bstr_t(name.GetBuffer()), >>> _bstr_t(value.GetBuffer())); >>> if (*pEnd != '\0') >>> pEnd++; >>> >>> pStart = pEnd; >>> } >>> } >>> >>> return S_OK; >>> } >>> >>> >>> -----Original Message----- >>> From: fastcgi-developers-bounces >>> +chapmanm=pixia.com at mailman.fastcgi.com >>> [mailto:fastcgi-developers-bounces >>> +chapmanm=pixia.com at mailman.fastcgi.com] >>> >>> On Behalf Of Tom Bowden >>> Sent: Wednesday, December 09, 2009 1:18 PM >>> To: FastCGI Developers >>> Subject: [FASTCGI] Cookie processing in Fast CGI >>> >>> Is there a thread somewhere that talks about parsing cookies - >>> or, is >>> this something that I have to treat like any other header parsing >>> task. >>> >>> Tom >>> >>> _______________________________________________ >>> FastCGI-developers mailing list >>> FastCGI-developers at mailman.fastcgi.com >>> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi- >>> developers>> n.cpp> >>> >> >> _______________________________________________ >> FastCGI-developers mailing list >> FastCGI-developers at mailman.fastcgi.com >> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers >> >> > From jsprenkle at gmail.com Thu Dec 10 15:24:46 2009 From: jsprenkle at gmail.com (Jay Sprenkle) Date: Thu, 10 Dec 2009 14:24:46 -0600 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> <104D293C-5EFD-4073-BC0D-55DC06434745@mac.com> <4B203FBF.1000100@booksys.com> Message-ID: <1b5f39a10912101224n23a6e1c9v69296b0824792cca@mail.gmail.com> I'd like to see what you've written if you want to share it. When deciding on authentication methods you might look into 'cookie theft' . When doing connection based authentication using cookies on older browsers it makes it pretty difficult to ensure malicious people are kept out. I couldn't come up with a way to do it other than just making the authentication token expire so quickly that even if they got the cookie by the time they tried to use it the id would have expired. On Thu, Dec 10, 2009 at 1:54 PM, Tom Bowden wrote: > - when it comes to the cookie jar (CookieContainer class) functionality, I > usually use a JSON structure/library - and have written/acquired json > objects in everything (C, C++, postgres, javascript (duh), and php). Since > this is C++, and because I would get warm fuzzies if others can actually use > it -- any problems with my favorite package (jsoncpp -- > http://jsoncpp.sourceforge.net) ? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From charles_thomas at mac.com Thu Dec 10 15:30:54 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Thu, 10 Dec 2009 14:30:54 -0600 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> Message-ID: martin, A couple questions (compiled from previous post with an addition): I tend to use external libraries that make my life easier. Namely jsoncpp and pcrecpp. With pcrecpp i can (for example) replace the parsing the logic where you're going character by character with something like: #define PCRE_COOKIE_MASK "^Set-Cookie:[ \t]*([^=]+)=(.*)$" and then: std::string cookie_name; std::string cookie_value; if ( pcre_object->PartialMatch(instr, &cookie_name, &cookie_value) ) { // do assignment logic... } Obviously some times its not good to rely on third party libs (portability/etc). Is this one of those times? What would be most useful to the community? Tom On Dec 9, 2009, at 3:02 PM, Martin Chapman wrote: > Tom, > > It's a little ugly because it's COM and if you convert it to > FastCGI it > would be cool if you posted it back for the rest of us if you can. > The > entire COM implementation is attached. > > General Gist: > > 1. Get the cookie from the env vars. Should be called HTTP_COOKIE. > > 2. Use a method like the one below to parse the cookie value. > > STDMETHODIMP CCookie::ParseValue(BSTR sCookie) > { > AFX_MANAGE_STATE(AfxGetStaticModuleState()); > > _bstr_t bstrCookie(sCookie); > if (bstrCookie.length() == 0) > return E_INVALIDARG; > > CString strCookie = (TCHAR*) bstrCookie; > LPCSTR pEnd = strCookie; > LPCSTR pStart = strCookie; > CString name, value; > > while (*pEnd != '\0') > { > while (*pEnd && *pEnd != '=' && *pEnd != '&') > pEnd++; > > if (*pEnd == '\0' || *pEnd == '&') > { > if (pEnd > pStart) > { > CopyToCString(value, pStart, pEnd); > } > put_Value(_bstr_t(value.GetBuffer())); > if (*pEnd == '&') > { > pEnd++; > pStart = pEnd; > continue; > } > return S_OK; > } > else if (*pEnd == '=' ) > { > if (pEnd > pStart) > { > CopyToCString(name, pStart, pEnd); > } > else > { > pEnd++; > pStart = pEnd; > break; > } > > pEnd++; > pStart = pEnd; > while (*pEnd && *pEnd != '&' && *pEnd != '=') > pEnd++; > if (pEnd > pStart) > CopyToCString(value, pStart, pEnd); > > AddValue(_bstr_t(name.GetBuffer()), > _bstr_t(value.GetBuffer())); > if (*pEnd != '\0') > pEnd++; > > pStart = pEnd; > } > } > > return S_OK; > } > > 3. The following func parses a single cookie value and is used in > the func > above. > > STDMETHODIMP CCookie::ParseValue(BSTR sCookie) > { > AFX_MANAGE_STATE(AfxGetStaticModuleState()); > > _bstr_t bstrCookie(sCookie); > if (bstrCookie.length() == 0) > return E_INVALIDARG; > > CString strCookie = (TCHAR*) bstrCookie; > LPCSTR pEnd = strCookie; > LPCSTR pStart = strCookie; > CString name, value; > > while (*pEnd != '\0') > { > while (*pEnd && *pEnd != '=' && *pEnd != '&') > pEnd++; > > if (*pEnd == '\0' || *pEnd == '&') > { > if (pEnd > pStart) > { > CopyToCString(value, pStart, pEnd); > } > put_Value(_bstr_t(value.GetBuffer())); > if (*pEnd == '&') > { > pEnd++; > pStart = pEnd; > continue; > } > return S_OK; > } > else > if (*pEnd == '=' ) > { > if (pEnd > pStart) > { > CopyToCString(name, pStart, pEnd); > } > else > { > pEnd++; > pStart = pEnd; > break; > } > > pEnd++; > pStart = pEnd; > while (*pEnd && *pEnd != '&' && *pEnd != '=') > pEnd++; > if (pEnd > pStart) > CopyToCString(value, pStart, pEnd); > > AddValue(_bstr_t(name.GetBuffer()), > _bstr_t(value.GetBuffer())); > if (*pEnd != '\0') > pEnd++; > > pStart = pEnd; > } > } > > return S_OK; > } > > > -----Original Message----- > From: fastcgi-developers-bounces > +chapmanm=pixia.com at mailman.fastcgi.com > [mailto:fastcgi-developers-bounces > +chapmanm=pixia.com at mailman.fastcgi.com] > On Behalf Of Tom Bowden > Sent: Wednesday, December 09, 2009 1:18 PM > To: FastCGI Developers > Subject: [FASTCGI] Cookie processing in Fast CGI > > Is there a thread somewhere that talks about parsing cookies - or, is > this something that I have to treat like any other header parsing > task. > > Tom > > _______________________________________________ > FastCGI-developers mailing list > FastCGI-developers at mailman.fastcgi.com > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi- > developers cpp> From chapmanm at pixia.com Thu Dec 10 15:33:44 2009 From: chapmanm at pixia.com (Martin Chapman) Date: Thu, 10 Dec 2009 13:33:44 -0700 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> Message-ID: My opinion would be parse it yourself so it's not dependent. That said, it's your project so do what makes the most sense for you. Martin -----Original Message----- From: Tom Bowden [mailto:charles_thomas at mac.com] Sent: Thursday, December 10, 2009 1:31 PM To: Martin Chapman Cc: 'FastCGI Developers' Subject: Re: [FASTCGI] Cookie processing in Fast CGI martin, A couple questions (compiled from previous post with an addition): I tend to use external libraries that make my life easier. Namely jsoncpp and pcrecpp. With pcrecpp i can (for example) replace the parsing the logic where you're going character by character with something like: #define PCRE_COOKIE_MASK "^Set-Cookie:[ \t]*([^=]+)=(.*)$" and then: std::string cookie_name; std::string cookie_value; if ( pcre_object->PartialMatch(instr, &cookie_name, &cookie_value) ) { // do assignment logic... } Obviously some times its not good to rely on third party libs (portability/etc). Is this one of those times? What would be most useful to the community? Tom On Dec 9, 2009, at 3:02 PM, Martin Chapman wrote: > Tom, > > It's a little ugly because it's COM and if you convert it to > FastCGI it > would be cool if you posted it back for the rest of us if you can. > The > entire COM implementation is attached. > > General Gist: > > 1. Get the cookie from the env vars. Should be called HTTP_COOKIE. > > 2. Use a method like the one below to parse the cookie value. > > STDMETHODIMP CCookie::ParseValue(BSTR sCookie) > { > AFX_MANAGE_STATE(AfxGetStaticModuleState()); > > _bstr_t bstrCookie(sCookie); > if (bstrCookie.length() == 0) > return E_INVALIDARG; > > CString strCookie = (TCHAR*) bstrCookie; > LPCSTR pEnd = strCookie; > LPCSTR pStart = strCookie; > CString name, value; > > while (*pEnd != '\0') > { > while (*pEnd && *pEnd != '=' && *pEnd != '&') > pEnd++; > > if (*pEnd == '\0' || *pEnd == '&') > { > if (pEnd > pStart) > { > CopyToCString(value, pStart, pEnd); > } > put_Value(_bstr_t(value.GetBuffer())); > if (*pEnd == '&') > { > pEnd++; > pStart = pEnd; > continue; > } > return S_OK; > } > else if (*pEnd == '=' ) > { > if (pEnd > pStart) > { > CopyToCString(name, pStart, pEnd); > } > else > { > pEnd++; > pStart = pEnd; > break; > } > > pEnd++; > pStart = pEnd; > while (*pEnd && *pEnd != '&' && *pEnd != '=') > pEnd++; > if (pEnd > pStart) > CopyToCString(value, pStart, pEnd); > > AddValue(_bstr_t(name.GetBuffer()), > _bstr_t(value.GetBuffer())); > if (*pEnd != '\0') > pEnd++; > > pStart = pEnd; > } > } > > return S_OK; > } > > 3. The following func parses a single cookie value and is used in > the func > above. > > STDMETHODIMP CCookie::ParseValue(BSTR sCookie) > { > AFX_MANAGE_STATE(AfxGetStaticModuleState()); > > _bstr_t bstrCookie(sCookie); > if (bstrCookie.length() == 0) > return E_INVALIDARG; > > CString strCookie = (TCHAR*) bstrCookie; > LPCSTR pEnd = strCookie; > LPCSTR pStart = strCookie; > CString name, value; > > while (*pEnd != '\0') > { > while (*pEnd && *pEnd != '=' && *pEnd != '&') > pEnd++; > > if (*pEnd == '\0' || *pEnd == '&') > { > if (pEnd > pStart) > { > CopyToCString(value, pStart, pEnd); > } > put_Value(_bstr_t(value.GetBuffer())); > if (*pEnd == '&') > { > pEnd++; > pStart = pEnd; > continue; > } > return S_OK; > } > else > if (*pEnd == '=' ) > { > if (pEnd > pStart) > { > CopyToCString(name, pStart, pEnd); > } > else > { > pEnd++; > pStart = pEnd; > break; > } > > pEnd++; > pStart = pEnd; > while (*pEnd && *pEnd != '&' && *pEnd != '=') > pEnd++; > if (pEnd > pStart) > CopyToCString(value, pStart, pEnd); > > AddValue(_bstr_t(name.GetBuffer()), > _bstr_t(value.GetBuffer())); > if (*pEnd != '\0') > pEnd++; > > pStart = pEnd; > } > } > > return S_OK; > } > > > -----Original Message----- > From: fastcgi-developers-bounces > +chapmanm=pixia.com at mailman.fastcgi.com > [mailto:fastcgi-developers-bounces > +chapmanm=pixia.com at mailman.fastcgi.com] > On Behalf Of Tom Bowden > Sent: Wednesday, December 09, 2009 1:18 PM > To: FastCGI Developers > Subject: [FASTCGI] Cookie processing in Fast CGI > > Is there a thread somewhere that talks about parsing cookies - or, is > this something that I have to treat like any other header parsing > task. > > Tom > > _______________________________________________ > FastCGI-developers mailing list > FastCGI-developers at mailman.fastcgi.com > http://mailman.pins.net/mailman/listinfo.cgi/fastcgi- > developers cpp> From charles_thomas at mac.com Thu Dec 10 15:45:17 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Thu, 10 Dec 2009 14:45:17 -0600 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: <1b5f39a10912101224n23a6e1c9v69296b0824792cca@mail.gmail.com> References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> <104D293C-5EFD-4073-BC0D-55DC06434745@mac.com> <4B203FBF.1000100@booksys.com> <1b5f39a10912101224n23a6e1c9v69296b0824792cca@mail.gmail.com> Message-ID: <70BFCF7D-A48B-4E9E-8F84-AF06D9A90552@mac.com> absolutely! On Dec 10, 2009, at 2:24 PM, Jay Sprenkle wrote: > I'd like to see what you've written if you want to share it. > > When deciding on authentication methods you might look into 'cookie > theft' . When doing connection based authentication using cookies > on older browsers it makes it pretty difficult to ensure malicious > people are kept out. I couldn't come up with a way to do it other > than just making the authentication token expire so quickly that > even if they got the cookie by the time they tried to use it the id > would have expired. > > > On Thu, Dec 10, 2009 at 1:54 PM, Tom Bowden > wrote: > - when it comes to the cookie jar (CookieContainer class) > functionality, I usually use a JSON structure/library - and have > written/acquired json objects in everything (C, C++, postgres, > javascript (duh), and php). Since this is C++, and because I > would get warm fuzzies if others can actually use it -- any > problems with my favorite package (jsoncpp -- http:// > jsoncpp.sourceforge.net) ? > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From charles_thomas at mac.com Thu Dec 10 18:01:38 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Thu, 10 Dec 2009 17:01:38 -0600 Subject: [FASTCGI] fastcgi stability Message-ID: <67BB4CD9-C79D-4C87-B4FF-14322E9BC692@mac.com> i was just looking through the fastcgi source code and noticed that the timestamps are from 2002/2001 -- as well as the checkout/ $Id tags. That's fricking amazing. Tom From bil at corry.biz Fri Dec 11 04:08:02 2009 From: bil at corry.biz (Bil Corry) Date: Fri, 11 Dec 2009 01:08:02 -0800 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> <104D293C-5EFD-4073-BC0D-55DC06434745@mac.com> <4B203FBF.1000100@booksys.com> Message-ID: <4B220BF2.90104@corry.biz> Cookies were originally created by Netscape, then RFC2109 made it a formal specification, and RFC2965 superseded RFC2109 to fix certain issues and extend the functionality. But in practice, the browser vendors ignored all of the specifications and did their own thing, mostly driven by the behavior of other browsers along with how servers actually provided Set-Cookie. Currently, there doesn't exist a specification for cookies that actually tells you how to implement it as to be compatible with the major UAs. We're in midsts of forming an official IETF working group that will produce such a RFC, our mailing list and draft specification (not complete) are here: http://www.ietf.org/mail-archive/web/http-state/current/maillist.html http://tools.ietf.org/html/draft-abarth-cookie As for Set-Cookie2, only Opera supports it (IIRC) and isn't used except by a small number of sites. I wouldn't work too hard to support it at this time. - Bil Tom Bowden wrote on 12/10/2009 12:16 PM: > The two rfc's you mention below are for Set-Cookie and Set-Cookie2. I > presume the Set-Cookie2 is for sending multiple cookies in one header? > Is that widely accepted? > > Also -- do you know which RFC includes the Content-Disposition spec? > > > On Dec 9, 2009, at 6:24 PM, Rob Lemley wrote: > >> I'd recommend having rfc2109 and rfc2965 handy. From bil at corry.biz Fri Dec 11 04:19:11 2009 From: bil at corry.biz (Bil Corry) Date: Fri, 11 Dec 2009 01:19:11 -0800 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: <4B220BF2.90104@corry.biz> References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> <104D293C-5EFD-4073-BC0D-55DC06434745@mac.com> <4B203FBF.1000100@booksys.com> <4B220BF2.90104@corry.biz> Message-ID: <4B220E8F.9080701@corry.biz> Bil Corry wrote on 12/11/2009 1:08 AM: > Cookies were originally created by Netscape, then RFC2109 made it a > formal specification, and RFC2965 superseded RFC2109 to fix certain > issues and extend the functionality. But in practice, the browser > vendors ignored all of the specifications and did their own thing, > mostly driven by the behavior of other browsers along with how > servers actually provided Set-Cookie. BTW, for the truly curious, a history of cookies is here (49 pages!): http://arxiv.org/PS_cache/cs/pdf/0105/0105018v1.pdf - Bil From charles_thomas at mac.com Fri Dec 11 12:41:27 2009 From: charles_thomas at mac.com (Tom Bowden) Date: Fri, 11 Dec 2009 11:41:27 -0600 Subject: [FASTCGI] Cookie processing in Fast CGI In-Reply-To: References: <9C951155AD144AFA88EE4B3E97E1EDF3@chapmanm64> Message-ID: I decided not to go with JSON - since I can use maps/multimaps. I am sticking with pcrecpp, but I will keep that logic in singleton patterns (the parsing). What I am doing now is that I created an object (FCGXProcessor). It has a series of operator<< functions, and maintains a deque of request objects that have a common base class (TRequestObject). This deque holds the cookies, contents, and other variables as TCookie, THeader, TContent, and TAnnotate (processor specific comments/ documentation). The deque of objects is created from the environment variables, the stdin (FCGX_Request.in), and additional sources. Once in the common format, I can manipulate as needed and then output the results of processor (which is a document to return to client). FCGXProcessor p; FCGI_Response r; while ( 1 ) { if ( FCGX_Accept_r(&r) == 0 ) { p << r } .... MODIFY ... ostringstream out; out << p; FCGX_PutStr( out.c_str(), out.str().size(), r.out); | On Dec 10, 2009, at 2:33 PM, Martin Chapman wrote: > My opinion would be parse it yourself so it's not dependent. That > said, > it's your project so do what makes the most sense for you. > > Martin > > > -----Original Message----- > From: Tom Bowden [mailto:charles_thomas at mac.com] > Sent: Thursday, December 10, 2009 1:31 PM > To: Martin Chapman > Cc: 'FastCGI Developers' > Subject: Re: [FASTCGI] Cookie processing in Fast CGI > > martin, > > A couple questions (compiled from previous post with an addition): > > I tend to use external libraries that make my life easier. Namely > jsoncpp and pcrecpp. > > With pcrecpp i can (for example) replace the parsing the logic where > you're going character by character with something like: > > #define PCRE_COOKIE_MASK "^Set-Cookie:[ \t]*([^=]+)=(.*)$" > > and then: > std::string cookie_name; > std::string cookie_value; > if ( pcre_object->PartialMatch(instr, &cookie_name, &cookie_value) ) { > // do assignment logic... > } > > Obviously some times its not good to rely on third party libs > (portability/etc). Is this one of those times? What would be most > useful to the community? > > Tom > > > On Dec 9, 2009, at 3:02 PM, Martin Chapman wrote: > >> Tom, >> >> It's a little ugly because it's COM and if you convert it to >> FastCGI it >> would be cool if you posted it back for the rest of us if you can. >> The >> entire COM implementation is attached. >> >> General Gist: >> >> 1. Get the cookie from the env vars. Should be called HTTP_COOKIE. >> >> 2. Use a method like the one below to parse the cookie value. >> >> STDMETHODIMP CCookie::ParseValue(BSTR sCookie) >> { >> AFX_MANAGE_STATE(AfxGetStaticModuleState()); >> >> _bstr_t bstrCookie(sCookie); >> if (bstrCookie.length() == 0) >> return E_INVALIDARG; >> >> CString strCookie = (TCHAR*) bstrCookie; >> LPCSTR pEnd = strCookie; >> LPCSTR pStart = strCookie; >> CString name, value; >> >> while (*pEnd != '\0') >> { >> while (*pEnd && *pEnd != '=' && *pEnd != '&') >> pEnd++; >> >> if (*pEnd == '\0' || *pEnd == '&') >> { >> if (pEnd > pStart) >> { >> CopyToCString(value, pStart, pEnd); >> } >> put_Value(_bstr_t(value.GetBuffer())); >> if (*pEnd == '&') >> { >> pEnd++; >> pStart = pEnd; >> continue; >> } >> return S_OK; >> } >> else if (*pEnd == '=' ) >> { >> if (pEnd > pStart) >> { >> CopyToCString(name, pStart, pEnd); >> } >> else >> { >> pEnd++; >> pStart = pEnd; >> break; >> } >> >> pEnd++; >> pStart = pEnd; >> while (*pEnd && *pEnd != '&' && *pEnd != '=') >> pEnd++; >> if (pEnd > pStart) >> CopyToCString(value, pStart, pEnd); >> >> AddValue(_bstr_t(name.GetBuffer()), >> _bstr_t(value.GetBuffer())); >> if (*pEnd != '\0') >> pEnd++; >> >> pStart = pEnd; >> } >> } >> >> return S_OK; >> } >> >> 3. The following func parses a single cookie value and is used in >> the func >> above. >> >> STDMETHODIMP CCookie::ParseValue(BSTR sCookie) >> { >> AFX_MANAGE_STATE(AfxGetStaticModuleState()); >> >> _bstr_t bstrCookie(sCookie); >> if (bstrCookie.length() == 0) >> return E_INVALIDARG; >> >> CString strCookie = (TCHAR*) bstrCookie; >> LPCSTR pEnd = strCookie; >> LPCSTR pStart = strCookie; >> CString name, value; >> >> while (*pEnd != '\0') >> { >> while (*pEnd && *pEnd != '=' && *pEnd != '&') >> pEnd++; >> >> if (*pEnd == '\0' || *pEnd == '&') >> { >> if (pEnd > pStart) >> { >> CopyToCString(value, pStart, pEnd); >> } >> put_Value(_bstr_t(value.GetBuffer())); >> if (*pEnd == '&') >> { >> pEnd++; >> pStart = pEnd; >> continue; >> } >> return S_OK; >> } >> else >> if (*pEnd == '=' ) >> { >> if (pEnd > pStart) >> { >> CopyToCString(name, pStart, pEnd); >> } >> else >> { >> pEnd++; >> pStart = pEnd; >> break; >> } >> >> pEnd++; >> pStart = pEnd; >> while (*pEnd && *pEnd != '&' && *pEnd != '=') >> pEnd++; >> if (pEnd > pStart) >> CopyToCString(value, pStart, pEnd); >> >> AddValue(_bstr_t(name.GetBuffer()), >> _bstr_t(value.GetBuffer())); >> if (*pEnd != '\0') >> pEnd++; >> >> pStart = pEnd; >> } >> } >> >> return S_OK; >> } >> >> >> -----Original Message----- >> From: fastcgi-developers-bounces >> +chapmanm=pixia.com at mailman.fastcgi.com >> [mailto:fastcgi-developers-bounces >> +chapmanm=pixia.com at mailman.fastcgi.com] >> On Behalf Of Tom Bowden >> Sent: Wednesday, December 09, 2009 1:18 PM >> To: FastCGI Developers >> Subject: [FASTCGI] Cookie processing in Fast CGI >> >> Is there a thread somewhere that talks about parsing cookies - or, is >> this something that I have to treat like any other header parsing >> task. >> >> Tom >> >> _______________________________________________ >> FastCGI-developers mailing list >> FastCGI-developers at mailman.fastcgi.com >> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi- >> developers> . >> cpp> > From i_konstantin at yahoo.com Fri Dec 11 22:36:35 2009 From: i_konstantin at yahoo.com (Konstantin Ivanov) Date: Fri, 11 Dec 2009 19:36:35 -0800 (PST) Subject: [FASTCGI] can FCGI_STDIN content length be increased when receiving the STDIN data? Message-ID: <523848.32225.qm@web65614.mail.ac4.yahoo.com> Hi all, I have the following situation which I am try to bypass in attempt to increase the performance. I am using PHP (php-cgi) in FCGI mode on Windows. I have a client to read from the fastcgi server written in C++. The "issue" I am experience is the size of the STDIN content length. I have a file of 65000 bytes (actually it is a print from php-info() function), but when I read it from the FastCGI process the STDIN type header always comes back with the maximum of 8184 bytes, which means that in order to read the entire request and before receiving FCGI_END_REQUEST i have to loop and read from the socket fd 8 times. I think that this is very inconvenient and I was wondering what controls the STDIN maximum content length? You see, if one would increase the Windows socket window size to say 128Kb, then the request of 65000 bytes could be read with a single iteration to recv() function. Did anyone experience the same behavior and if so, would you please give your advice or point in the right direction. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From chapmanm at pixia.com Fri Dec 11 22:43:22 2009 From: chapmanm at pixia.com (Martin Chapman) Date: Fri, 11 Dec 2009 20:43:22 -0700 Subject: [FASTCGI] can FCGI_STDIN content length be increased when receivingthe STDIN data? In-Reply-To: <523848.32225.qm@web65614.mail.ac4.yahoo.com> References: <523848.32225.qm@web65614.mail.ac4.yahoo.com> Message-ID: It might be a limit of Apache server with their bucket brigade buffer sizes. This define is in apr_buckets.h and I know that mod_fastcgid uses a bucket brigade to stream IO. Maybe there is an Apache config setting in httpd.conf to increase the limit. /** default bucket buffer size - 8KB minus room for memory allocator headers */ #define APR_BUCKET_BUFF_SIZE 8000 Martin _____ From: fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com [mailto:fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com] On Behalf Of Konstantin Ivanov Sent: Friday, December 11, 2009 8:37 PM To: fastcgi-developers at mailman.fastcgi.com Subject: [FASTCGI] can FCGI_STDIN content length be increased when receivingthe STDIN data? Hi all, I have the following situation which I am try to bypass in attempt to increase the performance. I am using PHP (php-cgi) in FCGI mode on Windows. I have a client to read from the fastcgi server written in C++. The "issue" I am experience is the size of the STDIN content length. I have a file of 65000 bytes (actually it is a print from php-info() function), but when I read it from the FastCGI process the STDIN type header always comes back with the maximum of 8184 bytes, which means that in order to read the entire request and before receiving FCGI_END_REQUEST i have to loop and read from the socket fd 8 times. I think that this is very inconvenient and I was wondering what controls the STDIN maximum content length? You see, if one would increase the Windows socket window size to say 128Kb, then the request of 65000 bytes could be read with a single iteration to recv() function. Did anyone experience the same behavior and if so, would you please give your advice or point in the right direction. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From i_konstantin at yahoo.com Fri Dec 11 22:52:38 2009 From: i_konstantin at yahoo.com (Konstantin Ivanov) Date: Fri, 11 Dec 2009 19:52:38 -0800 (PST) Subject: [FASTCGI] can FCGI_STDIN content length be increased when receivingthe STDIN data? In-Reply-To: References: <523848.32225.qm@web65614.mail.ac4.yahoo.com> Message-ID: <673417.56519.qm@web65605.mail.ac4.yahoo.com> Martin, Thanks for the comments. First I wanted to correct myself when I said STDIN, it is actually the data that comes from FCGI_STDOUT. Secondly, I am not using the Apache server, I am using the custom server. Thanks, Konstantin ________________________________ From: Martin Chapman To: Konstantin Ivanov ; fastcgi-developers at mailman.fastcgi.com Sent: Fri, December 11, 2009 7:43:22 PM Subject: RE: [FASTCGI] can FCGI_STDIN content length be increased when receivingthe STDIN data? It might be a limit of Apache server with their bucket brigade buffer sizes. This define is in apr_buckets.h and I know that mod_fastcgid uses a bucket brigade to stream IO. Maybe there is an Apache config setting in httpd.conf to increase the limit. /** default bucket buffer size - 8KB minus room for memory allocator headers */ #defineAPR_BUCKET_BUFF_SIZE 8000 Martin ________________________________ From:fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com [mailto:fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com] On Behalf Of Konstantin Ivanov Sent: Friday, December 11, 2009 8:37 PM To: fastcgi-developers at mailman.fastcgi.com Subject: [FASTCGI] can FCGI_STDIN content length be increased when receivingthe STDIN data? Hi all, I have the following situation which I am try to bypass in attempt to increase the performance. I am using PHP (php-cgi) in FCGI mode on Windows. I have a client to read from the fastcgi server written in C++. The "issue" I am experience is the size of the STDIN content length. I have a file of 65000 bytes (actually it is a print from php-info() function), but when I read it from the FastCGI process the STDIN type header always comes back with the maximum of 8184 bytes, which means that in order to read the entire request and before receiving FCGI_END_REQUEST i have to loop and read from the socket fd 8 times. I think that this is very inconvenient and I was wondering what controls the STDIN maximum content length? You see, if one would increase the Windows socket window size to say 128Kb, then the request of 65000 bytes could be read with a single iteration to recv() function. Did anyone experience the same behavior and if so, would you please give your advice or point in the right direction. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From chapmanm at pixia.com Fri Dec 11 22:52:38 2009 From: chapmanm at pixia.com (Martin Chapman) Date: Fri, 11 Dec 2009 20:52:38 -0700 Subject: [FASTCGI] can FCGI_STDIN content length be increased when receivingthe STDIN data? In-Reply-To: <523848.32225.qm@web65614.mail.ac4.yahoo.com> References: <523848.32225.qm@web65614.mail.ac4.yahoo.com> Message-ID: <80D472FBC7054EAEBE462DFBBCDFC8A6@chapmanm64> Yeah, I did some research and it looks like APR_BUCKET_BUFF_SIZE 8000 is your limit. Apache developers did this to align data reads and writes with system page sizes to maximize performance. I didn't find a config option for it because it could hinder performance if you tune it wrong. In order to correctly increase it you will have to recompile Apache with the value set to be an exact multiple of 4KB in order to not affect performance of Apache. The setting is located in srclib/apr-util/buckets/apr_buckets.h under the Apache source code. A link that talks about is at http://www.mail-archive.com/dev at httpd.apache.org/msg44168.html Martin _____ From: fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com [mailto:fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com] On Behalf Of Konstantin Ivanov Sent: Friday, December 11, 2009 8:37 PM To: fastcgi-developers at mailman.fastcgi.com Subject: [FASTCGI] can FCGI_STDIN content length be increased when receivingthe STDIN data? Hi all, I have the following situation which I am try to bypass in attempt to increase the performance. I am using PHP (php-cgi) in FCGI mode on Windows. I have a client to read from the fastcgi server written in C++. The "issue" I am experience is the size of the STDIN content length. I have a file of 65000 bytes (actually it is a print from php-info() function), but when I read it from the FastCGI process the STDIN type header always comes back with the maximum of 8184 bytes, which means that in order to read the entire request and before receiving FCGI_END_REQUEST i have to loop and read from the socket fd 8 times. I think that this is very inconvenient and I was wondering what controls the STDIN maximum content length? You see, if one would increase the Windows socket window size to say 128Kb, then the request of 65000 bytes could be read with a single iteration to recv() function. Did anyone experience the same behavior and if so, would you please give your advice or point in the right direction. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From chapmanm at pixia.com Fri Dec 11 22:57:13 2009 From: chapmanm at pixia.com (Martin Chapman) Date: Fri, 11 Dec 2009 20:57:13 -0700 Subject: [FASTCGI] can FCGI_STDIN content length be increased when receivingthe STDIN data? In-Reply-To: <673417.56519.qm@web65605.mail.ac4.yahoo.com> References: <523848.32225.qm@web65614.mail.ac4.yahoo.com> <673417.56519.qm@web65605.mail.ac4.yahoo.com> Message-ID: Konstantin Could be the same issue on either end of the pipe, regardless of web server. Sorry I could not be of more help. Martin _____ From: Konstantin Ivanov [mailto:i_konstantin at yahoo.com] Sent: Friday, December 11, 2009 8:53 PM To: Martin Chapman; fastcgi-developers at mailman.fastcgi.com Subject: Re: [FASTCGI] can FCGI_STDIN content length be increased when receivingthe STDIN data? Martin, Thanks for the comments. First I wanted to correct myself when I said STDIN, it is actually the data that comes from FCGI_STDOUT. Secondly, I am not using the Apache server, I am using the custom server. Thanks, Konstantin _____ From: Martin Chapman To: Konstantin Ivanov ; fastcgi-developers at mailman.fastcgi.com Sent: Fri, December 11, 2009 7:43:22 PM Subject: RE: [FASTCGI] can FCGI_STDIN content length be increased when receivingthe STDIN data? It might be a limit of Apache server with their bucket brigade buffer sizes. This define is in apr_buckets.h and I know that mod_fastcgid uses a bucket brigade to stream IO. Maybe there is an Apache config setting in httpd.conf to increase the limit. /** default bucket buffer size - 8KB minus room for memory allocator headers */ #define APR_BUCKET_BUFF_SIZE 8000 Martin _____ From: fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com [mailto:fastcgi-developers-bounces+chapmanm=pixia.com at mailman.fastcgi.com] On Behalf Of Konstantin Ivanov Sent: Friday, December 11, 2009 8:37 PM To: fastcgi-developers at mailman.fastcgi.com Subject: [FASTCGI] can FCGI_STDIN content length be increased when receivingthe STDIN data? Hi all, I have the following situation which I am try to bypass in attempt to increase the performance. I am using PHP (php-cgi) in FCGI mode on Windows. I have a client to read from the fastcgi server written in C++. The "issue" I am experience is the size of the STDIN content length. I have a file of 65000 bytes (actually it is a print from php-info() function), but when I read it from the FastCGI process the STDIN type header always comes back with the maximum of 8184 bytes, which means that in order to read the entire request and before receiving FCGI_END_REQUEST i have to loop and read from the socket fd 8 times. I think that this is very inconvenient and I was wondering what controls the STDIN maximum content length? You see, if one would increase the Windows socket window size to say 128Kb, then the request of 65000 bytes could be read with a single iteration to recv() function. Did anyone experience the same behavior and if so, would you please give your advice or point in the right direction. Thank you, -------------- next part -------------- An HTML attachment was scrubbed... URL: From mst at shadowcat.co.uk Mon Dec 21 14:00:32 2009 From: mst at shadowcat.co.uk (Matt S Trout) Date: Mon, 21 Dec 2009 19:00:32 +0000 Subject: [FASTCGI] new FCGI.pm dev release out Message-ID: <20091221190032.GQ21799@agaton.scsys.co.uk> search.cpan URL: http://search.cpan.org/~mstrout/FCGI-0.67_01/ download URL: http://search.cpan.org/CPAN/authors/id/M/MS/MSTROUT/FCGI-0.67_01.tar.gz CPAN install via: cpan> install MSTROUT/FCGI-0.67_01.tar.gz Source code available at: git clone git://git.shadowcat.co.uk/catagits/fcgi2.git Gitweb available at: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits/fcgi2.git;a=summary Please everybody give it a test and tell us if it works for you. -- Matt S Trout Catalyst and DBIx::Class consultancy with a clue Technical Director and a commit bit: http://shadowcat.co.uk/catalyst/ Shadowcat Systems Limited mst (@) shadowcat.co.uk http://shadowcat.co.uk/blog/matt-s-trout/ From Howard.May at dialogic.com Thu Dec 24 04:49:03 2009 From: Howard.May at dialogic.com (Howard May) Date: Thu, 24 Dec 2009 04:49:03 -0500 Subject: [FASTCGI] Manually spawning a Windows fastCGI application Message-ID: <3256B665A5FD30499BA25BFF2EB77F3F04D7FE9D1D@MBX.dialogic.com> I am struggling to find documentation explaining how to manually start a windows fastCGI document using a named pipe or a TCP/ IP connection. I would be exceptionally grateful if someone could point me in the direction of some documentation explaining this. Best Regards Howard May -------------- next part -------------- An HTML attachment was scrubbed... URL: From i_konstantin at yahoo.com Thu Dec 24 12:23:51 2009 From: i_konstantin at yahoo.com (Konstantin Ivanov) Date: Thu, 24 Dec 2009 09:23:51 -0800 (PST) Subject: [FASTCGI] Manually spawning a Windows fastCGI application In-Reply-To: <3256B665A5FD30499BA25BFF2EB77F3F04D7FE9D1D@MBX.dialogic.com> References: <3256B665A5FD30499BA25BFF2EB77F3F04D7FE9D1D@MBX.dialogic.com> Message-ID: <360130.40839.qm@web65610.mail.ac4.yahoo.com> The fastcgi website contains a C library as an example how to use the protocol. This code file (http://www.fastcgi.com/devkit/libfcgi/os_win32.c) contains example code on how to spawn a process on windows using either Named pipes or TCP for communication with the process. It is a good start, but, not to offend creators of the site and this example library, I think there is a major gap in documentation and while the this library is a good start I believe there are a lot of things that are unnecessary and overcomplicated for beginners to understand. Howard, if you have any questions I would be glad to help to my ability as I've experimented with fastcgi on named pipes and sockets. Hope the code file referenced earlier is somewhat of a help. Merry Christmas. ________________________________ From: Howard May To: "fastcgi-developers at mailman.fastcgi.com" Sent: Thu, December 24, 2009 1:49:03 AM Subject: [FASTCGI] Manually spawning a Windows fastCGI application I am struggling to find documentation explaining how to manually start a windows fastCGI document using a named pipe or a TCP/ IP connection. I would be exceptionally grateful if someone could point me in the direction of some documentation explaining this. Best Regards Howard May -------------- next part -------------- An HTML attachment was scrubbed... URL: From webmaster at cosmicperl.com Fri Dec 25 05:50:51 2009 From: webmaster at cosmicperl.com (Lyle) Date: Fri, 25 Dec 2009 10:50:51 +0000 Subject: [FASTCGI] Manually spawning a Windows fastCGI application In-Reply-To: <360130.40839.qm@web65610.mail.ac4.yahoo.com> References: <3256B665A5FD30499BA25BFF2EB77F3F04D7FE9D1D@MBX.dialogic.com> <360130.40839.qm@web65610.mail.ac4.yahoo.com> Message-ID: <4B34990B.9000405@cosmicperl.com> Konstantin Ivanov wrote: > The fastcgi website contains a C library as an example how to use the > protocol. This code file > (http://www.fastcgi.com/devkit/libfcgi/os_win32.c) contains example > code on how to spawn a process on windows using either Named pipes or > TCP for communication with the process. It is a good start, but, not > to offend creators of the site and this example library, I think there > is a major gap in documentation and while the this library is a good > start I believe there are a lot of things that are unnecessary and > overcomplicated for beginners to understand. Howard, if you have any > questions I would be glad to help to my ability as I've experimented > with fastcgi on named pipes and sockets. Hope the code file referenced > earlier is somewhat of a help. You are More than welcome to contribute new guides and documentation. In fact, I'd encourage you to do so :) Lyle From jsprenkle at gmail.com Mon Dec 28 06:58:14 2009 From: jsprenkle at gmail.com (Jay Sprenkle) Date: Mon, 28 Dec 2009 05:58:14 -0600 Subject: [FASTCGI] Segmentation fault :-( In-Reply-To: References: Message-ID: <1b5f39a10912280358k2fc5ef59rff71fd12d196c0ae@mail.gmail.com> Your program is probably failing because the environment is different when executed from apache. On Thu, Oct 22, 2009 at 4:47 AM, David Wantia wrote: > HI, > > i have a problem with my fcgi. it can be execute in two ways. > -------------- next part -------------- An HTML attachment was scrubbed... URL: