On Thursday, September 2, 2004, at 08:16  PM, Yukihiro Matsumoto wrote:

> Hi,
>
> In message "fastcgi & continuations (Re: Idea: Webshare)"
>     on Tue, 31 Aug 2004 15:14:29 +0900, Patrick May 
> <patrick / hexane.org> writes:
>
> |I wasn't able to make this continuation trick work for me.  It flip
> |flops -- it works the first time, crashes the second time, then
> |mod_fastcgi restarts the process and the cycle repeats.
> |
> |I wish I could make these continuations work, though.
>
> Need more info.  Operating system, interpreter version, Apache version
> etc.

Here's a simple example of the bug(?).   Save this as fast.rb:

   class Server
     CONTINUATION = []
     def Server::new(*args)
       at_exit do
         puts 'at_exit'
         if CONTINUATION[0]
           CONTINUATION[0].call
         end
       end

       callcc do |c|
         CONTINUATION[0] = c
       end

       puts 'Do you want to continue?'
       answer = gets

       if (answer.strip == 'no')
         CONTINUATION[0] = nil
       end
     end
   end

   server = Server.new

Here's what happens when I run this script.  Note that I am typing the 
'yes' and 'no' in this example:

   [laputa:~/programming/narf-servers] patsplat% ruby fast.rb
   Do you want to continue?
   no
   at_exit
   [laputa:~/programming/narf-servers] patsplat% ruby fast.rb
   Do you want to continue?
   yes
   at_exit
   Do you want to continue?
   yes
   fast.rb:24: compile error (SyntaxError)
   fast.rb:24: [BUG] Bus Error
   ruby 1.8.1 (2003-12-25) [powerpc-darwin]

   Abort
   [laputa:~/programming/narf-servers] patsplat% ruby --version
   ruby 1.8.1 (2003-12-25) [powerpc-darwin]
   [laputa:~/programming/narf-servers] patsplat%

Cheers,

Patrick