Branch: Tag:

2011-02-09

2011-02-09 08:21:57 by Martin Jonsson <marty@roxen.com>

Return a 503 response if a request has been waiting for too long on the handler queue. Simplistic solution of [Bug 5886 (#5886)].

Rev: server/base_server/configuration.pike:1.714
Rev: server/protocols/http.pike:1.637

2:   // Modified by Francesco Chemolli to add throttling capabilities.   // Copyright © 1996 - 2009, Roxen IS.    - constant cvs_version = "$Id: http.pike,v 1.636 2010/12/08 14:56:03 marty Exp $"; + constant cvs_version = "$Id: http.pike,v 1.637 2011/02/09 08:21:57 marty Exp $";   // #define REQUEST_DEBUG   #define MAGIC_ERROR   
2979:    int now = gethrtime();    queue_time = now - queue_time;    +  // Let's see if the queue time was so long that we should return a +  // "503 - server too busy" response.. +  int queue_timeout = conf->handler_queue_timeout; +  if (queue_timeout && queue_time/1E6 > queue_timeout) { +  file = Roxen.http_rxml_answer (conf->query ("503-message"), +  this, 0, "text/html"); +  file->error = Protocols.HTTP.HTTP_UNAVAIL; +  NO_PROTO_CACHE(); +  handle_time = 0; +  handle_vtime = 0; +  TIMER_END(handle_request); +  send_result(); +  return; +  } +    #ifdef MAGIC_ERROR    if(prestate->old_error)    {