[Mongrel] mongrel thread safety and global variables

hemant gethemant at gmail.com
Mon Sep 4 14:24:53 EDT 2006

Well, I think i have figured out the problem with my code (*but i am not
entirely sure..so please correct me if i am wrong)

If you look at above code, then you will see:

   timeout(6) do
    # read from socket
rescue Timeout::Error
  # error handling

My assertion says, sometimes for certain protocol codes, the time to read
from the socket is more than 6 seconds and hence that "gets request" is
timed out there. Now..in the next call, when i put some new request to the
socket...i get response for the previous request, because socket still
contains data that was written to it after the timeout. Ugly,right?

Solution I have thought is:
  1. Send a unique GUID as a extended modifier with each request and expect
that proxy will echo it to us.
  2. Somehow clear the socket, before read...not entirely sure abt
this.Somebody on ruby-lang  also suggested that, use Eventmachine.

On 9/2/06, Zed Shaw <zedshaw at zedshaw.com> wrote:
> On Sat, 2006-09-02 at 17:00 +0530, hemant wrote:
> > Yes...its a multithreaded and supposed to server request flawlessly.
> >
> > BTW, as a  quick check...i wrote a ruby program to fetch data for some
> > 10000 iterations and and append it to a CSV file...and didn't get a
> > single data mangling error.
> >
> > Next step, I will try 100 simultaneous threads, fetching the data and
> > see if there is a mis-match.
> And randomize it.  Ruby's threads work fairly predictably so without a
> random short think time to mix things up you won't get good results.
> --
> Zed A. Shaw
> http://www.zedshaw.com/
> http://mongrel.rubyforge.org/
> http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users

nothing much to talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20060904/3c61ee8b/attachment.html 

More information about the Mongrel-users mailing list