Multithreading and cgi.rb 
Author Message
 Multithreading and cgi.rb

I've written a small multi-threaded message board server.

I originally tried to use cgi.rb, because I thought that made sense,
but hit problems because it assumes input is from $stdin and output is to
$stdout.  Obviously, since I can have multiple threads running, I
couldn't just assign the socket for a connection to $stdin and $stdout,
since then I'd get intermingled I/O and everything would fall in a heap.

Since I now have a basically functioning system, I thought it would be a
good time to go back and see if I can't work out some way to make cgi.rb
do what I want.

Has anyone else done this kind of thing?  Ie, used the cgi.rb facilities
in a multi-threaded program?

If so, can you give me any pointers on the simplest way to make the code
do all its I/O to a given socket?

TIA



Wed, 19 May 2004 16:48:36 GMT  
 Multithreading and cgi.rb

H> Has anyone else done this kind of thing?  Ie, used the cgi.rb facilities
H> in a multi-threaded program?

 Well, I know nothing about cgi (protocol not library) but I think that it
 use also environnemntal variable and it will be difficult to use it in a
 multi-threaded program.

Guy Decoux



Wed, 19 May 2004 19:47:19 GMT  
 Multithreading and cgi.rb

Quote:

> I've written a small multi-threaded message board server.

> I originally tried to use cgi.rb, because I thought that made sense,
> but hit problems because it assumes input is from $stdin and output is to
> $stdout.  Obviously, since I can have multiple threads running, I
> couldn't just assign the socket for a connection to $stdin and $stdout,
> since then I'd get intermingled I/O and everything would fall in a heap.

Do you want multiple connections, i.e. handling multiple requests within
one CGI application? This is impossible with CGI.

Have a look at FastCGI.

Regards,

  Michael

--
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de



Wed, 19 May 2004 20:03:43 GMT  
 Multithreading and cgi.rb

Quote:

> Do you want multiple connections, i.e. handling multiple requests within
> one CGI application? This is impossible with CGI.

As I discovered as soon as I tried to use it :-).

Quote:
> Have a look at FastCGI.

Unfotunately, as far as I can see, all that does is accept the multiple
connections, read the request and pass it on.  I have code for
that which I'm quite happy with.

What I was after from the CGI stuff was the ability to pull the request
apart, like pulling out cookies, reading multi-part forms and accepting
uploaded files, etc.

Not to worry.  I might be able to"borrow" some of the code from cgi.rb
to augment what I've written.

It would be nice if cgi.rb could be changed at some point to make it
usable in multi-threaded applications, because it provides a lot of
functionality that is quite complex to get right.



Thu, 20 May 2004 04:17:36 GMT  
 Multithreading and cgi.rb
At Sat, 1 Dec 2001 17:58:16 +0900,

Quote:

> I originally tried to use cgi.rb, because I thought that made sense,
> but hit problems because it assumes input is from $stdin and output is to
> $stdout.  Obviously, since I can have multiple threads running, I
> couldn't just assign the socket for a connection to $stdin and $stdout,
> since then I'd get intermingled I/O and everything would fall in a heap.

You can make new CGI subclass and override methods; env_table,
stdinput and stdoutput.  They're defaulted to return ENV,
$stdin and $> respectively.

Nobu Nakada



Sat, 22 May 2004 16:47:22 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. CGI in RB (for MAC OS X)

2. RB as a cgi?

3. cgi/session.rb help: How does it work ?

4. fcgi and cgi-lib.rb

5. Strange cgi.rb <--> StringIO problem

6. eruby and cgi.rb

7. cgi.rb - sending same named headers

8. cgi.rb:490:in `+': failed to convert Fixnum into String

9. are there unit tests for cgi.rb?

10. cgi.rb multipart question

11. param() method weirdness in cgi.rb

12. Minor cgi.rb question

 

 
Powered by phpBB® Forum Software