Thread

Posted on Sat Aug 13 23:24:17 2005 by bblakley
Any way to tell HTTP::Proxy to end?

First, thanks for such a great module.

Just as you use start() to start the main loop, is there any accessor that can be used to tell the main loop to end? I see that there is an accessor called "loop" that is denoted as "read-only" and is described as "Internal. False when the main loop is about to be broken." However, other than reaching the specified maxconn value I don't see anything that would ever cause the loop to *be* broken.

As an operator I can press Ctrl-C or Ctrl-Break to exit a program that has called start(), but I'm guessing there is probably a way to "break" it programmatically.

Direct Responses: 879 | Write a response
Posted on Sat Aug 13 23:45:53 2005 by book in response to 878
Re: Any way to tell HTTP::Proxy to end?

Well, you could always do $self->proxy->{loop} = 0 but that would break the encapsulation.

Breaking the loop will prevent new childs to be forked, but the living one will at least finished the active connections before dying (they will not accept new connections).

Should I make loop() a read-write accessor in 0.16?

Direct Responses: 880 | Write a response
Posted on Sun Aug 14 07:34:29 2005 by bblakley in response to 879
Re: Any way to tell HTTP::Proxy to end?

That sounds like it would work fine to me. If I understand correctly, then if wanted to create a request header filter that would look at the requests and watch for one that meets some predefined criteria, I could then do $self->proxy->{loop} = 0 to shutdown if I see it come through.

I tried adding that code now and it doesn't cause it to return from start().

I have another suggestion for 0.16 that I'll put in another post so as to keep the threads logical. Thanks again for a great module.

Direct Responses: 882 | Write a response
Posted on Sun Aug 14 10:48:54 2005 by book in response to 880
Re: Any way to tell HTTP::Proxy to end?

I'm stupid: HTTP::Proxy forks to start its children, and the main process never directly handles connections (except in very rare cases such as when too many child processes are started). So the only process that would be able to correctly handle that piece of information never actually sees it.

What you want is some way for the main process and its child process to communicate.

At this time, HTTP::Proxy has no built-in way to do this. :-( The main problem is that, when I'll have added this possibility, then I'll need to build some way for the main process to act on the received information (yet another hook somewhere).

You have another option: to create a global variable $main::PID (initialised to $$) and then have one of the child processes kill the parent whith the appropriate signal.

Write a response